Skip to content

Commit 370df78

Browse files
fix(ui): seed chat rename from stored label
1 parent e84a45e commit 370df78

3 files changed

Lines changed: 33 additions & 7 deletions

File tree

‎ui/src/e2e/session-management.account-label.e2e.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,32 @@ suite.define(() => {
9999
await context.close();
100100
}
101101
});
102+
103+
it("opens chat pane rename on the stored label, not the account-decorated title", async () => {
104+
const cardsKey = "agent:main:telegram:cards:direct:42";
105+
const context = await suite.browser.newContext({
106+
locale: "en-US",
107+
serviceWorkers: "block",
108+
viewport: { height: 900, width: 1280 },
109+
});
110+
const page = await context.newPage();
111+
await installMockGateway(page, {
112+
methodResponses: {
113+
"sessions.list": sessionsListResponse([gatewayDirectRow(cardsKey, Date.now(), "cards")]),
114+
},
115+
sessionKey: cardsKey,
116+
});
117+
118+
try {
119+
await page.goto(controlUiSessionUrl(suite.server.baseUrl, cardsKey));
120+
const title = page.locator(".chat-pane__session-title-button");
121+
await expect.poll(() => title.textContent()).toContain("Alice · cards");
122+
await title.click();
123+
const field = page.locator(".chat-pane__session-title-input");
124+
await field.waitFor({ state: "visible" });
125+
expect(await field.inputValue()).toBe("");
126+
} finally {
127+
await context.close();
128+
}
129+
});
102130
});

‎ui/src/pages/chat/chat-pane-base.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ export abstract class ChatPaneBase extends OpenClawLightDomElement {
320320
}
321321
>();
322322
protected headerRenameInitialLabel: string | null = null;
323-
protected headerRenameInitialValue = "";
324323
protected headerRenameSessionKey = "";
325324
protected headerCopiedTimer: number | null = null;
326325
protected composerPrefillAttentionTimer: number | null = null;

‎ui/src/pages/chat/chat-pane-session-menu.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,12 @@ export abstract class ChatPaneSessionMenu extends ChatPaneContext {
244244
this.publishHeaderError(access.reason);
245245
return;
246246
}
247-
const customLabel = row.label?.trim() || null;
247+
const customLabel = normalizeOptionalString(row.label) ?? null;
248248
this.headerRenameSessionKey = row.key;
249249
this.headerRenameInitialLabel = customLabel;
250-
this.headerRenameInitialValue = customLabel ?? this.paneTitle;
251-
this.headerRenameValue = this.headerRenameInitialValue;
250+
// Editable session names come only from persisted user data. Seeding from
251+
// paneTitle would let display decoration become the next stored label.
252+
this.headerRenameValue = customLabel ?? "";
252253
this.headerEditing = true;
253254
void this.updateComplete.then(() => {
254255
const input = this.querySelector<HTMLInputElement>(".chat-pane__session-title-input");
@@ -269,13 +270,11 @@ export abstract class ChatPaneSessionMenu extends ChatPaneContext {
269270
const key = this.headerRenameSessionKey;
270271
const trimmed = this.headerRenameValue.trim();
271272
const label = trimmed || null;
272-
const unchangedDerivedTitle =
273-
this.headerRenameInitialLabel === null && trimmed === this.headerRenameInitialValue.trim();
274273
const unchangedLabel = label === this.headerRenameInitialLabel;
275274
this.headerEditing = false;
276275
this.headerRenameSessionKey = "";
277276
const state = this.state;
278-
if (!key || !state || unchangedDerivedTitle || unchangedLabel) {
277+
if (!key || !state || unchangedLabel) {
279278
return;
280279
}
281280
const access = readSessionMethodAccess(this.context.gateway.snapshot, {

0 commit comments

Comments
 (0)