Q185: switching company carries no focus, search or form from the previous company

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-09 07:51:39 -04:00
1 parent 72cf57ce3a
commit f5526b075c
3 files changed
+47 -3

No files matched your search

+4 -2
View File
@@ -29,7 +29,8 @@ const isRoute = oneOf(ROUTE_IDS);
export function App() {
const { snapshot, syncFailure, actions } = useSnapshot();
const [routeChoice, setRoute] = useState<RouteId | null>(null);
const [focus, setFocus] = useState<Focus | null>(null);
// A focus belongs to the company it was opened in; another company's page never receives it.
const [focusChoice, setFocus] = useState<{ orgId: string | null; focus: Focus } | null>(null);
// Leaving a page with input that would be lost asks first.
const [leaving, setLeaving] = useState<{ proceed: () => void } | null>(null);
const requestLeave = (proceed: () => void) => {
@@ -40,7 +41,7 @@ export function App() {
const navigate = (next: RouteId, nextFocus?: Focus) => requestLeave(() => {
setRoute(next);
writeViewState("route", next);
setFocus(nextFocus ?? null);
setFocus(nextFocus ? { orgId: snapshot?.activeOrgId ?? null, focus: nextFocus } : null);
});
const avatarDirectory = useMemo(() => {
// Scope the directory to the active organization: names are only unique
@@ -97,6 +98,7 @@ export function App() {
);
}
const focus = focusChoice && focusChoice.orgId === snapshot.activeOrgId ? focusChoice.focus : null;
const pageProps = { snapshot, actions, navigate, focus };
const page = {
home: <HomePage {...pageProps} />,
+2 -1
View File
@@ -123,7 +123,7 @@ export function Shell({
</button>
</div>
</aside>
{profileOpen && <ProfileDialog employee={employee} onClose={() => setProfileOpen(false)} />}
{profileOpen && <ProfileDialog key={employee.id} employee={employee} onClose={() => setProfileOpen(false)} />}
<main className="main">
<header className="topbar">
<span className="crumb-sub">{organization.name}</span>
@@ -159,6 +159,7 @@ export function Shell({
</div>
</main>
<SearchDialog
key={snapshot.activeOrgId ?? "none"}
snapshot={snapshot}
open={searchOpen}
onClose={() => setSearchOpen(false)}
+41
View File
@@ -0,0 +1,41 @@
import { _electron as electron, expect, test } from "@playwright/test";
import { mkdirSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { randomUUID } from "node:crypto";
import { seedBuiltinSkillsFixture } from "./builtin-skills-fixture";
import { closeApp, onboard } from "./onboard";
test("switching company leaves nothing of the previous company on screen", async () => {
const profileDir = join(tmpdir(), `agentcompany-new-e2e-switch-${randomUUID()}`);
mkdirSync(profileDir, { recursive: true });
const builtinDir = seedBuiltinSkillsFixture(join(tmpdir(), `agentcompany-new-e2e-switch-builtin-${randomUUID()}`));
const app = await electron.launch({
args: [resolve("out/main/index.js")],
env: { ...process.env, AGENTCOMPANY_NEW_PROFILE_DIR: profileDir, AGENTCOMPANY_NEW_AUTORUN: "0", AGENTCOMPANY_NEW_BUILTIN_SKILLS_DIR: builtinDir },
});
try {
const page = await app.firstWindow();
await onboard(page, "Alpha Co");
const searchBox = page.getByRole("dialog", { name: "Search" }).getByRole("textbox");
await page.locator(".search-kbd").click();
await searchBox.fill("Alpha search");
await page.keyboard.press("Escape");
await page.getByRole("button", { name: "Alpha Co — switch organization" }).click();
await page.getByRole("menuitem", { name: "New organization" }).click();
await onboard(page, "Beta Co");
await expect(page.getByRole("button", { name: "Beta Co — switch organization" })).toBeVisible();
// Switching back keeps the shell on screen, yet search opens fresh in the other company.
await page.locator(".search-kbd").click();
await searchBox.fill("Beta search");
await page.keyboard.press("Escape");
await page.getByRole("button", { name: "Beta Co — switch organization" }).click();
await page.getByRole("menuitem", { name: /Alpha Co/ }).click();
await expect(page.getByRole("button", { name: "Alpha Co — switch organization" })).toBeVisible();
await page.locator(".search-kbd").click();
await expect(searchBox).toHaveValue("");
} finally {
await closeApp(app);
}
});