Skip to content

Commit 03262df

Browse files
authored
refactor(ui): tidy the roster refresh owner and session test harnesses (#129757)
* refactor(ui): name the roster load decision blocks and dedupe test harnesses Extract preserveCurrentSessionRow and retainSessionPaginationWindow from load()'s 140-line body so its spine reads as normalize -> loading publish -> request+owner merge -> provisional return -> decide -> publish; collapse the hasForegroundListOptions/hasSeededListOptions boolean pair into one closed listOptionsSource mode. Behavior-neutral. The event-refresh and owner-first suites hand-rolled copies of sessionsResult/createHarness/sessionChangedEvent; session-capability test-support already owned the canonical versions, so it gains selfUser support plus createSessionCapabilityHarness and the copies are deleted. * test(ui): move the attention-panel surface test to its component suite The app-sidebar harness mocks sidebar-attention.ts away (health RPCs must stay out of client call-order assertions), so the transient-menus case asserting the real attention panel renders was import-order dependent: deterministic-fail in local single-file runs on clean main, pass in CI's worker mix. The invariant (panel opens inside openclaw-menu-surface) now lives in sidebar-attention.test.ts against the real component, and the harness mock documents where attention rendering coverage belongs. * test(ui): give the moved attention-panel test its agent selection sidebar-attention reads context.agentSelection.state during refresh ownership; CI's striped worker mix exercised that path and crashed the render, leaving the trigger unrendered.
1 parent 316c341 commit 03262df

7 files changed

Lines changed: 223 additions & 233 deletions

File tree

‎ui/src/components/sidebar-attention.test.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,40 @@ describe("sidebar attention refresh ownership", () => {
237237
vi.unstubAllGlobals();
238238
});
239239

240+
it("keeps the plain attention panel inside its top-layer menu surface", async () => {
241+
const provider = createApplicationContextProvider({
242+
gateway: {
243+
snapshot: { phase: "connected", client: null, hello: null },
244+
connection: { gatewayUrl: "" },
245+
subscribe: () => () => undefined,
246+
subscribeEvents: () => () => undefined,
247+
},
248+
overlays: {
249+
snapshot: { approvalQueue: [] },
250+
subscribe: () => () => undefined,
251+
},
252+
agentSelection: {
253+
state: { selectedId: null, scopeId: null },
254+
subscribe: () => () => undefined,
255+
},
256+
scopeUpgrade: hiddenScopeUpgradeCapability,
257+
} as unknown as ApplicationContext);
258+
const element = document.createElement("openclaw-sidebar-attention") as SidebarAttentionElement;
259+
provider.append(element);
260+
document.body.append(provider);
261+
262+
await waitForFast(() =>
263+
expect(element.querySelector<HTMLButtonElement>(".sidebar-issues-button")).not.toBeNull(),
264+
);
265+
element.querySelector<HTMLButtonElement>(".sidebar-issues-button")!.click();
266+
267+
await waitForFast(() => {
268+
const panel = element.querySelector(".sidebar-issues-panel");
269+
expect(panel).not.toBeNull();
270+
expect(panel?.closest("openclaw-menu-surface")).not.toBeNull();
271+
});
272+
});
273+
240274
it("keeps the latest refresh when an older load on the same client finishes last", async () => {
241275
const firstCron = deferred<unknown>();
242276
const firstAuth = deferred<unknown>();

0 commit comments

Comments
 (0)