Skip to content

Commit 63c5dff

Browse files
authored
fix(app): persist queued followups across project switches (anomalyco#19421)
1 parent d99354c commit 63c5dff

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

packages/app/src/pages/session.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,15 @@ import { TerminalPanel } from "@/pages/session/terminal-panel"
5757
import { useSessionCommands } from "@/pages/session/use-session-commands"
5858
import { useSessionHashScroll } from "@/pages/session/use-session-hash-scroll"
5959
import { Identifier } from "@/utils/id"
60+
import { Persist, persisted } from "@/utils/persist"
6061
import { extractPromptFromParts } from "@/utils/prompt"
6162
import { same } from "@/utils/same"
6263
import { formatServerError } from "@/utils/server-errors"
6364

6465
const emptyUserMessages: UserMessage[] = []
65-
const emptyFollowups: (FollowupDraft & { id: string })[] = []
66+
type FollowupItem = FollowupDraft & { id: string }
67+
type FollowupEdit = Pick<FollowupItem, "id" | "prompt" | "context">
68+
const emptyFollowups: FollowupItem[] = []
6669

6770
type SessionHistoryWindowInput = {
6871
sessionID: () => string | undefined
@@ -512,15 +515,20 @@ export default function Page() {
512515
deferRender: false,
513516
})
514517

515-
const [followup, setFollowup] = createStore({
516-
items: {} as Record<string, (FollowupDraft & { id: string })[] | undefined>,
517-
failed: {} as Record<string, string | undefined>,
518-
paused: {} as Record<string, boolean | undefined>,
519-
edit: {} as Record<
520-
string,
521-
{ id: string; prompt: FollowupDraft["prompt"]; context: FollowupDraft["context"] } | undefined
522-
>,
523-
})
518+
const [followup, setFollowup] = persisted(
519+
Persist.workspace(sdk.directory, "followup", ["followup.v1"]),
520+
createStore<{
521+
items: Record<string, FollowupItem[] | undefined>
522+
failed: Record<string, string | undefined>
523+
paused: Record<string, boolean | undefined>
524+
edit: Record<string, FollowupEdit | undefined>
525+
}>({
526+
items: {},
527+
failed: {},
528+
paused: {},
529+
edit: {},
530+
}),
531+
)
524532

525533
createComputed((prev) => {
526534
const key = sessionKey()

0 commit comments

Comments
 (0)