Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
43 changes: 43 additions & 0 deletions packages/web-shell/client/App.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,49 @@
overflow: visible;
}

.missingSessionState {
flex: 1 1 auto;
min-height: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 18px;
padding: 24px;
color: var(--foreground);
font-family: var(--font-sans);
}

.missingSessionMessage {
font-size: inherit;
font-weight: inherit;
line-height: 1.4;
text-align: center;
}

.missingSessionButton {
min-width: 120px;
min-height: 38px;
padding: 0 16px;
border: 1px solid var(--border);
border-radius: var(--radius);
background: var(--primary);
color: var(--primary-foreground);
font: inherit;
font-size: 14px;
cursor: pointer;
transition:
border-color 120ms ease,
opacity 120ms ease;
}

.missingSessionButton:hover,
.missingSessionButton:focus-visible {
border-color: color-mix(in srgb, var(--foreground) 24%, var(--border));
opacity: 0.9;
outline: none;
}

.footer {
position: relative;
width: min(100%, var(--chat-shell-width));
Expand Down
47 changes: 46 additions & 1 deletion packages/web-shell/client/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createRoot, type Root } from 'react-dom/client';
type StreamingState = 'idle' | 'responding';

type MockConnection = {
status: 'connected';
status: 'connected' | 'disconnected';
sessionId: string | undefined;
clientId: string;
displayName: string | undefined;
Expand All @@ -18,6 +18,8 @@ type MockConnection = {
capabilities: { qwenCodeVersion: string; features: string[] };
loadingTranscript: boolean;
catchingUp: boolean;
error?: string;
errorStatus?: number;
};

type ChatEditorTestProps = {
Expand Down Expand Up @@ -60,6 +62,10 @@ const {
mockSessionActions: {
sendPrompt: vi.fn().mockResolvedValue(undefined),
createSession: vi.fn().mockResolvedValue({ sessionId: 'session-1' }),
attachSession: vi.fn().mockResolvedValue(undefined),
closeSession: vi.fn().mockResolvedValue(undefined),
clearSession: vi.fn().mockResolvedValue(undefined),
loadSession: vi.fn().mockResolvedValue(undefined),
refreshCommands: vi.fn().mockResolvedValue(undefined),
setModel: vi.fn().mockResolvedValue(undefined),
setApprovalMode: vi.fn().mockResolvedValue(undefined),
Expand Down Expand Up @@ -316,7 +322,10 @@ beforeEach(() => {
}),
});
mockConnection.sessionId = 'session-1';
mockConnection.status = 'connected';
mockConnection.displayName = 'Session One';
mockConnection.error = undefined;
mockConnection.errorStatus = undefined;
mockConnection.loadingTranscript = false;
mockConnection.catchingUp = false;
testState.prompt = 'hello';
Expand All @@ -335,6 +344,10 @@ beforeEach(() => {
mockSessionActions.createSession.mockResolvedValue({
sessionId: 'session-1',
});
mockSessionActions.attachSession.mockResolvedValue(undefined);
mockSessionActions.closeSession.mockResolvedValue(undefined);
mockSessionActions.clearSession.mockResolvedValue(undefined);
mockSessionActions.loadSession.mockResolvedValue(undefined);
mockSessionActions.refreshCommands.mockResolvedValue(undefined);
mockSessionActions.setModel.mockResolvedValue(undefined);
mockSessionActions.setApprovalMode.mockResolvedValue(undefined);
Expand Down Expand Up @@ -365,6 +378,38 @@ afterEach(() => {
});

describe('App session callbacks', () => {
it.each([404, 410])(
'shows a missing-session empty state with a new-session action for %d',
async (status) => {
mockConnection.status = 'disconnected';
mockConnection.sessionId = undefined;
mockConnection.error = 'Session load failed';
mockConnection.errorStatus = status;

const onSessionIdChange = vi.fn();
const { container } = renderApp({
onSessionIdChange,
});
await flush();

expect(container.textContent).toContain('Current session does not exist');
expect(container.querySelector('[data-testid="submit"]')).toBeNull();
expect(onSessionIdChange).not.toHaveBeenCalledWith(undefined);

await act(async () => {
Array.from(container.querySelectorAll('button'))
.find((button) => button.textContent === 'New session')
?.click();
await Promise.resolve();
});

expect(mockSessionActions.clearSession).toHaveBeenCalledTimes(1);
expect(mockSessionActions.createSession).not.toHaveBeenCalled();
expect(mockSessionActions.attachSession).not.toHaveBeenCalled();
expect(onSessionIdChange).toHaveBeenCalledWith(undefined);
},
);

it('gates direct submissions and dispatches submit events with delayed sidebar reload', async () => {
vi.useFakeTimers();
const onSubmitBefore = vi.fn().mockResolvedValue(undefined);
Expand Down
Loading
Loading