Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion frontend/src/components/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ export function ChatInput({
function handleKeyDown(e: KeyboardEvent) {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
handleSend();
if (running && onInterrupt) {
handleInterrupt();
} else {
handleSend();
}
}
}

Expand Down
8 changes: 5 additions & 3 deletions packages/client/__tests__/protocol-parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,15 +627,17 @@ describe('reconnected', () => {
expect(r.messagesActions).toContainEqual({ type: 'SET_RUNNING', running: false });
});

it('does not dispatch SET_RUNNING when active session is still running', () => {
it('dispatches SET_RUNNING true when active session is still running', () => {
const setWsRunning = vi.fn();
const state = makeState({ currentSessionId: 'sid-1' });
const r = parseServerMessage(
{ type: 'reconnected', sessions: [{ sessionId: 'sid-1', replayed: 0, running: true }] },
state,
makeCallbacks(),
makeCallbacks({ setWsRunning }),
POOL_KEY,
);
expect(r.messagesActions).not.toContainEqual(expect.objectContaining({ type: 'SET_RUNNING' }));
expect(r.messagesActions).toContainEqual({ type: 'SET_RUNNING', running: true });
expect(setWsRunning).toHaveBeenCalledWith(POOL_KEY, true);
});

it('no-ops when no currentSessionId', () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/client/src/protocol-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ export function parseServerMessage(
)
) {
const active = sessions.find((s) => s.sessionId === state.currentSessionId);
if (active && active.running === false) {
result.messagesActions.push({ type: 'SET_RUNNING', running: false });
if (active) {
result.messagesActions.push({ type: 'SET_RUNNING', running: active.running });
if (active.running) callbacks.setWsRunning?.(poolKey, true);
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 style: setWsRunning is only called when active.running is true, not when false — asymmetric with other message handlers (e.g. reattach_failed calls setWsRunning(false)). Since setWsRunning is deprecated and SET_RUNNING handles both directions, this is functionally fine, but could be simplified to callbacks.setWsRunning?.(poolKey, active.running) for symmetry. Low priority given the deprecation. [fixable]

}
}
callbacks.onReconnected?.();
Expand Down
Loading