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
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function ChannelHeader({
managerRuntime?: ManagerRuntimeSessionReadback | null;
mobileNavigationOpen?: boolean;
onOpenGoalCapabilities?: () => void;
onOpenGoalDetails?: () => void;
onOpenGoalDetails?: (openingControl: HTMLButtonElement) => void;
onOpenAllWork?: () => void;
allWorkOpen?: boolean;
onOpenManagerChat?: () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,15 @@ export function ContextDrawer({ agents, attentionHistory = [], onSelectAttention
}
}, [authoritativeSubagentConfiguration, verifiedSubagentConfiguration]);

const openingControl = selection.kind === "goal" ? selection.openingControl : undefined;
useEffect(() => {
const activeElement = document.activeElement;
if (activeElement instanceof HTMLElement && !drawerRef.current?.contains(activeElement)) {
returnFocusRef.current = activeElement;
const opener = openingControl ?? document.activeElement;
if (opener instanceof HTMLElement && !drawerRef.current?.contains(opener)) {
returnFocusRef.current = opener;
}
const frame = window.requestAnimationFrame(() => titleRef.current?.focus());
return () => window.cancelAnimationFrame(frame);
}, [selectionIdentity]);
}, [openingControl, selectionIdentity]);

useEffect(() => {
if (!taskInspectorModal || drawerRef.current?.contains(document.activeElement)) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function useGoalWorkspaceDigest(goal: WorkspaceGoal | null, userTodos: Wo
}, [goal, userTodos, items, map]);
}

export function GoalMastheadIdentity({ goal, onOpenWorkspace, onOpenDetails }: { goal: WorkspaceGoal; onOpenWorkspace: () => void; onOpenDetails?: () => void }) {
export function GoalMastheadIdentity({ goal, onOpenWorkspace, onOpenDetails }: { goal: WorkspaceGoal; onOpenWorkspace: () => void; onOpenDetails?: (openingControl: HTMLButtonElement) => void }) {
const { t } = useWorkspaceI18n();
const agents = (goal.agentLanes ?? []).map((lane) => lane.label);
const context = [
Expand All @@ -69,7 +69,11 @@ export function GoalMastheadIdentity({ goal, onOpenWorkspace, onOpenDetails }: {
<span className="personal-sr-only" aria-current="page">{goal.title}</span>

</nav>
<div className="goal-masthead-title"><h1>{goal.title}</h1>{onOpenDetails ? <button type="button" onClick={onOpenDetails} aria-label={t("masthead.completeTitle")} title={t("masthead.completeTitle")}><Info aria-hidden size={16} /></button> : null}</div>
<div className="goal-masthead-title">
<h1>{goal.title}</h1>
{onOpenDetails ? <button type="button" onClick={(event) => onOpenDetails(event.currentTarget)}
aria-label={t("masthead.completeTitle")} title={t("masthead.completeTitle")}><Info aria-hidden size={16} /></button> : null}
</div>
{context.length ? <p className="goal-masthead-context" title={agents.join(", ")}>{context.join(" · ")}</p> : null}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function GoalOverview({ active, goal, items, userTodos, readOnly, onOpenD
active: boolean; goal: WorkspaceGoal; items: WorkspaceTimelineItem[]; userTodos: WorkspaceModel["userTodos"];
selectedTodoId: string | null; board: ReactNode; historyRefreshRevision: number;
proposals: Record<string, WorkspaceActionPreview>; onPreview: (request: WorkspaceActionPreviewRequest) => Promise<WorkspaceActionPreview>;
readOnly: boolean; onOpenDetails: () => void; onSelect: (selection: WorkspaceDrawerSelection | null) => void; onView: (view: WorkspaceGoalTab) => void;
readOnly: boolean; onOpenDetails: (openingControl: HTMLButtonElement) => void; onSelect: (selection: WorkspaceDrawerSelection | null) => void; onView: (view: WorkspaceGoalTab) => void;
}) {
const { t, locale } = useWorkspaceI18n();
const copy = locale === "zh-CN" ? {
Expand Down Expand Up @@ -88,7 +88,7 @@ export function GoalOverview({ active, goal, items, userTodos, readOnly, onOpenD
{progressNote ? <div className="goal-overview-agent-note"><h3>{copy.agentSummary}</h3><p className="goal-overview-note">{progressNote}</p></div> : null}
</details> : null}
<div className="goal-overview-heading">
<button onClick={onOpenDetails} type="button"><Info aria-hidden size={14} />{copy.details}</button>
<button onClick={(event) => onOpenDetails(event.currentTarget)} type="button"><Info aria-hidden size={14} />{copy.details}</button>
{run ? <button className="goal-overview-run" type="button" onClick={() => onSelect({ kind: "run", item: run.run })}>{copy.execution}<ArrowRight aria-hidden size={15} /></button> : null}
</div>
<WorkerReadback goal={goal} zh={locale === "zh-CN"} onViewTasks={() => onView("tasks")}/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ export type WorkspaceAgentOption = {

export type WorkspaceDrawerSelection =
| { item: WorkspaceAttention; kind: "attention" }
| { item: WorkspaceGoal; kind: "goal" }
| { item: WorkspaceGoal; kind: "goal"; openingControl?: HTMLButtonElement }
| { item: WorkspaceTodo; kind: "todo" }
| { item: WorkspaceRun; kind: "run" }
| { item: WorkspaceOutput; kind: "output" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1710,7 +1710,7 @@ export function PersonalWorkspacePage({
if (selection?.kind === "attention") return { kind: "attention", item: refreshAttention(selection.item, model.attentionHistory ?? model.userTodos) };
if (selection?.kind === "goal") {
const currentGoal = workspaceGoals.find((goal) => goal.goalId === selection.item.goalId);
return currentGoal ? { item: currentGoal, kind: "goal" } : selection;
return currentGoal ? { ...selection, item: currentGoal } : selection;
}
if (selection?.kind === "todo") {
const goal = workspaceGoals.find((goal) => goal.goalId === selection.item.goalId);
Expand Down Expand Up @@ -3021,7 +3021,7 @@ export function PersonalWorkspacePage({
mobileNavigationOpen={mobileSidebarOpen}
allWorkOpen={railScope === selectionScope}
onOpenAllWork={selectedGoal ? () => {setSelectedGoalTab("overview"); setRailScope(selectionScope);} : undefined}
onOpenGoalDetails={selectedGoal ? () => setSelection({ kind: "goal", item: selectedGoal }) : undefined}
onOpenGoalDetails={selectedGoal ? (openingControl) => setSelection({ kind: "goal", item: selectedGoal, openingControl }) : undefined}
onOpenGoalCapabilities={selectedGoal && !readOnly ? () => openSettings({ goalId: selectedGoal.goalId, kind: "settings", tab: "capabilities" }) : undefined}
onOpenManagerSettings={!readOnly ? () => openSettings({ kind: "settings", tab: "steward" }) : undefined}
onRefresh={callbacks.onRefresh && !runtimeSourceUnavailable ? () => void refreshWorkspace() : undefined}
Expand Down Expand Up @@ -3111,7 +3111,7 @@ export function PersonalWorkspacePage({
overview: null, tasks: null, research: researchPanel, files: null, chat: null,
} : {
overview: <GoalOverview sinceYouLooked={sinceYouLooked?.goalId === selectedGoal.goalId ? sinceYouLooked.delta : null} onMarkSeen={markSeen} onOpenAgentConversation={callbacks.onSelectWorkAgent} railOpen={railScope === selectionScope} onCloseRail={() => setRailScope(null)} digest={workspaceDigest} review={workspaceReview} active={!settingsOpen && selectedGoalTab === "overview"} goal={selectedGoal} items={items} userTodos={model.userTodos} readOnly={readOnly}
onOpenDetails={() => setSelection({ kind: "goal", item: selectedGoal })} onSelect={setSelection} onView={setSelectedGoalTab}
onOpenDetails={(openingControl) => setSelection({ kind: "goal", item: selectedGoal, openingControl })} onSelect={setSelection} onView={setSelectedGoalTab}
selectedTodoId={drawerSelection?.kind === "todo" ? drawerSelection.item.todoId : null}
board={taskBoard(!settingsOpen && selectedGoalTab === "overview")}
historyRefreshRevision={historyRefreshRevision} proposals={proposals} onPreview={createPreview} />,
Expand Down
45 changes: 41 additions & 4 deletions examples/personal-workspace-browser/goal-workspace-m2.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,18 @@ async function verifyRemoteSelection(browser, url) {
await page.getByRole("tooltip").getByText("此来源仅提供状态快照,无法在这里读取或回复原会话。",{exact:true}).waitFor();
await page.keyboard.press("Escape");
assert.equal(await page.getByRole("region", {name:"Agent 工作会话",exact:true}).getByRole("textbox").count(),0);
await page.setViewportSize({width:390,height:844});
const mastheadInfo = page.getByRole("button",{name:"查看完整 Goal",exact:true});
await page.locator('.personal-goal-tabs button[aria-current="page"]').focus();
await mastheadInfo.dispatchEvent("click");
const conversationDrawer = page.locator('.personal-context-drawer[data-context-kind="goal"]');
await page.waitForFunction(() => document.activeElement?.id === "personal-drawer-title");
await conversationDrawer.locator(".personal-drawer-close").click();
await conversationDrawer.waitFor({state:"detached"});
await page.waitForFunction(() => document.activeElement !== document.body);
assert.ok(await mastheadInfo.evaluate(button => button === document.activeElement),
"The close button returns focus to the Goal button in the conversation masthead");
await page.screenshot({path:resolve(outputDir,"goal-detail-masthead-return.png"),animations:"disabled"});
assert.deepEqual(localOwnerReads,[],"Remote deep link caused local owner reads");
} finally {await session.close();}
}
Expand All @@ -422,7 +434,10 @@ async function verifyGoalDetails(page, snapshot) {
snapshot.usage_summary.goals = [];
await page.getByRole('button',{name:'刷新状态',exact:true}).click();
const info = page.getByRole('button',{name:'Goal 信息',exact:true});
await info.click();
const overviewTab = page.locator('.personal-goal-tabs button[aria-current="page"]');
// Pointer activation on macOS can open details without focusing the button.
await overviewTab.focus();
await info.dispatchEvent('click');
const drawer = page.locator('.personal-context-drawer[data-context-kind="goal"]');
const acceptance = drawer.locator('.personal-goal-acceptance');
const usage = drawer.locator('.personal-goal-detail-usage');
Expand Down Expand Up @@ -461,9 +476,31 @@ async function verifyGoalDetails(page, snapshot) {
await page.screenshot({path:resolve(outputDir,'goal-detail-expanded-desktop.png'),animations:'disabled'});
await page.keyboard.press('Escape');
await drawer.waitFor({state:'detached'});
// The reader owner restores focus in its scheduled animation frame.
await page.waitForFunction(() => document.activeElement?.matches('button') && document.activeElement.textContent.includes('Goal 信息'));
assert.ok(await info.evaluate(node=>node===document.activeElement),'Closing the Goal reader returns to its exact trigger');
await page.waitForFunction(() => document.activeElement !== document.body);
await page.screenshot({path:resolve(outputDir,'goal-detail-overview-return.png'),animations:'disabled'});
assert.ok(await info.evaluate(node=>node===document.activeElement),'Escape returns to Goal information even when opening did not move focus');

await info.focus();
await page.keyboard.press('Enter');
await page.waitForFunction(() => document.activeElement?.id === 'personal-drawer-title');
await info.evaluate(button => { button.disabled = true; });
await page.keyboard.press('Escape');
await drawer.waitFor({state:'detached'});
await page.waitForFunction(() => document.activeElement !== document.body);
assert.ok(await overviewTab.evaluate(tab => tab === document.activeElement),
'Closing a reader whose opener is unavailable returns to the active Goal tab');
await info.evaluate(button => { button.disabled = false; });

await info.click();
await drawer.waitFor();
await overviewTab.evaluate(tab => {
document.querySelector('.personal-context-drawer .personal-drawer-close').click();
tab.focus();
});
await drawer.waitFor({state:'detached'});
await page.evaluate(() => new Promise(resolve => requestAnimationFrame(resolve)));
assert.ok(await overviewTab.evaluate(tab => tab === document.activeElement),
'Closing the reader preserves focus moved outside the drawer');

snapshot.usage_summary.goals = [{goal_id:source.id,cost_usd_24h:0,duration_ms_7d:7_200_000,input_tokens_7d:12500}];
await page.getByRole('button',{name:'刷新状态',exact:true}).click(); await info.click();
Expand Down
Loading