feat(web): rework layout and quality of life (#12)

- App shell: top bar with connection state and Chat/Terminal toggles,
  per-column scrolling, sidebar only on the Notebooks page.
- Hash routes (#/notebooks/<path>, #/hosts, #/settings) so reloads and
  links keep the open notebook and page.
- Parameters sit beside the notebook on wide screens, collapsible, with
  missing-count summary and Reset; non-secret values are remembered per
  notebook in localStorage (secrets and undeclared names never stored).
- Sticky notebook header with breadcrumbs, check summary and run-all;
  Ctrl/Cmd+S saves the Markdown draft.
- Step cards show target, one deduplicated hint for missing values and
  copy feedback.
- Shared Dialog, Menu and CopyButton components; notebook and host
  actions move into menus and modal dialogs.
- Hosts page as a compact list; Settings split into cards with sign out
  for this browser.
This commit is contained in:
Florian Schmidt
2026-11-16 12:32:01 +01:00
parent 16cfcd36ea
commit e38f9c453c
20 changed files with 2297 additions and 1129 deletions
+36 -3
View File
@@ -1,3 +1,4 @@
import { useState } from "react";
import type { HostInfo, Notebook, ParamDef, ParamValues } from "@shellbook/core";
/** An included notebook (`::use`) whose parameters the form shows as a group. */
@@ -13,6 +14,7 @@ export function ParamsForm({
hosts,
groups = [],
onChange,
onReset,
}: {
notebook: Notebook;
values: ParamValues;
@@ -21,7 +23,10 @@ export function ParamsForm({
/** Active included notebooks; parameters of inactive ones are hidden. */
groups?: ParamGroup[];
onChange(name: string, value: string): void;
/** Clears the values typed for this notebook. */
onReset?(): void;
}) {
const [open, setOpen] = useState(true);
const field = (param: ParamDef) => {
const id = `param-${param.name}`;
const local = param.scope ? param.name.slice(param.scope.length + 1) : param.name;
@@ -31,6 +36,8 @@ export function ParamsForm({
value: values[param.name] ?? "",
"aria-labelledby": `${id}-label`,
"aria-invalid": !!errors[param.name],
// Red only for a wrong value; an empty field just still needs one.
className: errors[param.name] && values[param.name] ? "invalid" : undefined,
"aria-describedby": errors[param.name] ? `${id}-error` : undefined,
onChange: (
e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement>,
@@ -61,21 +68,47 @@ export function ParamsForm({
/>
)}
{errors[param.name] && (
<small id={`${id}-error`} className="error">
// An empty field only needs a value: say so quietly; a wrong value is an error.
<small id={`${id}-error`} className={values[param.name] ? "error" : "muted"}>
{errors[param.name]}
</small>
)}
</label>
);
};
const shown = [
...notebook.params.filter((param) => !param.scope),
...groups.flatMap((group) => notebook.params.filter((param) => param.scope === group.scope)),
];
const missing = shown.filter((param) => param.required && !values[param.name]).length;
if (!shown.length) return null;
return (
<form
className="params"
aria-label="Notebook parameters"
onSubmit={(e) => e.preventDefault()}
>
{notebook.params.filter((param) => !param.scope).map(field)}
{groups.map((group) => {
<header>
<h2>Parameters</h2>
<small className={missing ? "pending" : "ok"}>
{missing ? `${missing} required missing` : "All required set"}
</small>
{onReset && open && (
<button type="button" className="link" onClick={onReset}>
Reset
</button>
)}
<button
type="button"
className="link"
aria-expanded={open}
onClick={() => setOpen(!open)}
>
{open ? "Hide" : "Show"}
</button>
</header>
{open && notebook.params.filter((param) => !param.scope).map(field)}
{open && groups.map((group) => {
const params = notebook.params.filter((param) => param.scope === group.scope);
return params.length ? (
<fieldset key={group.scope}>