diff --git a/apps/web/src/app/(sandbox)/sessions/[sessionId]/SessionWorkspace.client.test.tsx b/apps/web/src/app/(sandbox)/sessions/[sessionId]/SessionWorkspace.client.test.tsx
index 9bf7413f9..47e5aa335 100644
--- a/apps/web/src/app/(sandbox)/sessions/[sessionId]/SessionWorkspace.client.test.tsx
+++ b/apps/web/src/app/(sandbox)/sessions/[sessionId]/SessionWorkspace.client.test.tsx
@@ -984,25 +984,25 @@ describe('SessionWorkspace', () => {
expect(screen.getByLabelText('Task prompt task-1')).toHaveFocus();
});
- it('opens tasks side-by-side when the Tasks rail item is middle-clicked', async () => {
+ it('opens tasks side-by-side without moving focus from the session prompt', async () => {
renderWorkspace({
isMobile: false,
workspaceWidth: 1280,
+ children: ,
sessionOverride: { tasks: [singleTask, secondTask] },
});
expect(await screen.findByLabelText('Full task task-1')).toBeVisible();
fireEvent.click(screen.getByRole('button', { name: 'Close panel task-1' }));
fireEvent.click(screen.getByRole('button', { name: 'Close panel task-2' }));
-
- fireEvent(
- screen.getByRole('button', { name: 'Tasks' }),
- new MouseEvent('auxclick', { bubbles: true, button: 1 }),
- );
+ const sessionPrompt = screen.getByLabelText('Session prompt');
+ sessionPrompt.focus();
+ fireEvent.click(screen.getByRole('button', { name: 'Tasks' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Open side-by-side' }));
expect(screen.getByLabelText('Full task task-1')).toBeVisible();
expect(screen.getByLabelText('Full task task-2')).toBeVisible();
- expect(screen.getByText('Session transcript')).toBeVisible();
+ expect(sessionPrompt).toHaveFocus();
});
it('moves focus between visible prompt inputs with Alt+Arrow keys', async () => {
@@ -1050,7 +1050,7 @@ describe('SessionWorkspace', () => {
expect(sessionPrompt).toHaveFocus();
});
- it('focuses the first task when several task panels open initially', async () => {
+ it('keeps session prompt focus when task panels open initially', async () => {
const thirdTask = {
...singleTask,
taskId: 'task-3',
@@ -1059,17 +1059,17 @@ describe('SessionWorkspace', () => {
renderWorkspace({
isMobile: false,
workspaceWidth: 1600,
- children: ,
+ children: ,
sessionOverride: { tasks: [singleTask, secondTask, thirdTask] },
});
expect(await screen.findByLabelText('Task prompt task-3')).toBeVisible();
await waitFor(() =>
- expect(screen.getByLabelText('Task prompt task-1')).toHaveFocus(),
+ expect(screen.getByLabelText('Session prompt')).toHaveFocus(),
);
});
- it('opens and focuses the first task when several delegated tasks start', async () => {
+ it('opens new delegated tasks without moving session prompt focus', async () => {
const thirdTask = {
...singleTask,
taskId: 'task-3',
@@ -1083,6 +1083,8 @@ describe('SessionWorkspace', () => {
});
expect(await screen.findByLabelText('Full task task-1')).toBeVisible();
+ const sessionPrompt = screen.getByLabelText('Session prompt');
+ sessionPrompt.focus();
fireEvent.click(screen.getByRole('button', { name: 'Tasks' }));
expect(screen.getByRole('heading', { name: 'Tasks' })).toBeVisible();
act(() => {
@@ -1094,9 +1096,7 @@ describe('SessionWorkspace', () => {
expect(await screen.findByLabelText('Full task task-2')).toBeVisible();
expect(screen.getByLabelText('Full task task-3')).toBeVisible();
- await waitFor(() =>
- expect(screen.getByLabelText('Task prompt task-2')).toHaveFocus(),
- );
+ await waitFor(() => expect(sessionPrompt).toHaveFocus());
});
it('replaces the URL-selected task when a task card opens at one-panel capacity', () => {
diff --git a/apps/web/src/app/(sandbox)/sessions/[sessionId]/use-session-workspace-panels.client.test.ts b/apps/web/src/app/(sandbox)/sessions/[sessionId]/use-session-workspace-panels.client.test.ts
index 867761083..a1f96fb54 100644
--- a/apps/web/src/app/(sandbox)/sessions/[sessionId]/use-session-workspace-panels.client.test.ts
+++ b/apps/web/src/app/(sandbox)/sessions/[sessionId]/use-session-workspace-panels.client.test.ts
@@ -107,7 +107,7 @@ describe('sessionWorkspacePanelReducer', () => {
});
expect(seeded.taskPanelIds).toEqual(['task-2', 'task-3']);
- expect(seeded.promptFocusTaskId).toBe('task-1');
+ expect(seeded.promptFocusTaskId).toBeNull();
expect(getOrderedSessionTaskPanelIds(seeded, 'task-1')).toEqual([
'task-1',
'task-2',
@@ -138,12 +138,12 @@ describe('sessionWorkspacePanelReducer', () => {
{
utilityPanel: null,
expectedUtilityPanel: null,
- expectedFocus: 'task-3',
+ expectedFocus: null,
},
{
utilityPanel: { kind: 'tasks' } as const,
expectedUtilityPanel: null,
- expectedFocus: 'task-3',
+ expectedFocus: null,
},
{
utilityPanel: { kind: 'info' } as const,
@@ -196,7 +196,7 @@ describe('sessionWorkspacePanelReducer', () => {
utilityPanel: null,
taskPanelIds: ['task-1', 'task-3'],
taskArtifacts: {},
- promptFocusTaskId: 'task-2',
+ promptFocusTaskId: null,
});
});
diff --git a/apps/web/src/app/(sandbox)/sessions/[sessionId]/use-session-workspace-panels.ts b/apps/web/src/app/(sandbox)/sessions/[sessionId]/use-session-workspace-panels.ts
index 78daeec73..fa6ba343e 100644
--- a/apps/web/src/app/(sandbox)/sessions/[sessionId]/use-session-workspace-panels.ts
+++ b/apps/web/src/app/(sandbox)/sessions/[sessionId]/use-session-workspace-panels.ts
@@ -136,10 +136,6 @@ export function sessionWorkspacePanelReducer(
return {
...state,
taskPanelIds,
- promptFocusTaskId:
- action.selectedTaskId ??
- action.taskIds.find((taskId) => taskId !== action.selectedTaskId) ??
- null,
};
}
case 'add-tasks': {
@@ -157,15 +153,12 @@ export function sessionWorkspacePanelReducer(
);
insertionIndex += 1;
}
- const shouldFocus =
+ const shouldShowTaskPanels =
state.utilityPanel === null || state.utilityPanel.kind === 'tasks';
return {
...state,
- utilityPanel: shouldFocus ? null : state.utilityPanel,
+ utilityPanel: shouldShowTaskPanels ? null : state.utilityPanel,
taskPanelIds,
- promptFocusTaskId: shouldFocus
- ? (action.taskIds[0] ?? state.promptFocusTaskId)
- : state.promptFocusTaskId,
};
}
case 'open-task': {
@@ -216,7 +209,6 @@ export function sessionWorkspacePanelReducer(
(taskId) => taskId !== action.selectedTaskId,
),
taskArtifacts: {},
- promptFocusTaskId: action.selectedTaskId ?? action.taskIds[0] ?? null,
};
case 'show-main':
return {