@devries-cameron20 / t3code Mirror · read-only / commits / 7389423507
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 00:45 UTC

fix(web): screen readers hear the add-project submit shortcut (#32576)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 10, 2026 at 08:16 UTC 7389423507aff8f931fdd41fd0b752589d2d810e
3 files changed +61 -9
apps/web/src/components/CommandPalette.composition.browser.test.tsx
+45 -1
@@ -2,11 +2,17 @@ import { describe, expect, it, vi } from "vite-plus/test";
2 import { page, userEvent } from "vite-plus/test/browser";
3 import { DEFAULT_RESOLVED_KEYBINDINGS } from "@t3tools/shared/keybindings";
4 import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings";
5 +import { AuthOrchestrationOperateScope, AuthSourceControlWriteScope } from "@t3tools/contracts";
6 import { act, render } from "../../test/render";
7 import { CommandPalette } from "./CommandPalette";
8 import { openCommandPalette } from "../commandPaletteBus";
9 import { primaryServerKeybindingsAtom } from "../state/server";
10
11 +const scopes = vi.hoisted(() => ({ denied: undefined as string | undefined }));
12 +const setup = (deniedScope?: string) => {
13 + scopes.denied = deniedScope;
14 +};
15 +
16 vi.mock("@effect/atom-react", async (original) => ({
17 ...(await original<typeof import("@effect/atom-react")>()),
18 useAtomValue: (atom: unknown) =>
@@ -85,7 +91,7 @@ vi.mock("../state/queries", async (original) => ({
91 }));
92 vi.mock("../state/session", async (original) => ({
93 ...(await original<typeof import("../state/session")>()),
88 - useEnvironmentScope: () => true,
94 + useEnvironmentScope: (_environmentId: unknown, scope: string) => scope !== scopes.denied,
95 readEnvironmentScope: () => true,
96 }));
97 vi.mock("../state/filesystem", async (original) => ({
@@ -106,6 +112,7 @@ describe.each(["repository", "folder", "destination"] as const)("add-project %s"
112 { isComposing: true, keyCode: 13 },
113 { isComposing: false, keyCode: 229 },
114 ])("keeps Enter in the input during composition: %j", async (composition) => {
115 + setup();
116 await using _screen = await render(<CommandPalette>{null}</CommandPalette>);
117 await act(() => openCommandPalette({ open: "add-project" }));
118 await page.getByText(step === "folder" ? "Local folder" : "Git URL", { exact: true }).click();
@@ -135,7 +142,44 @@ describe.each(["repository", "folder", "destination"] as const)("add-project %s"
142 });
143 });
144
145 +it.each([
146 + { step: "folder", source: "Local folder", keys: "", description: /^(?!.*(Ctrl|⌘)).*Add.*Enter/ },
147 + {
148 + step: "highlighted folder",
149 + source: "Local folder",
150 + keys: "{ArrowDown}",
151 + description: /Add.*(Ctrl|⌘) Enter/,
152 + },
153 + { step: "repository", source: "Git URL", keys: "", description: /Continue.*Enter/ },
154 + { step: "new project", source: "New project", keys: "", description: /Create.*Enter/ },
155 + {
156 + step: "permission-blocked folder",
157 + source: "Local folder",
158 + keys: "",
159 + deniedScope: AuthOrchestrationOperateScope,
160 + description: "This connection cannot add projects.",
161 + },
162 + {
163 + step: "permission-blocked destination",
164 + source: "Git URL",
165 + keys: "https://example.com/team/project.git{Enter}",
166 + deniedScope: AuthSourceControlWriteScope,
167 + description: "This connection needs permission to write source control and add projects.",
168 + },
169 +])(
170 + "tells screen readers how to submit the $step step",
171 + async ({ source, keys, deniedScope, description }) => {
172 + setup(deniedScope);
173 + await using _screen = await render(<CommandPalette>{null}</CommandPalette>);
174 + await act(() => openCommandPalette({ open: "add-project" }));
175 + await page.getByText(source, { exact: true }).click();
176 + if (keys) await userEvent.keyboard(keys);
177 + await expect.element(page.getByRole("combobox")).toHaveAccessibleDescription(description);
178 + },
179 +);
180 +
181 it("keeps the caret in place when an edit briefly makes the folder path not a path", async () => {
182 + setup();
183 await using _screen = await render(<CommandPalette>{null}</CommandPalette>);
184 await act(() => openCommandPalette({ open: "add-project" }));
185 await page.getByText("Local folder", { exact: true }).click();
apps/web/src/components/CommandPalette.tsx
+14 -8
@@ -82,6 +82,7 @@ import { openThreadFind } from "./chat/threadFindStore";
82 import {
83 useDeferredValue,
84 useEffect,
85 + useId,
86 useReducer,
87 useRef,
88 useState,
@@ -2784,9 +2785,17 @@ function OpenCommandPaletteDialog(props: {
2785 await handleAddProject(pickedPath);
2786 };
2787
2788 + const submitButtonId = useId();
2789 + const browseSubmitLabel =
2790 + isCloneDestinationStep && !canCloneProject
2791 + ? "This connection needs permission to write source control and add projects."
2792 + : canCreateProject
2793 + ? `${submitActionLabel} (${addShortcutLabel})`
2794 + : "This connection cannot add projects.";
2795 const inputAccessory =
2796 newProjectFlow !== null ? (
2797 <CommandPaletteSubmitButton
2798 + id={submitButtonId}
2799 label={isCreatingNewProject ? "Creating" : "Create"}
2800 shortcutLabel={createShortcutLabel}
2801 ariaLabel={`Create (${createShortcutLabel})`}
@@ -2798,6 +2807,7 @@ function OpenCommandPaletteDialog(props: {
2807 />
2808 ) : addProjectCloneFlow?.step === "repository" ? (
2809 <CommandPaletteSubmitButton
2810 + id={submitButtonId}
2811 label={isRemoteProjectPending ? "Working" : remoteProjectButtonLabel}
2812 shortcutLabel="Enter"
2813 ariaLabel={`${remoteProjectButtonLabel ?? "Continue"} (Enter)`}
@@ -2809,16 +2819,11 @@ function OpenCommandPaletteDialog(props: {
2819 />
2820 ) : isBrowsing ? (
2821 <CommandPaletteSubmitButton
2822 + id={submitButtonId}
2823 label={isCloneDestinationStep && isRemoteProjectPending ? "Cloning" : submitActionLabel}
2824 shortcutLabel={addShortcutLabel}
2814 - ariaLabel={`${submitActionLabel} (${addShortcutLabel})`}
2815 - tooltip={
2816 - isCloneDestinationStep && !canCloneProject
2817 - ? "This connection needs permission to write source control and add projects."
2818 - : canCreateProject
2819 - ? `${submitActionLabel} (${addShortcutLabel})`
2820 - : "This connection cannot add projects."
2821 - }
2825 + ariaLabel={browseSubmitLabel}
2826 + tooltip={browseSubmitLabel}
2827 disabled={
2828 !canCreateProject ||
2829 !canCreateProjectInEnvironment(browseEnvironment?.connection.phase) ||
@@ -2886,6 +2891,7 @@ function OpenCommandPaletteDialog(props: {
2891 })
2892 : undefined,
2893 placeholder: inputPlaceholder,
2894 + "aria-describedby": inputAccessory ? submitButtonId : undefined,
2895 ...(isSubmenu
2896 ? {
2897 startAddon: (
apps/web/src/components/CommandPaletteAddProject.tsx
+2
@@ -34,6 +34,7 @@ export function sourceControlHostIcon(
34
35 /** The input's trailing submit button for the add-project, clone, and new-project flows. */
36 export function CommandPaletteSubmitButton(props: {
37 + readonly id: string;
38 readonly label: ReactNode;
39 readonly shortcutLabel: string;
40 readonly ariaLabel: string;
@@ -46,6 +47,7 @@ export function CommandPaletteSubmitButton(props: {
47 <TooltipTrigger
48 render={
49 <Button
50 + id={props.id}
51 variant="outline"
52 size="xs"
53 className="absolute inset-e-2.5 top-1/2 -translate-y-1/2"