Skip to content

Commit c6cd26b

Browse files
maria-rcksclaude
andcommitted
fix(web): toggle filter projects from the keyboard and keep older clients' scope
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b89f3a6 commit c6cd26b

3 files changed

Lines changed: 34 additions & 4 deletions

File tree

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2812,13 +2812,24 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
28122812
event.nativeEvent.isComposing ||
28132813
event.ctrlKey ||
28142814
event.altKey ||
2815-
event.metaKey ||
2816-
(event.key !== "ContextMenu" && !(event.shiftKey && event.key === "F10"))
2815+
event.metaKey
28172816
) {
28182817
return;
28192818
}
28202819
const scopeKey = highlightedProjectScopeKeyRef.current;
28212820
const project = scopeKey ? projectGroupByScopeKey.get(scopeKey) : null;
2821+
if (event.shiftKey && event.key === "Enter") {
2822+
if (!project) return;
2823+
event.preventDefault();
2824+
toggleProjectScopeKey(project.projectKey);
2825+
return;
2826+
}
2827+
if (
2828+
event.key !== "ContextMenu" &&
2829+
!(event.shiftKey && event.key === "F10")
2830+
) {
2831+
return;
2832+
}
28222833
if (project) handleProjectSettings(event, project);
28232834
}}
28242835
onChange={(event) =>
@@ -2837,6 +2848,9 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
28372848
key={item.value}
28382849
hideIndicator
28392850
value={item}
2851+
{...(project
2852+
? { "aria-selected": projectScopeKeys.includes(item.value) }
2853+
: {})}
28402854
onContextMenu={(event) => {
28412855
if (project) handleProjectSettings(event, project);
28422856
}}
@@ -2885,8 +2899,8 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
28852899
aria-hidden="true"
28862900
title={
28872901
projectScopeKeys.includes(item.value)
2888-
? `Remove ${project.displayName} from the filter (Shift+click)`
2889-
: `Add ${project.displayName} to the filter (Shift+click)`
2902+
? `Remove ${project.displayName} from the filter (Shift+click or Shift+Enter)`
2903+
: `Add ${project.displayName} to the filter (Shift+click or Shift+Enter)`
28902904
}
28912905
onPointerDown={(event) => event.stopPropagation()}
28922906
onClick={(event) => {

‎apps/web/src/uiStateStore.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ describe("uiStateStore persistence", () => {
231231
},
232232
defaultAdvertisedEndpointKey: "desktop-core:lan:http",
233233
sidebarProjectScopeKeys: [],
234+
sidebarProjectScopeKey: null,
234235
threadChangedFilesExpansionVersion: 2,
235236
threadChangedFilesExpandedById: {
236237
"environment:thread-1": {
@@ -256,6 +257,16 @@ describe("uiStateStore persistence", () => {
256257
expect(parsePersistedState(persisted).sidebarProjectScopeKeys).toEqual(keys);
257258
});
258259

260+
it("keeps a single-project scope readable by older clients", () => {
261+
persistState(makeUiState({ sidebarProjectScopeKeys: ["github.com/pingdotgg/t3code"] }));
262+
263+
const persisted = JSON.parse(
264+
localStorageStub.getItem(PERSISTED_STATE_KEY) ?? "{}",
265+
) as PersistedUiState;
266+
267+
expect(persisted.sidebarProjectScopeKey).toBe("github.com/pingdotgg/t3code");
268+
});
269+
259270
it("restores a single-project scope saved before multi-project filtering", () => {
260271
expect(
261272
parsePersistedState({ sidebarProjectScopeKey: "github.com/pingdotgg/t3code" })

‎apps/web/src/uiStateStore.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ export function persistState(state: UiState): void {
228228
threadLastVisitedAtById: state.threadLastVisitedAtById,
229229
defaultAdvertisedEndpointKey: state.defaultAdvertisedEndpointKey,
230230
sidebarProjectScopeKeys: state.sidebarProjectScopeKeys,
231+
// Older clients read only this field.
232+
sidebarProjectScopeKey:
233+
state.sidebarProjectScopeKeys.length === 1
234+
? (state.sidebarProjectScopeKeys[0] ?? null)
235+
: null,
231236
threadChangedFilesExpansionVersion: THREAD_CHANGED_FILES_EXPANSION_VERSION,
232237
threadChangedFilesExpandedById: state.threadChangedFilesExpandedById,
233238
pullRequestMergeMethod: state.pullRequestMergeMethod,

0 commit comments

Comments
 (0)