Skip to content

Commit cf97dd1

Browse files
t3dotggclaude
andcommitted
fix(web): F6 bindings see terminal and preview state; first sidebar announcement is heard
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3c068ff commit cf97dd1

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

‎apps/web/src/components/AppSidebarLayout.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ function SidebarControl() {
375375
}
376376

377377
export function AppSidebarLayout({ children }: { children: ReactNode }) {
378+
const router = useRouter();
378379
const sidebarArea = useWorkspaceArea("sidebar", 0, "Threads");
379380
const legacySidebarEnabled = useLegacySidebarEnabled();
380381
const [sidebarRouteReveal] = useState<SidebarRouteReveal>(() => ({
@@ -453,7 +454,7 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
453454
{children}
454455
<BackgroundThreadAnnouncer />
455456
<SidebarControl />
456-
<WorkspaceNavigation />
457+
<WorkspaceNavigation readPanelContext={() => readRoutePanelsOpen(router)} />
457458
</SidebarProvider>
458459
</PanelAnimationSuppressionProvider>
459460
);

‎apps/web/src/components/WorkspaceNavigation.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useEffectEvent } from "react";
22
import { useAtomValue } from "@effect/atom-react";
33
import { primaryServerKeybindingsAtom } from "../state/server";
4-
import { resolveShortcutCommand } from "../keybindings";
4+
import { resolveShortcutCommand, type ShortcutMatchContext } from "../keybindings";
55
import { isTerminalFocused } from "../lib/terminalFocus";
66
import { isPreviewFocused } from "../lib/previewFocus";
77
import { isEditableFocused } from "../lib/editableFocus";
@@ -39,11 +39,17 @@ export function useWorkspacePageFocus(area: string, selector?: string) {
3939
}, [area, selector]);
4040
}
4141

42-
export function WorkspaceNavigation() {
42+
/** `readPanelContext` supplies route state for `terminalOpen` / `previewOpen` when-clauses. */
43+
export function WorkspaceNavigation({
44+
readPanelContext,
45+
}: {
46+
readPanelContext: () => Partial<ShortcutMatchContext>;
47+
}) {
4348
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
4449
const resolveCommand = useEffectEvent((event: KeyboardEvent) =>
4550
resolveShortcutCommand(event, keybindings, {
4651
context: {
52+
...readPanelContext(),
4753
terminalFocus: isTerminalFocused(),
4854
previewFocus: isPreviewFocused(),
4955
editableFocus: isEditableFocused(event.target),

‎apps/web/src/lib/accessibilityAnnouncements.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** Alternating atomic live regions allow repeated user actions to be announced, as in VS Code aria.ts. */
22
export function announceSidebarVisibility(open: boolean) {
33
let container = document.getElementById("workspace-visibility-alerts");
4+
const created = !container;
45
if (!container) {
56
container = document.createElement("div");
67
container.id = "workspace-visibility-alerts";
@@ -14,8 +15,13 @@ export function announceSidebarVisibility(open: boolean) {
1415
document.body.append(container);
1516
}
1617
const [first, second] = Array.from(container.children);
17-
const next = first!.textContent ? second! : first!;
18-
first!.textContent = "";
19-
second!.textContent = "";
20-
next.textContent = `Sidebar ${open ? "shown" : "hidden"}`;
18+
const write = () => {
19+
const next = first!.textContent ? second! : first!;
20+
first!.textContent = "";
21+
second!.textContent = "";
22+
next.textContent = `Sidebar ${open ? "shown" : "hidden"}`;
23+
};
24+
// Screen readers ignore text written in the same task that inserts its live region.
25+
if (created) setTimeout(write, 100);
26+
else write();
2127
}

0 commit comments

Comments
 (0)