Skip to content

Commit 002693c

Browse files
author
root
committed
fix(web): restore mobile supervisor sheet objective state
1 parent 92ba46b commit 002693c

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

packages/web/src/features/supervisor/actions/use-objective-dialog-state.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export function useObjectiveDialogState({
3434
const dispatch = useAtomValue(dispatchCommandAtom);
3535
const t = useTranslation();
3636

37-
const supervisor = dialog.sessionId ? supervisors.get(dialog.sessionId) : undefined;
37+
const effectiveSessionId = sessionId ?? dialog.sessionId;
38+
const supervisor = effectiveSessionId ? supervisors.get(effectiveSessionId) : undefined;
3839
const isVisible = dialog.open && (!sessionId || dialog.sessionId === sessionId);
3940
const mode = dialog.mode;
4041
const copy = {

packages/web/src/features/supervisor/views/mobile/mobile-supervisor-sheet.test.tsx

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
1+
import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
22
import userEvent from "@testing-library/user-event";
33
import { createStore, Provider } from "jotai";
44
import { describe, expect, it, vi } from "vitest";
@@ -8,6 +8,49 @@ import { supervisorDialogAtom, supervisorsAtom } from "../../atoms";
88
import { MobileSupervisorSheet } from "./mobile-supervisor-sheet";
99

1010
describe("MobileSupervisorSheet", () => {
11+
it("renders the current session supervisor details in the root sheet", () => {
12+
const store = createStore();
13+
14+
window.localStorage.setItem("ui.locale", JSON.stringify("en"));
15+
store.set(localeAtom, "en");
16+
store.set(wsClientAtom, { sendCommand: vi.fn() } as never);
17+
store.set(
18+
supervisorsAtom,
19+
new Map([
20+
[
21+
"sess-1",
22+
{
23+
id: "sup-1",
24+
sessionId: "sess-1",
25+
workspaceId: "ws-1",
26+
state: "idle",
27+
objective: "Reduce mobile regression bugs",
28+
evaluatorProviderId: "claude",
29+
cycles: [],
30+
createdAt: 1,
31+
updatedAt: 1,
32+
},
33+
],
34+
])
35+
);
36+
37+
render(
38+
<Provider store={store}>
39+
<MobileSupervisorSheet sessionId="sess-1" workspaceId="ws-1" onClose={vi.fn()} />
40+
</Provider>
41+
);
42+
43+
const rootActions = document.querySelector(".mobile-supervisor-sheet__actions");
44+
expect(rootActions).not.toBeNull();
45+
46+
expect(screen.getByText("Reduce mobile regression bugs")).toBeInTheDocument();
47+
expect(within(rootActions as HTMLElement).getByRole("button", { name: "Edit Objective" })).toBeInTheDocument();
48+
expect(
49+
within(rootActions as HTMLElement).getByRole("button", { name: "Disable Supervisor" })
50+
).toBeInTheDocument();
51+
expect(screen.queryByText("Supervisor is not enabled")).not.toBeInTheDocument();
52+
});
53+
1154
it("opens the enable flow inside the same sheet without rendering a second overlay", async () => {
1255
const sendCommand = vi.fn().mockResolvedValue({ id: "sup-1" });
1356
const store = createStore();

0 commit comments

Comments
 (0)