Skip to content

Commit 48405ae

Browse files
committed
fix(ui): rerender profile on connection transitions
1 parent f9e2df6 commit 48405ae

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎ui/src/pages/profile/profile-page.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,28 @@ it("keeps identity UI and profile RPCs absent for unidentified connections", asy
208208
expect(page.querySelector(".profile-refresh")).toBeNull();
209209
});
210210

211+
it("rerenders on connection transitions for unidentified connections", async () => {
212+
const request = vi.fn();
213+
const harness = createConnectedContext(request as GatewayBrowserClient["request"]);
214+
const provider = createApplicationContextProvider(harness.context);
215+
const page = document.createElement(PROFILE_PAGE_TEST_TAG) as ProfilePageElement;
216+
provider.append(page);
217+
document.body.append(provider);
218+
219+
await page.updateComplete;
220+
expect(page.querySelector(".profile-hero")).not.toBeNull();
221+
222+
// With no @state change (selfUser stays null), the snapshot handler must
223+
// still invalidate the render branch that reads connected/client.
224+
harness.emitConnected(false);
225+
await page.updateComplete;
226+
expect(page.querySelector(".profile-hero")).toBeNull();
227+
228+
harness.emitConnected(true);
229+
await page.updateComplete;
230+
expect(page.querySelector(".profile-hero")).not.toBeNull();
231+
});
232+
211233
it("retries the identity bootstrap when users.self returns no profile", async () => {
212234
const profile: UserProfile = {
213235
id: "profile-1",

‎ui/src/pages/profile/profile-page.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ export class ProfilePage extends OpenClawLightDomElement {
8989
this.client = snapshot.client;
9090
this.connected = snapshot.phase === "connected";
9191
this.selfUser = nextSelfUser;
92+
// connected/client are plain fields; an unidentified (token-auth) connect or
93+
// disconnect changes no @state, so the render branch must be invalidated
94+
// explicitly or the page sticks on the stale offline/connected view.
95+
this.requestUpdate();
9296
if (clientChanged || selfProfileChanged) {
9397
this.identityRequestId += 1;
9498
this.ownProfile = null;

0 commit comments

Comments
 (0)