-
Notifications
You must be signed in to change notification settings - Fork 120
🤖 feat: continue interrupted stream by clicking the interrupted splitter #3634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d7e6eaa
feat: continue interrupted stream by clicking the interrupted splitter
ethanndickson d89eba2
fix: address Codex review on interrupted-splitter resume
ethanndickson 9364f85
fix: surface interrupted-resume failures on the divider
ethanndickson c4d3d05
fix: don't make interrupted divider resumable in transcript-only chats
ethanndickson 928bc36
feat: add keyboard shortcut to continue interrupted streams
ethanndickson 9299d1d
fix: scope resume state per-workspace + list resume shortcut
ethanndickson 1fcb5b4
fix: restrict divider resume to suppressed-Retry turns + scope error …
ethanndickson 2c9e9fd
refactor: slim interrupted-divider resume to a one-shot hook
ethanndickson 483bd8f
fix: make pre-token interrupted turns resumable
ethanndickson e53d546
fix: use Shift+R for resume keybind instead of Ctrl/Cmd+Shift+Enter
ethanndickson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
src/browser/features/Messages/ChatBarrier/InterruptedBarrier.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test"; | ||
| import { cleanup, fireEvent, render, waitFor } from "@testing-library/react"; | ||
| import { GlobalWindow } from "happy-dom"; | ||
|
|
||
| import type * as WorkspaceStoreModule from "@/browser/stores/WorkspaceStore"; | ||
|
|
||
| interface MockWorkspaceState { | ||
| autoRetryStatus: null; | ||
| isStreamStarting: boolean; | ||
| canInterrupt: boolean; | ||
| messages: Array<Record<string, unknown>>; | ||
| } | ||
|
|
||
| function createWorkspaceState(overrides: Partial<MockWorkspaceState> = {}): MockWorkspaceState { | ||
| return { | ||
| autoRetryStatus: null, | ||
| isStreamStarting: false, | ||
| canInterrupt: false, | ||
| messages: [ | ||
| { | ||
| type: "user", | ||
| id: "user-1", | ||
| historyId: "user-1", | ||
| content: "Hello", | ||
| historySequence: 1, | ||
| }, | ||
| ], | ||
| ...overrides, | ||
| }; | ||
| } | ||
|
|
||
| let currentWorkspaceState = createWorkspaceState(); | ||
|
|
||
| let resumeStreamResult: { success: true; data: { started: boolean } } = { | ||
| success: true, | ||
| data: { started: true }, | ||
| }; | ||
| const resumeStream = mock((_input: unknown) => Promise.resolve(resumeStreamResult)); | ||
| const setAutoRetryEnabled = mock((input: unknown) => | ||
| Promise.resolve({ | ||
| success: true as const, | ||
| data: { | ||
| previousEnabled: true, | ||
| enabled: | ||
| typeof input === "object" && input !== null && "enabled" in input | ||
| ? ((input as { enabled?: boolean }).enabled ?? true) | ||
| : true, | ||
| }, | ||
| }) | ||
| ); | ||
|
|
||
| void mock.module("@/browser/contexts/API", () => ({ | ||
| useAPI: () => ({ | ||
| api: { | ||
| workspace: { | ||
| resumeStream, | ||
| setAutoRetryEnabled, | ||
| }, | ||
| }, | ||
| status: "connected" as const, | ||
| error: null, | ||
| authenticate: () => undefined, | ||
| retry: () => undefined, | ||
| }), | ||
| })); | ||
|
|
||
| /* eslint-disable @typescript-eslint/no-require-imports */ | ||
| const actualWorkspaceStore = | ||
| require("@/browser/stores/WorkspaceStore?real=1") as typeof WorkspaceStoreModule; | ||
| /* eslint-enable @typescript-eslint/no-require-imports */ | ||
|
|
||
| void mock.module("@/browser/stores/WorkspaceStore", () => ({ | ||
| ...actualWorkspaceStore, | ||
| useWorkspaceState: () => currentWorkspaceState, | ||
| useWorkspaceStoreRaw: () => ({ | ||
| getWorkspaceState: (_workspaceId: string) => currentWorkspaceState, | ||
| }), | ||
| })); | ||
|
|
||
| import { InterruptedBarrier } from "./InterruptedBarrier"; | ||
|
|
||
| describe("InterruptedBarrier", () => { | ||
| beforeEach(() => { | ||
| globalThis.window = new GlobalWindow() as unknown as Window & typeof globalThis; | ||
| globalThis.document = globalThis.window.document; | ||
|
|
||
| currentWorkspaceState = createWorkspaceState(); | ||
| resumeStreamResult = { success: true, data: { started: true } }; | ||
| resumeStream.mockClear(); | ||
| setAutoRetryEnabled.mockClear(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| cleanup(); | ||
| mock.restore(); | ||
| globalThis.window = undefined as unknown as Window & typeof globalThis; | ||
| globalThis.document = undefined as unknown as Document; | ||
| }); | ||
|
|
||
| test("clicking the interrupted label resumes the stream", async () => { | ||
| const view = render(<InterruptedBarrier workspaceId="ws-1" />); | ||
|
|
||
| const label = view.getByRole("button", { name: "Continue interrupted response" }); | ||
| fireEvent.click(label); | ||
|
|
||
| await waitFor(() => { | ||
| expect(resumeStream).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| // Temporarily enables auto-retry (persist:false) before resuming, mirroring | ||
| // the RetryBarrier / backend auto-retry flow. | ||
| expect(setAutoRetryEnabled).toHaveBeenCalledWith({ | ||
| workspaceId: "ws-1", | ||
| enabled: true, | ||
| persist: false, | ||
| }); | ||
| expect(resumeStream.mock.calls[0]?.[0]).toMatchObject({ workspaceId: "ws-1" }); | ||
| }); | ||
| }); |
24 changes: 22 additions & 2 deletions
24
src/browser/features/Messages/ChatBarrier/InterruptedBarrier.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,30 @@ | ||
| import React from "react"; | ||
| import { BaseBarrier } from "./BaseBarrier"; | ||
| import { useResumeStream } from "@/browser/hooks/useResumeStream"; | ||
|
|
||
| interface InterruptedBarrierProps { | ||
| workspaceId: string; | ||
| className?: string; | ||
| } | ||
|
|
||
| export const InterruptedBarrier: React.FC<InterruptedBarrierProps> = ({ className }) => { | ||
| return <BaseBarrier text="interrupted" color="var(--color-interrupted)" className={className} />; | ||
| /** | ||
| * Decorative "interrupted" divider shown on a partial assistant turn. Clicking | ||
| * the label continues the stream from where it stopped, identical to the | ||
| * RetryBarrier's Retry button and the backend auto-retry path (resumeStream). | ||
| * This is the only continue affordance for user-initiated (Esc) interrupts, | ||
| * where the RetryBarrier is intentionally suppressed. | ||
| */ | ||
| export const InterruptedBarrier: React.FC<InterruptedBarrierProps> = (props) => { | ||
| // resume() internally guards against re-entrancy while a resume is in flight, | ||
| // so we always keep the clickable label mounted (no button<->div remount flicker). | ||
| const { resume } = useResumeStream(props.workspaceId); | ||
|
ethanndickson marked this conversation as resolved.
Outdated
|
||
| return ( | ||
| <BaseBarrier | ||
| text="interrupted" | ||
| color="var(--color-interrupted)" | ||
| className={props.className} | ||
| onClick={() => void resume()} | ||
| ariaLabel="Continue interrupted response" | ||
| /> | ||
| ); | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.