Skip to content

fix(server): strip ANSI codes from extension session names - #1413

Merged
danyaberezun merged 3 commits into
JetBrains:mainfrom
markjoin123:cursor/strip-session-name-ansi-546c
Nov 18, 2026
Merged

danyaberezun merged 3 commits into
JetBrains:mainfrom
markjoin123:cursor/strip-session-name-ansi-546c

Conversation

@markjoin123

Copy link
Copy Markdown
Contributor

Problem

An extension that names a chat with pi.setSessionName("\x1b[31mred\x1b[0m name") shows the raw escape bytes in the chat title and the session list, including after reload. #1353 strips escapes from text the ext-UI bridge displays, including ctx.ui.setTitle. A session name does not go through that bridge: pi stores it on the session file as session_info, and the host reads it back from the live event, the session records, and the history index.

Approach

Strip escapes where the name is read, so a name already saved by an older build shows up plain. The session file is not rewritten, and the 80-character write cap stays on renameSession only.

stripAnsi moved to @thinkrail/shared/stripAnsi. history cannot import agent, and both modules read the title. Display reads are the forwarded session_info_changed event, every session summary and state-record title (including a disk list row's SessionInfo.name), and the title extractSession takes from session_info. A name that is only escapes is treated as a clear. A visible title longer than 80 characters is kept.

Changes

  • Shared stripAnsi / plainText, used by the ext-UI bridge and by session-title reads.
  • Live rename, session list, state records, and history titles drop terminal escapes.
  • Regression tests for a live pi.setSessionName, a name already on disk, and a coloured title past the write cap. The on-disk session_info name is still the original string.

Screenshots

Not applicable — no frontend changes. The page already renders the title string the host sends.

Related issues

Fixes #1374

Checklist

  • Fast gates pass: bun run lint, bun run typecheck, bun run test
  • E2E suite passes for app-affecting changes (bun run e2e, or bun run e2e:full when touching agent behavior)
  • Before/after screenshots are included for frontend changes, or marked not applicable
  • Relevant SPEC.md / top-level specs updated to reflect any boundary, contract, or behavior change
  • I have read the Contributing guide and agree to the Code of Conduct

The lint, typecheck, and new session-title tests passed. One existing @thinkrail/server test (pushBranch reftable workspace) failed because this environment's Git has no git refs; it is unrelated to session titles. E2E was not run: the page did not change, and the live and reload paths are covered by the server tests.

This change was made with AI assistance and reviewed.

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — ready to merge.

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — ready to merge.

@danyaberezun
danyaberezun added this pull request to the merge queue Nov 18, 2026
@danyaberezun

Copy link
Copy Markdown
Collaborator

Thanks markxu (@markjoin123) — verified that every read path a user sees is covered and that stripping is idempotent across the live event, summaries and the history index. I pushed one docs commit on top so the strip's behaviour and the reasons the built-ins don't fit are recorded once, in packages/shared/SPEC.md, with the agent spec pointing there (AGENTS.md: specs don't restate each other). Merging via the queue.

Merged via the queue into JetBrains:main with commit 52ea03b Nov 18, 2026
12 checks passed
Chong Jiang (Bouchee) added a commit to Bouchee/raildesign that referenced this pull request Nov 23, 2026
Adapt ThinkRail JetBrains#1413 (52ea03b) to RailDesign title and search handling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extension chat names set with pi.setSessionName show raw terminal escape codes

2 participants