feat(web): add notebook chat panel (#8)

This commit is contained in:
Florian Schmidt
2026-11-16 10:17:20 +01:00
parent 4fe7e4e376
commit 0055001abf
19 changed files with 602 additions and 16 deletions
+8 -1
View File
@@ -29,6 +29,7 @@ import type { Api } from "./api";
import { emptySession, eventReducer, stepKey } from "./events";
import { ParamsForm } from "./ParamsForm";
import { StepCard } from "./StepCard";
import { ChatPanel } from "./ChatPanel";
const TerminalSlot = lazy(() =>
import("./TerminalSlot").then((module) => ({ default: module.TerminalSlot })),
);
@@ -55,6 +56,7 @@ export function App({ api }: { api: Api }) {
const [values, setValues] = useState<ParamValues>({});
const [edit, setEdit] = useState(false);
const [terminal, setTerminal] = useState(false);
const [chat, setChat] = useState(false);
const [terminalOpened, setTerminalOpened] = useState(false);
const [conflict, setConflict] = useState(false);
const [error, setError] = useState("");
@@ -319,7 +321,7 @@ export function App({ api }: { api: Api }) {
</main>
);
return (
<div className={`app ${terminal ? "with-terminal" : ""}`}>
<div className={`app ${terminal || chat ? "with-terminal" : ""}`}>
<aside className="sidebar">
<h1>
ShellBook<span>RUNBOOKS</span>
@@ -348,6 +350,7 @@ export function App({ api }: { api: Api }) {
</aside>
<main>
<div className="toolbar">
<button aria-expanded={chat} onClick={() => { setChat(!chat); setTerminal(false); }}>Chat</button>
<span>{doc?.notebook.title ?? "Loading workspace…"}</span>
<button onClick={() => setEdit(!edit)}>
{edit ? "Close editor" : "Edit Markdown"}
@@ -356,6 +359,7 @@ export function App({ api }: { api: Api }) {
aria-expanded={terminal}
onClick={() => {
setTerminalOpened(true);
setChat(false);
setTerminal(!terminal);
}}
>
@@ -469,6 +473,9 @@ export function App({ api }: { api: Api }) {
</>
)}
</main>
{chat && <ChatPanel notebookPath={doc?.path} openNotebook={path => {
if (!dirty || window.confirm("Discard unsaved edits?")) void load(path);
}} openTerminal={() => { setChat(false); setTerminalOpened(true); setTerminal(true); }} />}
{terminalOpened && (
<Suspense fallback={<p>Loading terminal...</p>}>
<TerminalSlot collapsed={!terminal} />