Skip to content

Commit b48d689

Browse files
committed
fix(workbench): handle hunt sidebar and search toggles
1 parent ad816a9 commit b48d689

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

apps/workbench/src/features/activity-bar/__tests__/sidebar-panel.test.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ vi.mock("@/components/workbench/explorer/explorer-panel", () => ({
7373
),
7474
}));
7575

76+
vi.mock("../panels/findings-panel", () => ({
77+
FindingsPanel: () => <div>Findings Panel</div>,
78+
}));
79+
7680
describe("SidebarPanel explorer wiring", () => {
7781
beforeEach(() => {
7882
openFileByPath.mockReset();
@@ -142,4 +146,20 @@ describe("SidebarPanel explorer wiring", () => {
142146
);
143147
expect(deleteFile).toHaveBeenCalledWith("/workspace/project/policies/example.yml");
144148
});
149+
150+
it("renders the findings panel for the hunt activity-bar entry", () => {
151+
useActivityBarStore.setState({
152+
activeItem: "hunt",
153+
sidebarVisible: true,
154+
sidebarWidth: 320,
155+
});
156+
157+
render(
158+
<MemoryRouter>
159+
<SidebarPanel />
160+
</MemoryRouter>,
161+
);
162+
163+
expect(screen.getByText("Findings Panel")).toBeInTheDocument();
164+
});
145165
});

apps/workbench/src/features/activity-bar/components/sidebar-panel.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ function renderPanel(activeItem: ActivityBarItemId) {
7979
switch (activeItem) {
8080
case "heartbeat":
8181
return <HeartbeatPanel />;
82+
case "hunt":
83+
return <FindingsPanel />;
8284
case "sentinels":
8385
return <SentinelPanel />;
8486
case "findings":

apps/workbench/src/features/search/__tests__/search-panel-connected.test.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,24 @@ describe("SearchPanelConnected", () => {
143143
);
144144
});
145145
});
146+
147+
it("reruns the active search when options change", async () => {
148+
render(
149+
<MemoryRouter>
150+
<SearchPanelConnected />
151+
</MemoryRouter>,
152+
);
153+
154+
await userEvent.click(screen.getByRole("button", { name: "Aa" }));
155+
156+
await waitFor(() => {
157+
expect(searchInProjectNative).toHaveBeenCalledWith(
158+
"/workspace/project",
159+
"needle",
160+
true,
161+
false,
162+
false,
163+
);
164+
});
165+
});
146166
});

apps/workbench/src/features/search/components/search-panel.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,13 @@ export function SearchPanelConnected() {
339339
loading={loading}
340340
error={error}
341341
onQueryChange={actions.setQuery}
342-
onOptionToggle={(key) => actions.setOption(key, !options[key])}
342+
onOptionToggle={(key) => {
343+
const nextValue = !options[key];
344+
actions.setOption(key, nextValue);
345+
if (searchRootPath && query.trim()) {
346+
void actions.performSearch(searchRootPath);
347+
}
348+
}}
343349
onSearch={() => searchRootPath && actions.performSearch(searchRootPath)}
344350
onResultClick={async (match) => {
345351
if (!searchRootPath) return;

0 commit comments

Comments
 (0)