diff --git a/packages/tui/src/ui/dialog.tsx b/packages/tui/src/ui/dialog.tsx
index 6604e034794..b9a4eb3ccd9 100644
--- a/packages/tui/src/ui/dialog.tsx
+++ b/packages/tui/src/ui/dialog.tsx
@@ -225,7 +225,7 @@ function DialogFooterItem(props: { action: DialogFooterAction }) {
function init() {
const [store, setStore] = createStore({
stack: [] as {
- element: JSX.Element
+ element: () => JSX.Element
onClose?: () => void
key?: unknown
}[],
@@ -316,7 +316,7 @@ function init() {
})
refocus()
},
- replace(input: any, onClose?: () => void, options?: { key?: unknown; size?: DialogSize }) {
+ replace(input: () => JSX.Element, onClose?: () => void, options?: { key?: unknown; size?: DialogSize }) {
if (store.stack.length === 0) {
focus = renderer.currentFocusedRenderable
focus?.blur()
@@ -390,7 +390,11 @@ export function DialogProvider(props: ParentProps) {
>
diff --git a/packages/tui/test/component/dialog-error-details.test.tsx b/packages/tui/test/component/dialog-error-details.test.tsx
index e43978000e4..f5fe2a7c2a2 100644
--- a/packages/tui/test/component/dialog-error-details.test.tsx
+++ b/packages/tui/test/component/dialog-error-details.test.tsx
@@ -35,7 +35,7 @@ for (const width of [40, 100]) {
route = useRoute()
const dialog = useDialog()
onMount(() =>
- dialog.replace(
+ dialog.replace(() => (
dialog.clear()}
- />,
- ),
+ />
+ )),
)
return null
}
diff --git a/packages/tui/test/session-fork-pending.test.tsx b/packages/tui/test/session-fork-pending.test.tsx
new file mode 100644
index 00000000000..e5f665368e9
--- /dev/null
+++ b/packages/tui/test/session-fork-pending.test.tsx
@@ -0,0 +1,60 @@
+import { expect, test } from "bun:test"
+import { createAppFixture } from "./fixture/app"
+import { directory, json } from "./fixture/tui-client"
+
+const session = {
+ id: "ses_fork_pending",
+ title: "Fork pending",
+ projectID: "proj_test",
+ location: { directory },
+ cost: 0,
+ tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
+ time: { created: 0, updated: 0 },
+}
+const messages = [
+ {
+ type: "assistant",
+ id: "msg_b",
+ agent: "build",
+ model: { providerID: "fixture", id: "fixture" },
+ finish: "stop",
+ time: { created: 2, completed: 3 },
+ content: [{ type: "text", text: "First answer" }],
+ },
+ { type: "user", id: "msg_a", text: "First prompt", time: { created: 1 } },
+]
+
+test("choosing a row in /fork shows the pending view until the fork finishes", async () => {
+ const fork = Promise.withResolvers()
+ const requested = Promise.withResolvers()
+ await using setup = await createAppFixture({
+ width: 112,
+ height: 34,
+ config: { animations: false, tabs: { enabled: false } },
+ args: { sessionID: session.id },
+ fetch: (url) => {
+ if (url.pathname === "/api/session") return json({ data: [session], cursor: {} })
+ if (url.pathname === `/api/session/${session.id}`) return json({ data: session })
+ if (url.pathname === `/api/session/${session.id}/fork`) {
+ requested.resolve()
+ return fork.promise
+ }
+ if (/^\/api\/session\/ses_fork_pending\/(message|inbox|permission)$/.test(url.pathname))
+ return json({ data: url.pathname.endsWith("/message") ? messages : [], cursor: {} })
+ return undefined
+ },
+ })
+
+ try {
+ await setup.waitForFrame((frame) => frame.includes("First answer"))
+ await setup.mockInput.typeText("/fork")
+ setup.mockInput.pressEnter()
+ await setup.waitForFrame((frame) => frame.includes("Fork session") && frame.includes("Full session"))
+ setup.mockInput.pressEnter()
+ await requested.promise
+ await setup.waitForFrame((frame) => frame.includes("Forking session") && !frame.includes("Full session"))
+ expect(setup.captureCharFrame()).toContain("Fork session")
+ } finally {
+ fork.resolve(new Response(null, { status: 500 }))
+ }
+}, 20000)