feat: add URL-driven workspace state and streamed Codex research

This commit is contained in:
2026-09-28 20:08:28 +09:00
parent 85d23a328b
commit 8085ad2f90
207 changed files with 15287 additions and 16026 deletions
+23 -23
View File
@@ -1,11 +1,16 @@
import type { Deck, DeckView, Workspace } from '../decks/model'
import type { Deck, DeckView, Workspace } from "../decks/model";
type WorkspaceActions = {
getWorkspace: () => Workspace
createTemporary: (title: string, columns: Deck['columns']) => DeckView
save: (deck: Deck) => Promise<boolean>
select: (id: string) => unknown
}
getWorkspace: () => Workspace;
createTemporary: (
title: string,
columns: Deck["columns"],
activate?: boolean,
preferredId?: string,
) => DeckView;
save: (deck: Deck) => Promise<boolean>;
select: (id: string, updateUrl?: boolean) => unknown;
};
/** A generated plan owns a temporary view, never a user's saved deck. */
export async function syncResearchDeck(
@@ -14,28 +19,23 @@ export async function syncResearchDeck(
bindings: Map<string, string>,
workspace: WorkspaceActions,
): Promise<void> {
const before = workspace.getWorkspace()
const previousActiveId = before.activeDeckId
const previousId = bindings.get(plan.id)
const existing = before.decks.find((deck) => deck.id === previousId)
let viewId: string
const before = workspace.getWorkspace();
const previousActiveId = before.activeDeckId;
const previousId = bindings.get(plan.id);
const existing = before.decks.find((deck) => deck.id === previousId);
let viewId: string;
if (existing && !existing.persisted) {
if (!(await workspace.save({ ...plan, id: existing.id }))) {
throw new Error(
'Unable to update the temporary deck. Try again after saving finishes.',
)
throw new Error("Unable to update the temporary deck. Try again after saving finishes.");
}
viewId = existing.id
viewId = existing.id;
} else {
viewId = workspace.createTemporary(plan.title, plan.columns).id
bindings.set(plan.id, viewId)
viewId = workspace.createTemporary(plan.title, plan.columns, false, plan.id).id;
bindings.set(plan.id, viewId);
}
if (activate) {
workspace.select(viewId)
} else if (
previousId &&
workspace.getWorkspace().decks.some((deck) => deck.id === previousActiveId)
) {
workspace.select(previousActiveId)
workspace.select(viewId);
} else if (workspace.getWorkspace().decks.some((deck) => deck.id === previousActiveId)) {
workspace.select(previousActiveId, false);
}
}