From 834f8ec55740f03f960a03ad5ccea0752208cde8 Mon Sep 17 00:00:00 2001 From: prem315 Date: Sun, 1 Nov 2026 13:08:09 +0530 Subject: [PATCH 1/5] fix(desktop): align conversations with thread RPC models --- apps/desktop/scripts/dev.mjs | 5 +- apps/desktop/scripts/start-electron.mjs | 3 +- apps/web/src/kernel/servers.ts | 4 +- apps/web/src/widgets/session/address.ts | 11 +- apps/web/src/widgets/session/backend.ts | 232 ++++++++++++------ apps/web/src/widgets/session/composer.tsx | 16 +- apps/web/src/widgets/session/index.ts | 4 +- apps/web/src/widgets/session/queue.tsx | 10 +- apps/web/src/widgets/session/schema.ts | 41 ++-- apps/web/src/widgets/session/view.tsx | 36 +-- apps/widget/src/codework.ts | 50 +++- .../test/__artifacts__/desktop.threads.json | 70 ++++++ packages/codework/test/desktop.test.ts | 131 ++++++++++ 13 files changed, 474 insertions(+), 139 deletions(-) create mode 100644 packages/codework/test/__artifacts__/desktop.threads.json create mode 100644 packages/codework/test/desktop.test.ts diff --git a/apps/desktop/scripts/dev.mjs b/apps/desktop/scripts/dev.mjs index 09ef74e5..f5875cb1 100644 --- a/apps/desktop/scripts/dev.mjs +++ b/apps/desktop/scripts/dev.mjs @@ -65,7 +65,10 @@ while (!(await ready())) await sleep(100); let electron; function startElectron() { - electron = run("node", ["scripts/start-electron.mjs"], { + // pnpm inserts a lone `--` before arguments meant for the script. + const extra = process.argv.slice(2); + if (extra[0] === "--") extra.shift(); + electron = run("node", ["scripts/start-electron.mjs", ...extra], { cwd: desktopDir, env: { ...process.env, CODEWORK_WEB_URL: WEB_URL }, }); diff --git a/apps/desktop/scripts/start-electron.mjs b/apps/desktop/scripts/start-electron.mjs index 65928a80..21182c3f 100644 --- a/apps/desktop/scripts/start-electron.mjs +++ b/apps/desktop/scripts/start-electron.mjs @@ -40,7 +40,8 @@ const electronPath = process.platform === "darwin" ? brandedElectron() : electro const env = { ...process.env }; delete env.ELECTRON_RUN_AS_NODE; -const child = spawn(electronPath, ["."], { +// Extra arguments reach Electron, `--remote-debugging-port=9222` say. +const child = spawn(electronPath, [".", ...process.argv.slice(2)], { stdio: "inherit", cwd: desktopDir, env, diff --git a/apps/web/src/kernel/servers.ts b/apps/web/src/kernel/servers.ts index ada99e74..48be6d91 100644 --- a/apps/web/src/kernel/servers.ts +++ b/apps/web/src/kernel/servers.ts @@ -17,6 +17,8 @@ export interface Problem { /** The default server's problem from its status; undefined while the app can work with it. */ export function problemOf(status: ServerStatus): Problem | undefined { const { cli, server } = status; + // An already running, compatible server is usable even without a local CLI. + if (server._tag === "Running") return undefined; if (cli === null) return { title: "CodeWork Isn't Installed", @@ -43,8 +45,6 @@ export function problemOf(status: ServerStatus): Problem | undefined { title: "Incompatible Server Version", line: `${status.name} runs codework v${server.version}, which this app can't read.`, }; - case "Running": - return undefined; } } diff --git a/apps/web/src/widgets/session/address.ts b/apps/web/src/widgets/session/address.ts index 6e620045..fcbf6e68 100644 --- a/apps/web/src/widgets/session/address.ts +++ b/apps/web/src/widgets/session/address.ts @@ -1,6 +1,13 @@ +import type { ThreadRef } from "./schema"; + const prefix = "codework://session/"; +/** A session's address: its main thread's. Another thread's is `/`. */ export const sessionAddress = (id: string) => `${prefix}${id}`; -export const sessionId = (address: string | undefined) => - address?.startsWith(prefix) ? address.slice(prefix.length) : undefined; +export const threadRef = (address: string | undefined): ThreadRef | undefined => { + if (!address?.startsWith(prefix)) return undefined; + const [sessionId, threadId, ...rest] = address.slice(prefix.length).split("/"); + if (sessionId === undefined || sessionId === "" || threadId === "" || rest.length > 0) return undefined; + return threadId === undefined ? { sessionId } : { sessionId, threadId }; +}; diff --git a/apps/web/src/widgets/session/backend.ts b/apps/web/src/widgets/session/backend.ts index 222bdc14..87038ba0 100644 --- a/apps/web/src/widgets/session/backend.ts +++ b/apps/web/src/widgets/session/backend.ts @@ -25,12 +25,14 @@ import { type Reply, type Snapshot, snapshotKey, + threadKey, topics, + type ThreadRef, type Update, type Window, } from "./schema.ts"; -// A session shows as its main thread until threads get a view of their own. +// Metadata follows the addressed thread; placement and project belong to its session. const toInfo = (info: ThreadInfo): Info => ({ title: info.title ?? UNTITLED, updated: info.updatedAt, @@ -72,18 +74,21 @@ const changes = ( ]; }; +/** Every thread-scoped event names its thread, and the session it belongs to. */ +const OfThread = { sessionId: Schema.String, threadId: Schema.String }; + /** A live text or thinking delta, as `event.subscribe` carries it. */ const Delta = Schema.Struct({ - sessionId: Schema.String, + ...OfThread, messageId: Schema.String, partIndex: Schema.Int, delta: Schema.String, timestamp: Schema.Number, }); const decodeDelta = Schema.decodeUnknownOption(Delta); -const decodeOfSession = Schema.decodeUnknownOption(Schema.Struct({ sessionId: Schema.String })); +const decodeOfThread = Schema.decodeUnknownOption(Schema.Struct(OfThread)); const decodeFailed = Schema.decodeUnknownOption( - Schema.Struct({ sessionId: Schema.String, error: Schema.Struct({ type: Schema.String, message: Schema.String }) }), + Schema.Struct({ ...OfThread, error: Schema.Struct({ type: Schema.String, message: Schema.String }) }), ); /** Appends a delta to the part it belongs to; a part not seen yet starts with it. */ @@ -96,10 +101,19 @@ const fold = (current: Part | undefined, kind: "text" | "thinking", delta: strin ? { ...current, thinking: current.thinking + delta } : { type: "thinking", thinking: delta }; +/** Overlays live text at its original index, preserving tools and other stored parts. */ +const mergeParts = (stored: ReadonlyArray, streamed: ReadonlyMap): Part[] => { + const parts = new Map(stored.map((part, index) => [index, part])); + for (const [index, part] of streamed) parts.set(index, part); + return [...parts.entries()].sort(([a], [b]) => a - b).map(([, part]) => part); +}; + const describe = (error: { readonly _tag: string }) => { switch (error._tag) { case "SessionNotFoundError": return "This session no longer exists."; + case "ThreadNotFoundError": + return "This thread no longer exists."; case "PromptConflictError": return "That message was already sent."; case "Location.DirectoryNotFoundError": @@ -122,10 +136,11 @@ const encodeSnapshot = Schema.encodeEffect(Json.Snapshot); const decodeSnapshot = Schema.decodeUnknownEffect(Json.Snapshot); /** - * Keeps a copy of each followed session in kv and publishes what changes on the session's topic. - * The copy is CodeWork's own conversation (`session.history`), refetched whenever the session's - * durable log moves, so this backend never folds the stored events itself. What CodeWork only says - * live, a reply's text as it streams and whether the agent works, it relays as it happens. + * Keeps a copy of each followed thread in kv and publishes what changes on that thread's topic. + * The copy is that thread's conversation (`thread.history`), refetched whenever its durable log + * moves, so this backend never folds the stored events itself. What CodeWork only says live, a + * reply's text as it streams and whether the agent works, it relays as it happens, for that thread + * alone. A follow that names no thread is the session's main thread. */ export const session = defineBackend({ package: "codework", @@ -136,8 +151,8 @@ export const session = defineBackend({ const scope = yield* Effect.scope; // A snapshot that no longer decodes was stored by an older build: it is seeded again. - const load = (id: string) => - kv.get(snapshotKey(id)).pipe( + const load = (key: string) => + kv.get(snapshotKey(key)).pipe( Effect.flatMap( Option.match({ onNone: () => Effect.succeed(undefined), @@ -154,6 +169,7 @@ export const session = defineBackend({ string, { readonly sessionId: string; + readonly threadId: string; message: HistoryEntry; // Keyed by the part index deltas carry, which can skip parts that stream no text. readonly parts: Map; @@ -161,32 +177,46 @@ export const session = defineBackend({ >(); // Drafts changed since they were last published. const dirty = new Set(); - // Each session's latest snapshot, so a delta can start from the draft CodeWork stored. + // Each followed thread's latest snapshot, by its {@link threadKey}. const latest = new Map(); + // The concrete thread id `thread.info` named for each follow. Live events match this, not the address. + const open = new Map(); + + const keysFor = (event: { readonly sessionId: string; readonly threadId: string }) => + [...open.entries()] + .filter(([, followed]) => followed.sessionId === event.sessionId && followed.threadId === event.threadId) + .map(([key]) => key); + + /** The RPC address: the concrete thread once known, else the request (`threadId` absent is the main thread). */ + const addressed = (ref: ThreadRef) => { + const threadId = ref.threadId ?? open.get(threadKey(ref))?.threadId; + return threadId === undefined ? { sessionId: ref.sessionId } : { sessionId: ref.sessionId, threadId }; + }; /** A draft reads as streamed so far; a reply that has ended stops streaming. */ const withStreamed = (entries: ReadonlyArray) => entries.map((entry) => { const streamed = streaming.get(entry.id); - if (streamed === undefined) return entry; + if (streamed === undefined || streamed.threadId !== entry.threadId) return entry; if (entry.state !== "draft") { streaming.delete(entry.id); dirty.delete(entry.id); return entry; } - streamed.message = { ...entry, parts: streamed.message.parts }; + streamed.message = { ...entry, parts: mergeParts(entry.parts, streamed.parts) }; return streamed.message; }); /** Refetches the conversation, publishes what changed, then stores the snapshot. */ - const refresh = Effect.fn("Session.refresh")(function* (id: string, cursor: number | undefined) { + const refresh = Effect.fn("Session.refresh")(function* (ref: ThreadRef, cursor: number | undefined) { + const key = threadKey(ref); + const target = addressed(ref); // In this order: a prompt promoted between the queue and history reads is then in both, never in neither. - const { info, queue, history } = yield* Effect.all({ - info: codework("thread.info", { sessionId: id }), - queue: codework("thread.queue", { sessionId: id }), - history: codework("thread.history", { sessionId: id }), - }); - const before = yield* load(id); + const info = yield* codework("thread.info", target); + open.set(key, { sessionId: ref.sessionId, threadId: info.id }); + const queue = yield* codework("thread.queue", target); + const history = yield* codework("thread.history", target); + const before = yield* load(key); const next = toInfo(info); const messages = withStreamed(history.entries); // One that is in both has been promoted: the conversation wins. @@ -196,7 +226,7 @@ export const session = defineBackend({ // Published before the snapshot is stored, so a view never holds a snapshot newer than its cursor. for (const update of changes(before, next, messages, queued)) { const payload = yield* encodeUpdate(update).pipe(Effect.orDie); - seq = (yield* bus.publish({ topic: topics.session(id), payload })).seq ?? seq; + seq = (yield* bus.publish({ topic: topics.thread(key), payload })).seq ?? seq; } // A history entry's seq is its place in the durable log, so the newest one is where to resume. const resume = cursor ?? before?.cursor ?? history.entries.at(-1)?.seq; @@ -207,34 +237,42 @@ export const session = defineBackend({ seq, ...(resume === undefined ? {} : { cursor: resume }), }; - yield* kv.set(snapshotKey(id), yield* encodeSnapshot(snapshot).pipe(Effect.orDie)); - latest.set(id, snapshot); + yield* kv.set(snapshotKey(key), yield* encodeSnapshot(snapshot).pipe(Effect.orDie)); + latest.set(key, snapshot); return snapshot; }); - /** Publishes to the session's live subscribers without storing it. */ - const publishLive = (sessionId: string, update: Update) => + /** Publishes to the thread's live subscribers without storing it. */ + const publishLive = (key: string, update: Update) => encodeUpdate(update).pipe( Effect.orDie, - Effect.flatMap((payload) => bus.publish({ topic: topics.session(sessionId), payload, ephemeral: true })), + Effect.flatMap((payload) => bus.publish({ topic: topics.thread(key), payload, ephemeral: true })), Effect.asVoid, ); + const publishEach = (event: { readonly sessionId: string; readonly threadId: string }, update: Update) => + Effect.forEach(keysFor(event), (key) => publishLive(key, update), { discard: true }); + /** Folds what CodeWork only says live: deltas into their drafts, and whether the agent works. */ const observe = (envelope: EventEnvelope): Effect.Effect => { switch (envelope.type) { case "session.llm.text.delta": case "session.llm.thinking.delta": { const delta = Option.getOrUndefined(decodeDelta(envelope.data)); - if (delta === undefined || !following.has(delta.sessionId)) return Effect.void; + const keys = delta === undefined ? [] : keysFor(delta); + if (delta === undefined || keys.length === 0) return Effect.void; return Effect.sync(() => { const streamed = streaming.get(delta.messageId); + // Until the conversation lists the reply, only its parts are kept: it is not published before then. const draft = streamed?.message ?? - latest.get(delta.sessionId)?.messages.find((message) => message.id === delta.messageId) ?? { + keys + .map((key) => latest.get(key)?.messages.find((message) => message.id === delta.messageId)) + .find((message) => message !== undefined) ?? { id: delta.messageId, - seq: latest.get(delta.sessionId)?.cursor ?? 0, - role: "assistant", - state: "draft", + threadId: delta.threadId, + seq: latest.get(keys[0] ?? "")?.cursor ?? 0, + role: "assistant" as const, + state: "draft" as const, createdAt: delta.timestamp, updatedAt: delta.timestamp, parts: [], @@ -242,10 +280,11 @@ export const session = defineBackend({ const kind = envelope.type === "session.llm.text.delta" ? "text" : "thinking"; const parts = streamed?.parts ?? new Map(); parts.set(delta.partIndex, fold(parts.get(delta.partIndex), kind, delta.delta)); - const ordered = [...parts.entries()].sort(([a], [b]) => a - b).map(([, part]) => part); + const ordered = mergeParts(draft.parts, parts); streaming.set(delta.messageId, { sessionId: delta.sessionId, - message: { ...draft, parts: ordered }, + threadId: delta.threadId, + message: { ...draft, threadId: delta.threadId, parts: ordered }, parts, }); dirty.add(delta.messageId); @@ -255,10 +294,10 @@ export const session = defineBackend({ // in the session's log records it: this is the only place the reason shows. case "session.execution.failed": { const failed = Option.getOrUndefined(decodeFailed(envelope.data)); - if (failed === undefined || !following.has(failed.sessionId)) return Effect.void; - return publishLive(failed.sessionId, { _tag: "Running", running: false }).pipe( + if (failed === undefined || keysFor(failed).length === 0) return Effect.void; + return publishEach(failed, { _tag: "Running", running: false }).pipe( Effect.andThen( - publishLive(failed.sessionId, { + publishEach(failed, { _tag: "Failed", kind: failed.error.type, message: failed.error.message, @@ -269,9 +308,9 @@ export const session = defineBackend({ case "session.execution.started": case "session.execution.succeeded": case "session.execution.interrupted": { - const sessionId = Option.getOrUndefined(decodeOfSession(envelope.data))?.sessionId; - if (sessionId === undefined || !following.has(sessionId)) return Effect.void; - return publishLive(sessionId, { + const event = Option.getOrUndefined(decodeOfThread(envelope.data)); + if (event === undefined || keysFor(event).length === 0) return Effect.void; + return publishEach(event, { _tag: "Running", running: envelope.type === "session.execution.started", }); @@ -281,17 +320,31 @@ export const session = defineBackend({ } }; - // Drafts go out at most every 50ms, however fast the deltas arrive. + // Drafts go out at most every 50ms, however fast the deltas arrive. A draft waits until the + // conversation lists it, so a view never has it ahead of the prompt it answers. const flush = Effect.suspend(() => { - const ids = [...dirty]; - dirty.clear(); + const ids = [...dirty].filter((id) => { + const streamed = streaming.get(id); + return ( + streamed !== undefined && + keysFor(streamed).some((key) => latest.get(key)?.messages.some((message) => message.id === id)) + ); + }); return Effect.forEach( ids, (id) => { const streamed = streaming.get(id); - return streamed === undefined - ? Effect.void - : publishLive(streamed.sessionId, { _tag: "Message", message: streamed.message }); + if (streamed === undefined) return Effect.void; + const keys = keysFor(streamed).filter((key) => + latest.get(key)?.messages.some((message) => message.id === id), + ); + const waiting = keysFor(streamed).some( + (key) => !latest.get(key)?.messages.some((message) => message.id === id), + ); + if (!waiting) dirty.delete(id); + return Effect.forEach(keys, (key) => publishLive(key, { _tag: "Message", message: streamed.message }), { + discard: true, + }); }, { discard: true }, ); @@ -299,31 +352,38 @@ export const session = defineBackend({ const following = new Map>(); - /** Seeds, answers `ready`, then refreshes on every move of the session's durable log. */ - const sync = (id: string, ready: Deferred.Deferred) => - Effect.gen(function* () { - const seeded = yield* refresh(id, undefined); + /** Seeds, answers `ready`, then refreshes on every move of this thread's durable log. */ + const sync = (ref: ThreadRef, ready: Deferred.Deferred) => { + const key = threadKey(ref); + const missed = (error: { readonly _tag: string }) => + Deferred.succeed(ready, { _tag: "Failed" as const, message: describe(error) }).pipe( + Effect.andThen(Effect.sync(() => following.delete(key))), + ); + return Effect.gen(function* () { + const seeded = yield* refresh(ref, undefined); + const threadId = open.get(key)?.threadId; yield* Deferred.succeed(ready, { _tag: "Done" }); yield* codework("session.log", { - sessionId: id, + sessionId: ref.sessionId, + ...(threadId === undefined ? {} : { threadId }), follow: true, ...(seeded.cursor === undefined ? {} : { after: seeded.cursor }), }).pipe( Stream.map((item) => ("id" in item ? item.durable?.seq : item.seq)), // A turn commits several events at once; one refetch covers them all. Stream.debounce("50 millis"), - Stream.runForEach((seq) => refresh(id, seq)), + Stream.runForEach((seq) => refresh(ref, seq)), ); }).pipe( - Effect.catchTag("SessionNotFoundError", (error) => - Deferred.succeed(ready, { _tag: "Failed", message: describe(error) }).pipe( - Effect.andThen(Effect.sync(() => following.delete(id))), - ), - ), + Effect.catchTags({ + SessionNotFoundError: missed, + ThreadNotFoundError: missed, + }), // The connection dropped: start over from the stored cursor once it is back. Effect.retry(Schedule.spaced("1 second")), - Effect.repeat({ while: () => following.has(id), schedule: Schedule.spaced("1 second") }), + Effect.repeat({ while: () => following.has(key), schedule: Schedule.spaced("1 second") }), ); + }; // Both loops outlive anything that stops them, a defect included, and say what it was: one that // stopped quietly would freeze every view's live updates while sends still went through. @@ -341,22 +401,29 @@ export const session = defineBackend({ ); /** - * Stops following a session once no view has watched its topic for a while: a view watches + * Stops following a thread once no view has watched its topic for a while: a view watches * from just after it follows until its frame closes, and a closed window stops watching too. * The snapshot stays in kv, so the next follow refreshes it rather than seeding again. */ - const release = (sessionId: string, syncing: Fiber.Fiber) => - bus.watchers(topics.session(sessionId)).pipe( + const release = (key: string, syncing: Fiber.Fiber) => + bus.watchers(topics.thread(key)).pipe( // Long enough to cover a view between its follow and its subscription, or a quick reopen. Stream.debounce("30 seconds"), Stream.filter((count) => count === 0), Stream.runHead, Effect.andThen( Effect.sync(() => { - following.delete(sessionId); - latest.delete(sessionId); + const followed = open.get(key); + following.delete(key); + latest.delete(key); + open.delete(key); + if (followed === undefined) return; + const still = [...open.values()].some( + (item) => item.sessionId === followed.sessionId && item.threadId === followed.threadId, + ); + if (still) return; for (const [id, streamed] of streaming) { - if (streamed.sessionId !== sessionId) continue; + if (streamed.sessionId !== followed.sessionId || streamed.threadId !== followed.threadId) continue; streaming.delete(id); dirty.delete(id); } @@ -365,14 +432,15 @@ export const session = defineBackend({ Effect.andThen(Fiber.interrupt(syncing)), ); - yield* handle(topics.follow, Follow, ({ sessionId }) => + yield* handle(topics.follow, Follow, (ref) => Effect.gen(function* () { - let ready = following.get(sessionId); + const key = threadKey(ref); + let ready = following.get(key); if (ready === undefined) { ready = yield* Deferred.make(); - following.set(sessionId, ready); - const syncing = yield* Effect.forkIn(sync(sessionId, ready), scope); - yield* Effect.forkIn(release(sessionId, syncing), scope); + following.set(key, ready); + const syncing = yield* Effect.forkIn(sync(ref, ready), scope); + yield* Effect.forkIn(release(key, syncing), scope); } return yield* encodeReply(yield* Deferred.await(ready)).pipe(Effect.orDie); }), @@ -382,9 +450,11 @@ export const session = defineBackend({ yield* handle( topics.page, Page, - ({ sessionId, before, limit }) => + (ref) => Effect.gen(function* () { - const snapshot = latest.get(sessionId) ?? (yield* load(sessionId)); + const { before, limit } = ref; + const key = threadKey(ref); + const snapshot = latest.get(key) ?? (yield* load(key)); if (snapshot === undefined) { return yield* encodeWindow({ _tag: "Failed", message: "Follow the session before paging it." }).pipe( Effect.orDie, @@ -411,9 +481,9 @@ export const session = defineBackend({ { ephemeral: true }, ); - const prompt = ({ sessionId, messageId, text, delivery }: Prompt) => + const prompt = ({ messageId, text, delivery, ...ref }: Prompt) => codework("thread.prompt", { - sessionId, + ...addressed(ref), text, id: messageId, ...(delivery === undefined ? {} : { delivery }), @@ -448,10 +518,10 @@ export const session = defineBackend({ ), ); - // The session's own log moves with the change, so the refresh that follows publishes the new info. - yield* handle(topics.configure, Configure, ({ sessionId, model, thinkingLevel }) => + // The thread's log moves with the change, so the refresh that follows publishes the new info. + yield* handle(topics.configure, Configure, ({ model, thinkingLevel, ...ref }) => codework("thread.configure", { - sessionId, + ...addressed(ref), runtime: { ...(model === undefined ? {} : { model }), ...(thinkingLevel === undefined ? {} : { thinkingLevel }), @@ -465,17 +535,17 @@ export const session = defineBackend({ // A cancel that lost to promotion answers `Sent`: the prompt is in the conversation, and the // refresh that follows the log moving shows it there. - yield* handle(topics.cancel, Cancel, ({ sessionId, messageId }) => - codework("thread.cancel", { sessionId, messageId }).pipe( + yield* handle(topics.cancel, Cancel, ({ messageId, ...ref }) => + codework("thread.cancel", { ...addressed(ref), messageId }).pipe( Effect.map(({ cancelled }): Cancelled => (cancelled ? { _tag: "Cancelled" } : { _tag: "Sent" })), Effect.catch((error) => Effect.succeed({ _tag: "Failed", message: describe(error) })), Effect.flatMap((reply) => encodeCancelled(reply).pipe(Effect.orDie)), ), ); - yield* handle(topics.change, Change, ({ sessionId, messageId, delivery, text }) => + yield* handle(topics.change, Change, ({ messageId, delivery, text, ...ref }) => codework("thread.update", { - sessionId, + ...addressed(ref), messageId, ...(delivery === undefined ? {} : { delivery }), ...(text === undefined ? {} : { text }), @@ -488,8 +558,8 @@ export const session = defineBackend({ ), ); - yield* handle(topics.interrupt, Interrupt, ({ sessionId }) => - codework("session.interrupt", { sessionId }).pipe( + yield* handle(topics.interrupt, Interrupt, (ref) => + codework("thread.interrupt", addressed(ref)).pipe( Effect.as({ _tag: "Done" }), Effect.catch((error) => Effect.succeed({ _tag: "Failed", message: describe(error) })), Effect.flatMap((reply) => encodeReply(reply).pipe(Effect.orDie)), diff --git a/apps/web/src/widgets/session/composer.tsx b/apps/web/src/widgets/session/composer.tsx index 88afdd27..5f0d6c03 100644 --- a/apps/web/src/widgets/session/composer.tsx +++ b/apps/web/src/widgets/session/composer.tsx @@ -6,7 +6,7 @@ import { useEffect, useRef, useState } from "react"; import { PromptComposer, ComposerHeader, ComposerSubmit, ComposerButton, type Submit } from "@/components/composer"; import { ModelPicker, type ModelRef, ThinkingPicker } from "@/components/model"; import type { Delivery, ThinkingLevel } from "@codeworksh/widget/codework"; -import { type Info, Json, topics } from "./schema"; +import { type Info, Json, type ThreadRef, topics } from "./schema"; const decodeReply = Schema.decodeUnknownOption(Json.Reply); const encodePrompt = Schema.encodeSync(Json.Prompt); @@ -25,18 +25,18 @@ const unreachable = "The CodeWork server is not reachable."; * an id the view chooses for the user message it becomes; the message itself arrives as an update. * The text stays until the backend accepts it, and the unsent draft survives a remount. * - * The model and reasoning pickers show the session's own choice, which CodeWork keeps with the - * session; a pick shows at once and is sent as a configure request, applying from the next exchange. + * The model and reasoning pickers show the thread's own choice, which CodeWork keeps with the + * thread; a pick shows at once and is sent as a configure request, applying from the next exchange. */ export function SessionComposer({ - sessionId, + thread, instanceId, running, info, onError, restored, }: { - readonly sessionId: string; + readonly thread: ThreadRef; readonly instanceId: string; readonly running: boolean; readonly info: Info; @@ -164,7 +164,7 @@ export function SessionComposer({ const sent = await ask( topics.prompt, encodePrompt({ - sessionId, + ...thread, messageId: crypto.randomUUID(), text: prompt, ...(delivery === undefined ? {} : { delivery }), @@ -176,7 +176,7 @@ export function SessionComposer({ const configure = (change: { model?: ModelRef; thinkingLevel?: ThinkingLevel }) => { setPicked((current) => ({ ...current, ...change })); - void ask(topics.configure, encodeConfigure({ sessionId, ...change })); + void ask(topics.configure, encodeConfigure({ ...thread, ...change })); }; const empty = text.trim() === ""; @@ -230,7 +230,7 @@ export function SessionComposer({ actions={ <> {running && ( - void ask(topics.interrupt, { sessionId })}> + void ask(topics.interrupt, { ...thread })}> )} diff --git a/apps/web/src/widgets/session/index.ts b/apps/web/src/widgets/session/index.ts index 14192762..2d3b643e 100644 --- a/apps/web/src/widgets/session/index.ts +++ b/apps/web/src/widgets/session/index.ts @@ -4,7 +4,7 @@ import { MessageSquare } from "lucide-react"; import { Session } from "./view"; -/** One session's conversation, opened by its `codework://session/` address. */ +/** One thread's conversation: `codework://session/` for a session's main thread, `…//` for another. */ export const session = defineWidget({ kind: "codework:session", title: "Session", @@ -13,7 +13,7 @@ export const session = defineWidget({ minHeight: 200, cardinality: "many", priority: "builtin", - opens: ["codework://session/*"], + opens: ["codework://session/*", "codework://session/*/*"], ownsTab: true, replaceable: true, props: Schema.Struct({}), diff --git a/apps/web/src/widgets/session/queue.tsx b/apps/web/src/widgets/session/queue.tsx index b17d1ea6..5af7be54 100644 --- a/apps/web/src/widgets/session/queue.tsx +++ b/apps/web/src/widgets/session/queue.tsx @@ -4,7 +4,7 @@ import { Option, Schema } from "effect"; import { CornerDownRight, ListEnd, type LucideIcon, Pencil, SendHorizontal, Trash2, Undo2 } from "lucide-react"; import { useRef, useState } from "react"; -import { Json, topics } from "./schema"; +import { Json, type ThreadRef, topics } from "./schema"; const decodeReply = Schema.decodeUnknownOption(Json.Reply); const decodeCancelled = Schema.decodeUnknownOption(Json.Cancelled); @@ -21,13 +21,13 @@ const unreachable = "The CodeWork server is not reachable."; * the queue next updates. */ export function Queue({ - sessionId, + thread, queued, running, onError, onRestore, }: { - readonly sessionId: string; + readonly thread: ThreadRef; readonly queued: readonly QueuedPrompt[]; readonly running: boolean; readonly onError: (message: string | undefined) => void; @@ -70,7 +70,7 @@ export function Queue({ act(prompt.id, async () => { const answer = await bus.request({ topic: topics.change, - payload: { sessionId, messageId: prompt.id, ...patch }, + payload: { ...thread, messageId: prompt.id, ...patch }, }); const reply = decodeReply(answer.payload); if (Option.isSome(reply) && reply.value._tag === "Failed") onError(reply.value.message); @@ -79,7 +79,7 @@ export function Queue({ // Undo restores only what it took back: a prompt the agent already took in stays in the conversation. const cancel = (prompt: QueuedPrompt, restore: boolean) => act(prompt.id, async () => { - const answer = await bus.request({ topic: topics.cancel, payload: { sessionId, messageId: prompt.id } }); + const answer = await bus.request({ topic: topics.cancel, payload: { ...thread, messageId: prompt.id } }); const reply = Option.getOrUndefined(decodeCancelled(answer.payload)); if (reply?._tag === "Failed") onError(reply.message); else if (reply?._tag === "Cancelled" && restore) onRestore(prompt.text); diff --git a/apps/web/src/widgets/session/schema.ts b/apps/web/src/widgets/session/schema.ts index eb242af1..e4241d75 100644 --- a/apps/web/src/widgets/session/schema.ts +++ b/apps/web/src/widgets/session/schema.ts @@ -6,32 +6,43 @@ import { Schema } from "effect"; * halves import this file, so it stays free of React and the DOM. */ +/** A thread of a session: `threadId`, or the session's main thread when absent. */ +export const ThreadRef = Schema.Struct({ sessionId: Schema.String, threadId: Schema.optionalKey(Schema.String) }); +export type ThreadRef = typeof ThreadRef.Type; + +/** + * What names a thread in addresses, topics and kv: its session's id for the main thread, else + * `/`. The main thread is never named by its own id, so it has one key. + */ +export const threadKey = ({ sessionId, threadId }: ThreadRef) => + threadId === undefined ? sessionId : `${sessionId}/${threadId}`; + export const topics = { - /** Requests: start following a session; answered once its snapshot is stored. */ + /** Requests: start following a thread; answered once its snapshot is stored. */ follow: "codework/session.follow", /** Requests: create a session and send its first prompt; answered with its id. */ create: "codework/session.create", prompt: "codework/session.prompt", - /** Requests: choose a session's model or thinking level; they apply from its next turn. */ + /** Requests: choose a thread's model or thinking level; they apply from its next turn. */ configure: "codework/session.configure", interrupt: "codework/session.interrupt", /** Requests: withdraw a queued prompt before the agent takes it in; answered with `Cancelled`. */ cancel: "codework/session.cancel", /** Requests: move a queued prompt to the other lane, or rewrite it, in place. */ change: "codework/session.change", - /** Requests: a window of a followed session's conversation, newest first back from `before`. */ + /** Requests: a window of a followed thread's conversation, newest first back from `before`. */ page: "codework/session.page", - /** Updates to one session's conversation. */ - session: (id: string) => `codework/session/${id}`, + /** Updates to one thread's conversation, by its {@link threadKey}. */ + thread: (key: string) => `codework/session/${key}`, }; -/** The kv key of a session's snapshot. */ -export const snapshotKey = (id: string) => `session/${id}`; +/** The kv key of a thread's snapshot, by its {@link threadKey}. */ +export const snapshotKey = (key: string) => `session/${key}`; -export const Follow = Schema.Struct({ sessionId: Schema.String }); +export const Follow = ThreadRef; export const Prompt = Schema.Struct({ - sessionId: Schema.String, + ...ThreadRef.fields, /** Chosen by the view: the id of the user message this prompt becomes. */ messageId: Schema.String, text: Schema.String, @@ -65,9 +76,9 @@ export const Created = Schema.Union([ ]); export type Created = typeof Created.Type; -export const Interrupt = Schema.Struct({ sessionId: Schema.String }); +export const Interrupt = ThreadRef; -export const Cancel = Schema.Struct({ sessionId: Schema.String, messageId: Schema.String }); +export const Cancel = Schema.Struct({ ...ThreadRef.fields, messageId: Schema.String }); /** The answer to a cancel: withdrawn, already in the conversation, or why neither is known. */ export const Cancelled = Schema.Union([ @@ -79,22 +90,22 @@ export type Cancelled = typeof Cancelled.Type; /** A queued prompt moved to `delivery`, or given new `text`; an absent key is left as it is. */ export const Change = Schema.Struct({ - sessionId: Schema.String, + ...ThreadRef.fields, messageId: Schema.String, delivery: Schema.optionalKey(Delivery), text: Schema.optionalKey(Schema.String), }); -/** A model or thinking level chosen for a session; an absent key is left as it is. */ +/** A model or thinking level chosen for a thread; an absent key is left as it is. */ export const Configure = Schema.Struct({ - sessionId: Schema.String, + ...ThreadRef.fields, model: Schema.optionalKey(Schema.Struct({ provider: Schema.String, id: Schema.String })), thinkingLevel: Schema.optionalKey(ThinkingLevel), }); export type Configure = typeof Configure.Type; export const Page = Schema.Struct({ - sessionId: Schema.String, + ...ThreadRef.fields, /** The oldest message the view holds; omitted asks for the newest messages. */ before: Schema.optionalKey(Schema.String), limit: Schema.Int, diff --git a/apps/web/src/widgets/session/view.tsx b/apps/web/src/widgets/session/view.tsx index a339f2fb..23cfedc0 100644 --- a/apps/web/src/widgets/session/view.tsx +++ b/apps/web/src/widgets/session/view.tsx @@ -8,13 +8,13 @@ import { memo, type ReactNode, useCallback, useEffect, useMemo, useRef, useState import { ComposerNotice, type Notice } from "@/components/banner"; import { Monogram } from "@/components/monogram"; import { useModelsNotice } from "@/components/model"; -import { sessionId } from "./address"; +import { threadRef } from "./address"; import { SessionComposer } from "./composer"; import { Markdown } from "./markdown"; import { Message } from "./message"; import { Queue } from "./queue"; import { useListedSession } from "./projects"; -import { type Info, Json, topics, type Update } from "./schema"; +import { type Info, Json, type ThreadRef, threadKey, topics, type Update } from "./schema"; const decodeReply = Schema.decodeUnknownOption(Json.Reply); const decodeWindow = Schema.decodeUnknownOption(Json.Window); @@ -27,9 +27,9 @@ const PAGE = 60; const contentWidth = "mx-auto w-full max-w-[62rem]"; export function Session({ address, instanceId }: WidgetProps) { - const id = sessionId(address); - if (id === undefined) return

Not a session: {address}

; - return ; + const thread = useMemo(() => threadRef(address), [address]); + if (thread === undefined) return

Not a session: {address}

; + return ; } type State = @@ -106,11 +106,11 @@ const apply = (state: State, update: Update): State => { }; /** - * Asks the session backend to follow the session, loads its newest page, then applies every update + * Asks the session backend to follow the thread, loads its newest page, then applies every update * published after that page. Older pages load on demand. A dropped connection resumes where it * left off. */ -function useConversation(id: string) { +function useConversation(thread: ThreadRef) { const bus = useBus(); const [state, setState] = useState({ status: "loading" }); const paging = useRef(false); @@ -121,13 +121,13 @@ function useConversation(id: string) { ( await bus.request({ topic: topics.page, - payload: { sessionId: id, limit: PAGE, ...(before === undefined ? {} : { before }) }, + payload: { ...thread, limit: PAGE, ...(before === undefined ? {} : { before }) }, }) ).payload, ); return Option.getOrUndefined(reply); }, - [bus, id], + [bus, thread], ); useEffect(() => { @@ -136,10 +136,10 @@ function useConversation(id: string) { if (active) setState({ status: "failed", message }); }; void (async () => { - const reply = decodeReply((await bus.request({ topic: topics.follow, payload: { sessionId: id } })).payload); + const reply = decodeReply((await bus.request({ topic: topics.follow, payload: thread })).payload); if (Option.isSome(reply) && reply.value._tag === "Failed") return fail(reply.value.message); const window = await page(undefined); - if (window === undefined) return fail(`Could not load session ${id}.`); + if (window === undefined) return fail(`Could not load session ${threadKey(thread)}.`); if (window._tag === "Failed") return fail(window.message); const { info, messages, more, queued, seq } = window; if (active) setState({ status: "ready", info, messages, more, queued, after: seq, running: undefined }); @@ -147,10 +147,10 @@ function useConversation(id: string) { return () => { active = false; }; - }, [bus, id, page]); + }, [bus, thread, page]); const after = state.status === "ready" ? state.after : undefined; - useEvents(after === undefined ? undefined : { topics: [topics.session(id)], after }, (item) => { + useEvents(after === undefined ? undefined : { topics: [topics.thread(threadKey(thread))], after }, (item) => { if ("_tag" in item) return; const update = decodeUpdate(item.payload); if (Option.isSome(update)) setState((current) => apply(current, update.value)); @@ -178,11 +178,11 @@ function useConversation(id: string) { return { state, loadOlder }; } -function Conversation({ id, instanceId }: { readonly id: string; readonly instanceId: string }) { +function Conversation({ thread, instanceId }: { readonly thread: ThreadRef; readonly instanceId: string }) { const { setTitle, setIcon, setTab } = useFrame(); - const { state, loadOlder } = useConversation(id); + const { state, loadOlder } = useConversation(thread); // Named from the sessions list at once, so the frame never shows its default title while loading. - const listed = useListedSession(id); + const listed = useListedSession(thread.sessionId); const title = state.status === "ready" ? state.info.title : listed?.title; const project = state.status === "ready" ? state.info.project : listed?.project; const projectId = project?.id; @@ -253,7 +253,7 @@ function Conversation({ id, instanceId }: { readonly id: string; readonly instan {/* Idle too: prompts left waiting by a stop or a failure run with the next message, so they stay in view. */} {state.queued.length > 0 && ( )} + RpcClient.layerProtocolSocket().pipe( + Layer.provide(Socket.layerWebSocket(url)), + Layer.provide(Socket.layerWebSocketConstructorGlobal), + Layer.provide(RpcSerialization.layerNdjson), + ); + +it("desktop keeps fork history, configuration and prompts separate from main", async () => { + const home = mkdtempSync(join(tmpdir(), "codework-desktop-threads-")); + try { + const artifact = await Effect.gen(function* () { + const listener = yield* HttpServer.HttpServer; + if (listener.address._tag === "UnixPathAddress") return yield* Effect.die("Expected TCP listener"); + const url = `ws://127.0.0.1:${listener.address.port}/rpc/v1`; + const rpcContext = yield* Layer.build(Client.layer(url)); + const rpc = yield* Client.make.pipe(Effect.provideContext(rpcContext)); + const mirrorContext = yield* Layer.build(protocol(url)); + const mirror = yield* RpcClient.make(Mirror.Api).pipe(Effect.provideContext(mirrorContext)); + const created = yield* mirror["session.create"]({ directory: home }); + const sessionId = Session.SessionSchema.ID.make(created.session.id); + yield* mirror["thread.prompt"]({ sessionId, text: "Main prompt" }); + yield* rpc["thread.wait"]({ sessionId }); + const history = yield* rpc["thread.history"]({ sessionId }); + const fork = yield* rpc["thread.fork"]({ sessionId, entryId: history.entries.at(-1)!.id }); + const ref = { sessionId, threadId: fork.thread.id }; + const child = yield* Effect.acquireRelease( + Effect.sync(() => + spawn(process.execPath, [fileURLToPath(new URL("../../../apps/server/src/index.ts", import.meta.url))], { + env: { ...process.env, CODEWORK_HOME_DIR: home, CODEWORK_DATABASE: join(home, "app.db") }, + stdio: ["ignore", "pipe", "inherit"], + }), + ), + (child) => + Effect.promise( + () => + new Promise((resolve) => { + if (child.exitCode !== null || child.signalCode !== null) return resolve(); + child.once("exit", () => resolve()); + child.kill("SIGKILL"); + }), + ), + ); + const port = yield* Effect.tryPromise( + () => + new Promise((resolve, reject) => { + child.once("exit", (code) => reject(new Error(`App server exited: ${code}`))); + createInterface({ input: child.stdout! }).on("line", (line) => { + if (line.startsWith('{"type":"ready"')) resolve((JSON.parse(line) as { port: number }).port); + }); + }), + ); + const appContext = yield* Layer.build(protocol(`ws://127.0.0.1:${port}/rpc`)); + const app = yield* RpcClient.make(Desktop.Api).pipe(Effect.provideContext(appContext)); + const ask = (topic: string, payload: Schema.Json) => app["event.request"]({ topic, payload, source: "test" }); + for (const target of [{ sessionId }, ref]) + expect((yield* ask(topics.follow, target)).payload).toEqual({ _tag: "Done" }); + expect((yield* ask(topics.configure, { ...ref, thinkingLevel: "high" })).payload).toEqual({ _tag: "Done" }); + expect((yield* mirror["thread.info"](ref)).thinkingLevel).toBe("high"); + expect((yield* mirror["thread.info"]({ sessionId })).thinkingLevel).toBeUndefined(); + expect((yield* ask(topics.prompt, { ...ref, messageId: "fork-prompt", text: "Fork prompt" })).payload).toEqual( + { _tag: "Done" }, + ); + yield* rpc["thread.wait"](ref); + yield* app["event.subscribe"]({ topics: [topics.thread(threadKey(ref))], after: 0 }).pipe( + Stream.filter( + (item) => + "payload" in item && + Schema.is(Json.Update)(item.payload) && + item.payload._tag === "Message" && + item.payload.message.state === "committed" && + item.payload.message.parts.some((part) => part.type === "text" && part.text === "response 2"), + ), + Stream.runHead, + ); + const page = (target: ThreadRef) => + ask(topics.page, { ...target, limit: 60 }).pipe( + Effect.flatMap((reply) => Schema.decodeUnknownEffect(Json.Window)(reply.payload)), + ); + const main = yield* page({ sessionId }); + const branch = yield* page(ref); + if (main._tag !== "Window" || branch._tag !== "Window") return yield* Effect.die("Missing page"); + expect(main.messages).toHaveLength(2); + expect(branch.messages).toHaveLength(4); + expect(branch.messages.slice(0, 2).every((entry) => entry.threadId === created.id)).toBe(true); + expect(branch.messages.slice(2).every((entry) => entry.threadId === fork.thread.id)).toBe(true); + const missing = yield* ask(topics.follow, { sessionId, threadId: "thr_missing" }); + expect(missing.payload).toEqual({ _tag: "Failed", message: "This thread no longer exists." }); + return { + main: main.messages.map(({ role, state, parts }) => ({ role, state, parts })), + fork: branch.messages.map(({ role, state, parts }) => ({ role, state, parts })), + missing: missing.payload, + }; + }).pipe( + Effect.scoped, + Effect.provide( + Server.layer({ + host: "127.0.0.1", + port: 0, + harness: { home, hostCwd: home, plugins: [], llm: immediateOpen() }, + }), + ), + Effect.timeout("30 seconds"), + Effect.runPromise, + ); + await expect(`${JSON.stringify(artifact, null, "\t")}\n`).toMatchFileSnapshot( + "./__artifacts__/desktop.threads.json", + ); + } finally { + rmSync(home, { recursive: true, force: true }); + } +}, 40_000); From a87c89cef172a0383cdc1647b081502bdedd0098 Mon Sep 17 00:00:00 2001 From: prem315 Date: Sun, 1 Nov 2026 13:43:00 +0530 Subject: [PATCH 2/5] refactor(desktop): keep only light and dark themes --- apps/web/index.html | 5 +- apps/web/src/settings/themes.tsx | 2 +- apps/web/src/theme.ts | 31 +- apps/web/src/themes.css | 440 +-------------------- apps/web/src/widgets/session/highlight.tsx | 29 +- 5 files changed, 29 insertions(+), 478 deletions(-) diff --git a/apps/web/index.html b/apps/web/index.html index f37396af..44fc6686 100644 --- a/apps/web/index.html +++ b/apps/web/index.html @@ -1,5 +1,5 @@ - + @@ -7,7 +7,8 @@ diff --git a/apps/web/src/settings/themes.tsx b/apps/web/src/settings/themes.tsx index d2f3c91f..e56de930 100644 --- a/apps/web/src/settings/themes.tsx +++ b/apps/web/src/settings/themes.tsx @@ -20,7 +20,7 @@ export function ThemesSettings() { } >
-
+
{THEMES.map((theme) => { const selected = theme.id === current; return ( diff --git a/apps/web/src/theme.ts b/apps/web/src/theme.ts index 49294df6..56c5a8a0 100644 --- a/apps/web/src/theme.ts +++ b/apps/web/src/theme.ts @@ -1,37 +1,14 @@ import { Atom } from "effect/reactivity"; -/** - * Colour themes: the codework.sh palettes in themes.css, keyed by id. The choice is saved per - * device; index.html applies it before first paint under the same storage key. - */ +/** Light and dark themes, saved per device and applied before first paint by index.html. */ export const THEMES = [ - { id: "catppuccin", name: "Catppuccin" }, - { id: "catppuccin-latte", name: "Catppuccin Latte" }, - { id: "ethereal", name: "Ethereal" }, - { id: "everforest", name: "Everforest" }, - { id: "flexoki-light", name: "Flexoki Light" }, - { id: "gruvbox", name: "Gruvbox" }, - { id: "hackerman", name: "Hackerman" }, - { id: "kanagawa", name: "Kanagawa" }, - { id: "last-horizon", name: "Last Horizon" }, - { id: "lumon", name: "Lumon" }, - { id: "lupine", name: "Lupine" }, - { id: "matte-black", name: "Matte Black" }, - { id: "miasma", name: "Miasma" }, - { id: "nord", name: "Nord" }, - { id: "osaka-jade", name: "Osaka Jade" }, - { id: "retro-82", name: "Retro 82" }, - { id: "ristretto", name: "Ristretto" }, - { id: "rose-pine", name: "Rosé Pine" }, - { id: "solitude", name: "Solitude" }, - { id: "tokyo-night", name: "Tokyo Night" }, - { id: "vantablack", name: "Vantablack" }, - { id: "white", name: "White" }, + { id: "light", name: "Light" }, + { id: "dark", name: "Dark" }, ] as const; export type ThemeId = (typeof THEMES)[number]["id"]; -const DEFAULT_THEME: ThemeId = "tokyo-night"; +const DEFAULT_THEME: ThemeId = "dark"; const STORAGE_KEY = "codework-theme"; export const isTheme = (id: string): id is ThemeId => THEMES.some((theme) => theme.id === id); diff --git a/apps/web/src/themes.css b/apps/web/src/themes.css index 03e352d9..62978778 100644 --- a/apps/web/src/themes.css +++ b/apps/web/src/themes.css @@ -1,31 +1,27 @@ -/* - * The codework.sh site palettes, copied from sites/www/src/styles/themes.css; keep the two in step. - * Each sets the same --t-* tokens and its color-scheme. Tokyo Night is the default; another - * applies with data-theme on . - */ +/* The desktop light and dark palettes. Dark applies when no theme is selected. */ :root, -[data-theme="tokyo-night"] { - --t-bg: #1a1b26; - --t-surface: #1f2230; - --t-surface-2: #24283b; - --t-border-subtle: #24283b; - --t-border-strong: #414868; - --t-text: #c0caf5; - --t-text-secondary: #a9b1d6; - --t-text-muted: #8b93b8; - --t-brand: #9ece6a; +[data-theme="dark"] { + --t-bg: #000000; + --t-surface: #0d0d0d; + --t-surface-2: #1a1a1a; + --t-border-subtle: #1a1a1a; + --t-border-strong: #7a7a7a; + --t-text: #ffffff; + --t-text-secondary: #ffffff; + --t-text-muted: #a8a8a8; + --t-brand: #8d8d8d; --t-brand-ink: #0c0e10; - --t-field-bg: #0e0e14; - --t-field-dim: #39482e; - --t-field-mid: #678549; - --t-field-lit: #9ece6a; - --t-field-hover: #bbdd97; - --t-field-crest: #daecc6; + --t-field-bg: #070707; + --t-field-dim: #2f2f2f; + --t-field-mid: #5a5a5a; + --t-field-lit: #8d8d8d; + --t-field-hover: #afafaf; + --t-field-crest: #d4d4d4; color-scheme: dark; } -[data-theme="white"] { +[data-theme="light"] { --t-bg: #ffffff; --t-surface: #ffffff; --t-surface-2: #f5f5f5; @@ -44,403 +40,3 @@ --t-field-crest: #3c3c3c; color-scheme: light; } - -[data-theme="catppuccin"] { - --t-bg: #1e1e2e; - --t-surface: #282839; - --t-surface-2: #313244; - --t-border-subtle: #313244; - --t-border-strong: #585b70; - --t-text: #cdd6f4; - --t-text-secondary: #cdd6f4; - --t-text-muted: #9399b2; - --t-brand: #89b4fa; - --t-brand-ink: #0c0e10; - --t-field-bg: #101019; - --t-field-dim: #34415c; - --t-field-mid: #5b76a4; - --t-field-lit: #89b4fa; - --t-field-hover: #accafc; - --t-field-crest: #d2e2fd; - color-scheme: dark; -} - -[data-theme="gruvbox"] { - --t-bg: #282828; - --t-surface: #32302f; - --t-surface-2: #3c3836; - --t-border-subtle: #3c3836; - --t-border-strong: #665c54; - --t-text: #d4be98; - --t-text-secondary: #d4be98; - --t-text-muted: #a89984; - --t-brand: #7daea3; - --t-brand-ink: #0c0e10; - --t-field-bg: #161616; - --t-field-dim: #354440; - --t-field-mid: #56746d; - --t-field-lit: #7daea3; - --t-field-hover: #a4c6bf; - --t-field-crest: #cee0dc; - color-scheme: dark; -} - -[data-theme="matte-black"] { - --t-bg: #121212; - --t-surface: #181818; - --t-surface-2: #1e1e1e; - --t-border-subtle: #1e1e1e; - --t-border-strong: #333333; - --t-text: #eaeaea; - --t-text-secondary: #bebebe; - --t-text-muted: #8a8a8a; - --t-brand: #e68e0d; - --t-brand-ink: #0c0e10; - --t-field-bg: #090909; - --t-field-dim: #4b310a; - --t-field-mid: #925b0b; - --t-field-lit: #e68e0d; - --t-field-hover: #eeb056; - --t-field-crest: #f6d4a3; - color-scheme: dark; -} - -[data-theme="rose-pine"] { - --t-bg: #faf4ed; - --t-surface: #fffaf3; - --t-surface-2: #ede7e1; - --t-border-subtle: #e1dbd5; - --t-border-strong: #cecacd; - --t-text: #575279; - --t-text-secondary: #5e587d; - --t-text-muted: #676284; - --t-brand: #56949f; - --t-brand-ink: #ffffff; - --t-field-bg: #e1dbd5; - --t-field-dim: #b7c6c5; - --t-field-mid: #8bafb4; - --t-field-lit: #56949f; - --t-field-hover: #43737c; - --t-field-crest: #2f5157; - color-scheme: light; -} - -[data-theme="catppuccin-latte"] { - --t-bg: #eff1f5; - --t-surface: #f8f9fb; - --t-surface-2: #e3e4e8; - --t-border-subtle: #d7d8dc; - --t-border-strong: #acb0be; - --t-text: #4c4f69; - --t-text-secondary: #53556f; - --t-text-muted: #5c5f77; - --t-brand: #1e66f5; - --t-brand-ink: #ffffff; - --t-field-bg: #d7d8dc; - --t-field-dim: #a0b6e4; - --t-field-mid: #6491ec; - --t-field-lit: #1e66f5; - --t-field-hover: #1750bf; - --t-field-crest: #103887; - color-scheme: light; -} - -[data-theme="ethereal"] { - --t-bg: #060b1e; - --t-surface: #0c122c; - --t-surface-2: #131a3a; - --t-border-subtle: #131a3a; - --t-border-strong: #6d7db6; - --t-text: #ffcead; - --t-text-secondary: #ffcead; - --t-text-muted: #b6a6b2; - --t-brand: #7d82d9; - --t-brand-ink: #0c0e10; - --t-field-bg: #030610; - --t-field-dim: #282b4c; - --t-field-mid: #4f538d; - --t-field-lit: #7d82d9; - --t-field-hover: #a4a8e4; - --t-field-crest: #ced0f1; - color-scheme: dark; -} - -[data-theme="everforest"] { - --t-bg: #2d353b; - --t-surface: #303a40; - --t-surface-2: #343f44; - --t-border-subtle: #343f44; - --t-border-strong: #475258; - --t-text: #d3c6aa; - --t-text-secondary: #d3c6aa; - --t-text-muted: #918f84; - --t-brand: #7fbbb3; - --t-brand-ink: #0c0e10; - --t-field-bg: #181d20; - --t-field-dim: #374c4c; - --t-field-mid: #587f7b; - --t-field-lit: #7fbbb3; - --t-field-hover: #a5cfca; - --t-field-crest: #cee5e2; - color-scheme: dark; -} - -[data-theme="flexoki-light"] { - --t-bg: #fffcf0; - --t-surface: #f9f6ea; - --t-surface-2: #f2efe4; - --t-border-subtle: #e5e2d8; - --t-border-strong: #b7b5ac; - --t-text: #100f0f; - --t-text-secondary: #454340; - --t-text-muted: #555450; - --t-brand: #205ea6; - --t-brand-ink: #ffffff; - --t-field-bg: #e5e2d8; - --t-field-dim: #aabac9; - --t-field-mid: #6b90b9; - --t-field-lit: #205ea6; - --t-field-hover: #194981; - --t-field-crest: #12345b; - color-scheme: light; -} - -[data-theme="hackerman"] { - --t-bg: #0b0c16; - --t-surface: #10121f; - --t-surface-2: #151828; - --t-border-subtle: #151828; - --t-border-strong: #2d3450; - --t-text: #ddf7ff; - --t-text-secondary: #ddf7ff; - --t-text-muted: #a4b2ca; - --t-brand: #82fb9c; - --t-brand-ink: #0c0e10; - --t-field-bg: #06060c; - --t-field-dim: #2b5037; - --t-field-mid: #539e65; - --t-field-lit: #82fb9c; - --t-field-hover: #a8fcba; - --t-field-crest: #d0fdd9; - color-scheme: dark; -} - -[data-theme="kanagawa"] { - --t-bg: #1f1f28; - --t-surface: #202838; - --t-surface-2: #223249; - --t-border-subtle: #223249; - --t-border-strong: #54546d; - --t-text: #dcd7ba; - --t-text-secondary: #dcd7ba; - --t-text-muted: #a7a492; - --t-brand: #dcd7ba; - --t-brand-ink: #0c0e10; - --t-field-bg: #111116; - --t-field-dim: #4e4c47; - --t-field-mid: #8f8c7c; - --t-field-lit: #dcd7ba; - --t-field-hover: #e6e3cf; - --t-field-crest: #f2f0e5; - color-scheme: dark; -} - -[data-theme="last-horizon"] { - --t-bg: #0c0b0c; - --t-surface: #0c0b0c; - --t-surface-2: #0c0b0c; - --t-border-subtle: #0c0b0c; - --t-border-strong: #584e51; - --t-text: #fafcfb; - --t-text-secondary: #e2dddc; - --t-text-muted: #a9a5a6; - --t-brand: #b59790; - --t-brand-ink: #0c0e10; - --t-field-bg: #060606; - --t-field-dim: #3a322f; - --t-field-mid: #72605c; - --t-field-lit: #b59790; - --t-field-hover: #cbb6b1; - --t-field-crest: #e3d7d5; - color-scheme: dark; -} - -[data-theme="lumon"] { - --t-bg: #16242d; - --t-surface: #182836; - --t-surface-2: #1b2d40; - --t-border-subtle: #1b2d40; - --t-border-strong: #304860; - --t-text: #f2fcff; - --t-text-secondary: #d6e2ee; - --t-text-muted: #a0c1d8; - --t-brand: #8bc9eb; - --t-brand-ink: #0c0e10; - --t-field-bg: #0b1216; - --t-field-dim: #314956; - --t-field-mid: #5a839a; - --t-field-lit: #8bc9eb; - --t-field-hover: #aed9f1; - --t-field-crest: #d3eaf7; - color-scheme: dark; -} - -[data-theme="lupine"] { - --t-bg: #fafafa; - --t-surface: #ffffff; - --t-surface-2: #ececec; - --t-border-subtle: #dedede; - --t-border-strong: #9e9e9e; - --t-text: #000000; - --t-text-secondary: #212121; - --t-text-muted: #484848; - --t-brand: #3264eb; - --t-brand-ink: #ffffff; - --t-field-bg: #dedede; - --t-field-dim: #aab9e2; - --t-field-mid: #7392e6; - --t-field-lit: #3264eb; - --t-field-hover: #274eb7; - --t-field-crest: #1c3781; - color-scheme: light; -} - -[data-theme="miasma"] { - --t-bg: #222222; - --t-surface: #272727; - --t-surface-2: #2c2c2c; - --t-border-subtle: #2c2c2c; - --t-border-strong: #666666; - --t-text: #c2c2b0; - --t-text-secondary: #c2c2b0; - --t-text-muted: #8c8c82; - --t-brand: #78824b; - --t-brand-ink: #0c0e10; - --t-field-bg: #121212; - --t-field-dim: #313423; - --t-field-mid: #515735; - --t-field-lit: #78824b; - --t-field-hover: #a0a881; - --t-field-crest: #ccd0bb; - color-scheme: dark; -} - -[data-theme="nord"] { - --t-bg: #2e3440; - --t-surface: #343b49; - --t-surface-2: #3b4252; - --t-border-subtle: #3b4252; - --t-border-strong: #4c566a; - --t-text: #d8dee9; - --t-text-secondary: #d8dee9; - --t-text-muted: #9fa7b4; - --t-brand: #81a1c1; - --t-brand-ink: #0c0e10; - --t-field-bg: #191c23; - --t-field-dim: #384452; - --t-field-mid: #596e85; - --t-field-lit: #81a1c1; - --t-field-hover: #a7bdd4; - --t-field-crest: #cfdbe7; - color-scheme: dark; -} - -[data-theme="osaka-jade"] { - --t-bg: #111c18; - --t-surface: #1a2a22; - --t-surface-2: #23372b; - --t-border-subtle: #23372b; - --t-border-strong: #53685b; - --t-text: #f7e8b2; - --t-text-secondary: #c1c497; - --t-text-muted: #969978; - --t-brand: #509475; - --t-brand-ink: #0c0e10; - --t-field-bg: #090f0d; - --t-field-dim: #1e372c; - --t-field-mid: #35614d; - --t-field-lit: #509475; - --t-field-hover: #84b49e; - --t-field-crest: #bcd6cb; - color-scheme: dark; -} - -[data-theme="retro-82"] { - --t-bg: #05182e; - --t-surface: #081e37; - --t-surface-2: #0a2540; - --t-border-subtle: #0a2540; - --t-border-strong: #2a6b78; - --t-text: #f6dcac; - --t-text-secondary: #f6dcac; - --t-text-muted: #9ab69b; - --t-brand: #faa968; - --t-brand-ink: #0c0e10; - --t-field-bg: #020c17; - --t-field-dim: #4c3b2f; - --t-field-mid: #9c6d49; - --t-field-lit: #faa968; - --t-field-hover: #fcc395; - --t-field-crest: #fddec6; - color-scheme: dark; -} - -[data-theme="ristretto"] { - --t-bg: #2c2525; - --t-surface: #342a28; - --t-surface-2: #3d2f2a; - --t-border-subtle: #3d2f2a; - --t-border-strong: #72696a; - --t-text: #e6d9db; - --t-text-secondary: #e6d9db; - --t-text-muted: #aca1a2; - --t-brand: #f38d70; - --t-brand-ink: #0c0e10; - --t-field-bg: #181414; - --t-field-dim: #5a3830; - --t-field-mid: #a05f4d; - --t-field-lit: #f38d70; - --t-field-hover: #f7af9b; - --t-field-crest: #fad4c9; - color-scheme: dark; -} - -[data-theme="solitude"] { - --t-bg: #101315; - --t-surface: #101315; - --t-surface-2: #101315; - --t-border-subtle: #101315; - --t-border-strong: #4b4e55; - --t-text: #cacccc; - --t-text-secondary: #a5aeb4; - --t-text-muted: #8a8d90; - --t-brand: #798186; - --t-brand-ink: #0c0e10; - --t-field-bg: #080a0b; - --t-field-dim: #2a2e30; - --t-field-mid: #4e5457; - --t-field-lit: #798186; - --t-field-hover: #a1a7aa; - --t-field-crest: #cccfd1; - color-scheme: dark; -} - -[data-theme="vantablack"] { - --t-bg: #000000; - --t-surface: #0d0d0d; - --t-surface-2: #1a1a1a; - --t-border-subtle: #1a1a1a; - --t-border-strong: #7a7a7a; - --t-text: #ffffff; - --t-text-secondary: #ffffff; - --t-text-muted: #a8a8a8; - --t-brand: #8d8d8d; - --t-brand-ink: #0c0e10; - --t-field-bg: #070707; - --t-field-dim: #2f2f2f; - --t-field-mid: #5a5a5a; - --t-field-lit: #8d8d8d; - --t-field-hover: #afafaf; - --t-field-crest: #d4d4d4; - color-scheme: dark; -} diff --git a/apps/web/src/widgets/session/highlight.tsx b/apps/web/src/widgets/session/highlight.tsx index a71242f1..b2304163 100644 --- a/apps/web/src/widgets/session/highlight.tsx +++ b/apps/web/src/widgets/session/highlight.tsx @@ -12,33 +12,10 @@ import { import type { ThemeId } from "../../theme"; -/** - * The Shiki theme whose token colours go with each palette: the same theme where Shiki ships it, - * else the closest in mood. Only token colours are used; the code block's background is ours. - */ +/** Syntax colours follow the app's light or dark appearance. */ const SHIKI_THEMES: Record = { - "tokyo-night": "tokyo-night", - catppuccin: "catppuccin-mocha", - "catppuccin-latte": "catppuccin-latte", - gruvbox: "gruvbox-dark-medium", - everforest: "everforest-dark", - kanagawa: "kanagawa-wave", - nord: "nord", - "rose-pine": "rose-pine-dawn", - "last-horizon": "horizon", - white: "github-light", - "flexoki-light": "vitesse-light", - lupine: "one-light", - "matte-black": "github-dark-default", - vantablack: "min-dark", - hackerman: "github-dark-high-contrast", - lumon: "poimandres", - ethereal: "one-dark-pro", - miasma: "gruvbox-dark-soft", - "osaka-jade": "vitesse-dark", - "retro-82": "synthwave-84", - ristretto: "monokai", - solitude: "github-dark-dimmed", + light: "github-light", + dark: "github-dark-default", }; type Root = ReturnType; From bc79206a6b8f71df269155f11f825a469c177b09 Mon Sep 17 00:00:00 2001 From: Sanchit Rk <0xsanchit@gmail.com> Date: Sun, 1 Nov 2026 15:12:29 +0530 Subject: [PATCH 3/5] fix(desktop): show a fork's source title until its first prompt Co-Authored-By: Claude Opus 5.5 --- apps/web/src/widgets/session/backend.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/apps/web/src/widgets/session/backend.ts b/apps/web/src/widgets/session/backend.ts index 87038ba0..99249f1d 100644 --- a/apps/web/src/widgets/session/backend.ts +++ b/apps/web/src/widgets/session/backend.ts @@ -33,8 +33,8 @@ import { } from "./schema.ts"; // Metadata follows the addressed thread; placement and project belong to its session. -const toInfo = (info: ThreadInfo): Info => ({ - title: info.title ?? UNTITLED, +const toInfo = (info: ThreadInfo, title: string | undefined): Info => ({ + title: title ?? UNTITLED, updated: info.updatedAt, ...(info.session.hostDir === undefined ? {} : { hostDir: info.session.hostDir }), ...(info.session.sandbox === undefined ? {} : { sandbox: info.session.sandbox.driver }), @@ -207,6 +207,20 @@ export const session = defineBackend({ return streamed.message; }); + /** A fork or subagent reads as its source until its first own prompt names it. */ + const titleOf = Effect.fn("Session.titleOf")(function* (info: ThreadInfo) { + let current = info; + while (current.title === undefined && current.origin.kind !== "main") { + const source = yield* codework("thread.info", { + sessionId: info.session.id, + threadId: current.origin.threadId, + }).pipe(Effect.option); + if (Option.isNone(source)) return undefined; + current = source.value; + } + return current.title; + }); + /** Refetches the conversation, publishes what changed, then stores the snapshot. */ const refresh = Effect.fn("Session.refresh")(function* (ref: ThreadRef, cursor: number | undefined) { const key = threadKey(ref); @@ -217,7 +231,7 @@ export const session = defineBackend({ const queue = yield* codework("thread.queue", target); const history = yield* codework("thread.history", target); const before = yield* load(key); - const next = toInfo(info); + const next = toInfo(info, yield* titleOf(info)); const messages = withStreamed(history.entries); // One that is in both has been promoted: the conversation wins. const listed = new Set(messages.map((message) => message.id)); From 79fab21f619023ba300f3239e63071b965e11454 Mon Sep 17 00:00:00 2001 From: Sanchit Rk <0xsanchit@gmail.com> Date: Sun, 1 Nov 2026 15:12:29 +0530 Subject: [PATCH 4/5] fix(desktop): refresh the sessions list once a session is titled Co-Authored-By: Claude Opus 5.5 --- apps/web/src/widgets/session/view.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/web/src/widgets/session/view.tsx b/apps/web/src/widgets/session/view.tsx index 23cfedc0..891f21e4 100644 --- a/apps/web/src/widgets/session/view.tsx +++ b/apps/web/src/widgets/session/view.tsx @@ -1,3 +1,4 @@ +import { useAtomRefresh } from "@effect/atom-react"; import { LegendList, type MaintainScrollAtEndOptions } from "@legendapp/list/react"; import type { HistoryEntry, Part, QueuedPrompt, ToolCall } from "@codeworksh/widget/codework"; import { useBus, useEvents, useFrame, type WidgetProps } from "@codeworksh/widget/view"; @@ -13,7 +14,7 @@ import { SessionComposer } from "./composer"; import { Markdown } from "./markdown"; import { Message } from "./message"; import { Queue } from "./queue"; -import { useListedSession } from "./projects"; +import { projectsAtom, useListedSession } from "./projects"; import { type Info, Json, type ThreadRef, threadKey, topics, type Update } from "./schema"; const decodeReply = Schema.decodeUnknownOption(Json.Reply); @@ -184,6 +185,12 @@ function Conversation({ thread, instanceId }: { readonly thread: ThreadRef; read // Named from the sessions list at once, so the frame never shows its default title while loading. const listed = useListedSession(thread.sessionId); const title = state.status === "ready" ? state.info.title : listed?.title; + // A first prompt names the session after the list was fetched; the main thread's title is the listed one. + const refreshProjects = useAtomRefresh(projectsAtom); + const stale = thread.threadId === undefined && state.status === "ready" && listed?.title !== title; + useEffect(() => { + if (stale) refreshProjects(); + }, [stale, title, refreshProjects]); const project = state.status === "ready" ? state.info.project : listed?.project; const projectId = project?.id; const projectName = project?.name; From 585145790c63095516756ee8be16722636aba894 Mon Sep 17 00:00:00 2001 From: Sanchit Rk <0xsanchit@gmail.com> Date: Sun, 1 Nov 2026 15:12:29 +0530 Subject: [PATCH 5/5] refactor(desktop): start without seeded workspaces Co-Authored-By: Claude Opus 5.5 --- apps/server/src/db.ts | 8 ----- apps/server/test/__artifacts__/desk.json | 37 ++++++++++++------------ apps/server/test/desk.test.ts | 17 +++++------ 3 files changed, 26 insertions(+), 36 deletions(-) diff --git a/apps/server/src/db.ts b/apps/server/src/db.ts index 3f2ac840..74d0b3eb 100644 --- a/apps/server/src/db.ts +++ b/apps/server/src/db.ts @@ -30,14 +30,6 @@ const migrations = { created INTEGER NOT NULL ) `; - const created = yield* Clock.currentTimeMillis; - yield* sql`INSERT INTO workspaces ${sql.insert( - [ - { id: "main", name: "Main", icon: "layout-dashboard" }, - { id: "code", name: "Code", icon: "code" }, - { id: "notes", name: "Notes", icon: "notebook-pen" }, - ].map((workspace, index) => ({ ...workspace, bit: index, pos: index, layout: "tile", mfact: 0.6, created })), - )}`; // AUTOINCREMENT so a seq is never reused, even after the newest rows are deleted. yield* sql` CREATE TABLE event ( diff --git a/apps/server/test/__artifacts__/desk.json b/apps/server/test/__artifacts__/desk.json index 9400b63f..143bcb44 100644 --- a/apps/server/test/__artifacts__/desk.json +++ b/apps/server/test/__artifacts__/desk.json @@ -4,10 +4,19 @@ "tileOrder": [], "focusOrder": [] }, + "other": { + "id": "", + "bit": 0, + "pos": 0, + "name": "Other", + "layout": "tile", + "mfact": 0.6, + "auto": false + }, "workspace": { "id": "", - "bit": 3, - "pos": 3, + "bit": 1, + "pos": 1, "name": "Scratch", "layout": "tile", "mfact": 0.6, @@ -18,7 +27,7 @@ { "id": "browser-1", "kind": "browser", - "tags": 9, + "tags": 3, "props": {}, "pinned": false, "title": "Docs", @@ -35,7 +44,7 @@ { "id": "notes-1", "kind": "notes", - "tags": 8, + "tags": 2, "props": { "text": "hello" }, @@ -56,7 +65,7 @@ { "id": "browser-1", "kind": "browser", - "tags": 9, + "tags": 3, "props": {}, "pinned": false, "title": "Docs", @@ -73,7 +82,7 @@ { "id": "notes-1", "kind": "notes", - "tags": 8, + "tags": 2, "props": { "text": "hello" }, @@ -129,24 +138,14 @@ "afterRestart": { "workspaces": [ { - "name": "Main", + "name": "Other", "auto": false, "pos": 0 }, - { - "name": "Code", - "auto": false, - "pos": 1 - }, - { - "name": "Notes", - "auto": false, - "pos": 2 - }, { "name": "Kept", "auto": true, - "pos": 3, + "pos": 1, "tab": "Kept / A session" } ], @@ -155,7 +154,7 @@ { "id": "notes-2", "kind": "notes", - "tags": 8, + "tags": 2, "props": {}, "pinned": false } diff --git a/apps/server/test/desk.test.ts b/apps/server/test/desk.test.ts index 46daf066..a31dc026 100644 --- a/apps/server/test/desk.test.ts +++ b/apps/server/test/desk.test.ts @@ -60,14 +60,17 @@ it("desk round-trips and follows workspace deletion", async () => { const rpc = yield* RpcClient.make(Contract.Api); const empty = yield* rpc["desk.get"](); + // Two workspaces, so a frame on both outlives deleting one of them. + const other = yield* rpc["workspaces.create"]({ name: "Other" }); const workspace = yield* rpc["workspaces.create"]({ name: "Scratch" }); const bit = 1 << workspace.bit; + const otherBit = 1 << other.bit; const saved: Contract.Desk = { instances: [ { id: "browser-1", kind: "browser", - tags: bit | 1, + tags: bit | otherBit, props: {}, pinned: false, title: "Docs", @@ -105,6 +108,7 @@ it("desk round-trips and follows workspace deletion", async () => { return { empty, + other: { ...other, id: "" }, workspace: { ...workspace, id: "" }, saved, roundTrip, @@ -114,7 +118,7 @@ it("desk round-trips and follows workspace deletion", async () => { }).pipe(Effect.scoped, Effect.provide(protocol()), Effect.runPromise); expect(steps.roundTrip).toEqual(steps.saved); - expect(steps.afterDelete.instances).toEqual([{ ...steps.saved.instances[0], tags: 1 }]); + expect(steps.afterDelete.instances).toEqual([{ ...steps.saved.instances[0], tags: 1 << steps.other.bit }]); // A restart sweeps the empty auto workspace and keeps the one with a frame. await stop(); @@ -125,14 +129,9 @@ it("desk round-trips and follows workspace deletion", async () => { const desk = yield* rpc["desk.get"](); return { workspaces: workspaces.map(({ name, auto, pos, tab }) => ({ name, auto, pos, tab })), desk }; }).pipe(Effect.scoped, Effect.provide(protocol()), Effect.runPromise); - expect(afterRestart.workspaces.map((workspace) => workspace.name)).toEqual(["Main", "Code", "Notes", "Kept"]); + expect(afterRestart.workspaces.map((workspace) => workspace.name)).toEqual(["Other", "Kept"]); // A workspace's last tab survives the restart, so it names what it shows before its frame loads. - expect(afterRestart.workspaces.map((workspace) => workspace.tab)).toEqual([ - undefined, - undefined, - undefined, - "Kept / A session", - ]); + expect(afterRestart.workspaces.map((workspace) => workspace.tab)).toEqual([undefined, "Kept / A session"]); await expect(`${JSON.stringify({ ...steps, afterRestart }, null, "\t")}\n`).toMatchFileSnapshot( "./__artifacts__/desk.json",