Skip to content

The agent that grows with you

docs(desktop): name the timer drain in the effect that performs it

Jack Laufab931fa28f8
diff --git a/apps/desktop/src/components/assistant-ui/thread/user-edit-composer.tsx b/apps/desktop/src/components/assistant-ui/thread/user-edit-composer.tsx
index a61409b3aeb..cd0d45eb347 100644
--- a/apps/desktop/src/components/assistant-ui/thread/user-edit-composer.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/user-edit-composer.tsx
@@ -140,6 +140,11 @@ export const UserEditComposer: FC<UserEditComposerProps> = ({ cwd, gateway, sess
// bus leaks: confirming or cancelling an edit tears the composer down while
// `'edit'` is still the active target. Release it alongside the thread-scroll
// cleanup so keyboard routing falls back to the visible chat composer.
+ //
+ // It also drains whatever `scheduleTimeout` still has pending, which is a
+ // second concern under the same heading rather than a separate one: both
+ // are "this composer is going away", they unmount together by definition,
+ // and a sibling unmount-only effect would only be a second place to forget.
useEffect(
() => () => {
notifyThreadEditClose()
diff --git a/apps/desktop/src/components/assistant-ui/thread/user-message-edit.test.tsx b/apps/desktop/src/components/assistant-ui/thread/user-message-edit.test.tsx
index 5befc0515d8..98449a0cb33 100644
--- a/apps/desktop/src/components/assistant-ui/thread/user-message-edit.test.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/user-message-edit.test.tsx
@@ -263,9 +263,13 @@ describe('Enter submission and latch behavior', () => {
return id
}) as typeof window.setTimeout)
- vi.spyOn(window, 'clearTimeout').mockImplementation(((id?: number) => {
+ // `id` is typed `unknown` for the same reason the arrays above are: what
+ // actually arrives is whatever `setTimeout` returned, and under jsdom that
+ // is a Timeout object rather than the `number` the DOM lib promises.
+ // Declaring it `number` would have documented a shape this never sees.
+ vi.spyOn(window, 'clearTimeout').mockImplementation(((id?: unknown) => {
cleared.push(id)
- realClearTimeout(id)
+ realClearTimeout(id as number | undefined)
}) as typeof window.clearTimeout)
const onEdit = vi.fn(async () => {})