From a6da05164d81ae51c21e39b2cf19909b1d0b2f20 Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Fri, 25 Sep 2026 22:54:31 +0800 Subject: [PATCH] fix(linear): clarify workspace hierarchy and align setup controls --- .../linear/tests/webui/LinearPanel.test.tsx | 48 ++++++- .../linear/webui/LinearMemberAccess.tsx | 10 +- nanobot/channels/linear/webui/LinearPanel.tsx | 120 ++++++++++-------- 3 files changed, 120 insertions(+), 58 deletions(-) diff --git a/nanobot/channels/linear/tests/webui/LinearPanel.test.tsx b/nanobot/channels/linear/tests/webui/LinearPanel.test.tsx index 7fdacb15c..5ae58a8cd 100644 --- a/nanobot/channels/linear/tests/webui/LinearPanel.test.tsx +++ b/nanobot/channels/linear/tests/webui/LinearPanel.test.tsx @@ -476,7 +476,13 @@ describe("Linear channel UI", () => { renderSettingsView({ initialSection: "channels" }); fireEvent.click(await screen.findByRole("button", { name: "View Linear settings" })); expect(await screen.findByText("Example workspace")).toBeVisible(); - expect(screen.getByText(/app:assignable/)).toBeVisible(); + const workspace = screen.getByRole("article", { name: "Example workspace" }); + expect(within(workspace).getByRole("heading", { name: "Example workspace", level: 5 })).toBeVisible(); + expect(within(workspace).getByRole("button", { name: "Member access" })).toBeVisible(); + expect(screen.queryByText(/app:assignable/)).not.toBeInTheDocument(); + fireEvent.click(within(workspace).getByRole("button", { name: "Authorized" })); + expect(await screen.findByRole("tooltip")).toHaveTextContent("read, write, app:mentionable, app:assignable"); + fireEvent.keyDown(document, { key: "Escape" }); fireEvent.click(screen.getByRole("button", { name: "Disconnect" })); fireEvent.click(screen.getByRole("button", { name: "Disconnect workspace" })); @@ -490,6 +496,46 @@ describe("Linear channel UI", () => { ); }); + it("keeps member access inside its own workspace card and leaves other cards collapsed", async () => { + mockFeature({ ...savedFeature(), enabled: true, running: true, runtime_status: "running" }); + requestMutationMock.mockImplementation(async (_method, params) => { + if (params.operation === "members") return { + session_id: "", status: "members", organization_id: params.organization_id, + legacy_allow_all: false, + members: [{ id: "u1", name: "Xubin", teams: ["nanobot"], allowed: true }], + }; + return { session_id: "", status: "inspected", installations: [ + { organization_id: "org-1", organization_name: "nanobot", authorization_status: "authorized" }, + { organization_id: "org-2", organization_name: "Design workspace", authorization_status: "authorized" }, + ] }; + }); + renderSettingsView({ initialSection: "channels" }); + fireEvent.click(await screen.findByRole("button", { name: "View Linear settings" })); + const workspace = await screen.findByRole("article", { name: "nanobot" }); + const other = screen.getByRole("article", { name: "Design workspace" }); + fireEvent.click(within(workspace).getByRole("button", { name: "Member access" })); + expect(await within(workspace).findByRole("switch", { name: "Allow Xubin to use nanobot" })).toBeVisible(); + expect(within(other).getByRole("button", { name: "Member access" })).toHaveAttribute("aria-expanded", "false"); + expect(within(other).queryByRole("switch")).not.toBeInTheDocument(); + expect(requestMutationMock).toHaveBeenCalledWith("settings.channel.connect.start", { + channel: "linear", operation: "members", organization_id: "org-1", + }, 150_000); + expect(requestMutationMock.mock.calls.some(([, params]) => params.operation === "member_access")).toBe(false); + }); + + it("keeps missing authorization scopes visible without opening a tooltip", async () => { + mockFeature({ ...savedFeature(), enabled: true, running: true, runtime_status: "running" }); + requestMutationMock.mockResolvedValue({ session_id: "", status: "inspected", installations: [{ + organization_id: "org-1", organization_name: "nanobot", authorization_status: "missing_scopes", + scopes: ["read"], missing_scopes: ["write", "app:mentionable"], + }] }); + renderSettingsView({ initialSection: "channels" }); + fireEvent.click(await screen.findByRole("button", { name: "View Linear settings" })); + const workspace = await screen.findByRole("article", { name: "nanobot" }); + expect(within(workspace).getByText("Reconnect to grant: write, app:mentionable")).toBeVisible(); + expect(screen.queryByRole("tooltip")).not.toBeInTheDocument(); + }); + it("prevents disconnecting a workspace while its status is refreshing", async () => { const running = { ...savedFeature(), enabled: true, running: true, runtime_status: "running" as const, diff --git a/nanobot/channels/linear/webui/LinearMemberAccess.tsx b/nanobot/channels/linear/webui/LinearMemberAccess.tsx index b0555686f..4c63bd9a5 100644 --- a/nanobot/channels/linear/webui/LinearMemberAccess.tsx +++ b/nanobot/channels/linear/webui/LinearMemberAccess.tsx @@ -68,14 +68,14 @@ export function LinearMemberAccess({ organizationId, configScope = "", disabled } return ( -
+
+ ) : null} + - ) : null} - - + +