Skip to content

The agent that grows with you

fix(desktop): keep the edit composer available after a timeline rail jump

Finn763f532b8adf50c
diff --git a/apps/desktop/src/app/chat/history-window.test.tsx b/apps/desktop/src/app/chat/history-window.test.tsx
index 71b6a8080ec..0040192d370 100644
--- a/apps/desktop/src/app/chat/history-window.test.tsx
+++ b/apps/desktop/src/app/chat/history-window.test.tsx
@@ -91,7 +91,10 @@ describe('bounded direct history runtime', () => {
await act(async () => { await mounted.window.revealRow(40, new AbortController().signal) })
const historical = mounted.runtime.thread.getState().messages
const snapshot = mounted.window
- expect(mounted.runtime.thread.getState().capabilities.edit).toBe(false)
+ // `edit` is the one capability that survives on a bounded page: the rail
+ // jump is its only entry and it has no in-thread exit, so dropping it
+ // wedged the inline composer after every far jump (#117298).
+ expect(mounted.runtime.thread.getState().capabilities.edit).toBe(true)
expect(mounted.runtime.thread.getState().capabilities.reload).toBe(false)
expect(mounted.runtime.thread.getState().capabilities.switchToBranch).toBe(false)
expect(mounted.runtime.thread.getState().isDisabled).toBe(true)
@@ -109,6 +112,29 @@ describe('bounded direct history runtime', () => {
for (const callback of Object.values(mounted.mutations)) {expect(callback).not.toHaveBeenCalled()}
})
+ it('keeps the edit composer available after a rail jump selects a history page', async () => {
+ vi.spyOn(window.hermesDesktop, 'api').mockResolvedValue(page(40))
+ const mounted = mount()
+ await act(async () => { await mounted.window.revealRow(40, new AbortController().signal) })
+
+ expect(mounted.window.isHistorical).toBe(true)
+ expect(mounted.runtime.thread.getState().capabilities.edit).toBe(true)
+
+ // The exact gesture that was dead: clicking a message on the bounded page
+ // the rail selected. With `onEdit` dropped on a history page this threw
+ // "Runtime does not support editing" (ExternalStoreThreadRuntimeCore
+ // .beginEdit) and left the composer unopenable for every message, healed
+ // only by the floating jump button's returnToLatest.
+ const composer = mounted.runtime.thread.getMessageByIndex(0).composer
+
+ expect(() => act(() => { composer.beginEdit() })).not.toThrow()
+ expect(composer.getState().isEditing).toBe(true)
+
+ act(() => { composer.cancel() })
+ act(() => { mounted.window.returnToLatest() })
+ expect(composer.getState().isEditing).toBe(false)
+ })
+
it('latest request wins even when the bridge ignores cancellation', async () => {
const resolves: ((value: ReturnType<typeof page>) => void)[] = []
vi.spyOn(window.hermesDesktop, 'api').mockImplementation(() => new Promise(resolve => resolves.push(resolve)))
diff --git a/apps/desktop/src/app/chat/index.tsx b/apps/desktop/src/app/chat/index.tsx
index db354346327..a4544479da0 100644
--- a/apps/desktop/src/app/chat/index.tsx
+++ b/apps/desktop/src/app/chat/index.tsx
@@ -407,7 +407,16 @@ export function ChatRuntimeBoundary({
// Submission is handled explicitly by ChatBar.
// Keeping this no-op avoids duplicate prompt.submit calls.
},
- onEdit: isHistorical ? undefined : onEdit,
+ // Editing stays AVAILABLE on a history page. `isDisabled` above blocks
+ // submit/reload/branch and keeps the page static, but the rail jump is
+ // the only way into that page and it has no in-thread exit — so dropping
+ // `onEdit` left the inline composer unopenable after ANY far rail jump
+ // (the throw "Runtime does not support editing", infectious downward,
+ // healed only by the floating jump button's returnToLatest). `editMessage`
+ // already resolves its target against the live session store
+ // (use-prompt-actions), never the display page, so the edit is correct;
+ // sending one rewinds the live transcript and drops the page.
+ onEdit,
onCancel: isHistorical ? undefined : async () => onCancel(),
onReload: isHistorical ? undefined : onReload
})