Skip to content

fix(naming): lead workspace and tab names with the work-item identifier - #8238

Merged
AmethystLiang merged 2 commits into
stablyai:mainfrom
tmchow:tmchow/worktree-rename-issue-pr
Jul 11, 2026
Merged

AmethystLiang merged 2 commits into
stablyai:mainfrom
tmchow:tmchow/worktree-rename-issue-pr

Conversation

@tmchow

@tmchow tmchow commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Auto-generated names now lead with the PR/MR/issue/ticket they reference. Before, first-work auto-rename and tab titles ran the prompt through a summarizer that buried or dropped the identifier: a prompt like "review this community PR …/pull/1094" became Review community pr 1094 as a workspace name and Review this community PR as a tab title (number gone). The identifier is the highest-signal, most searchable token, so the sidebar and tabs now lead with it — and stay consistent across every surface.

Surface Before After
Workspace / branch-rename name Review community pr 1094 PR 1094 - Review
Create-from-linked-item name Review PR 1234 (action-first) PR 1234 - Review
Tab title (URL in prompt) Review this community PR (number lost) PR 1094 - Review this community
Linear/Jira ticket Fix Issue 2635 ENG-456 - Fix

Decisions a reviewer should weigh:

  • One host-aware parser (src/shared/work-item-reference.ts) extracts the identifier from the raw prompt. URLs are validated by path structure (owner/repo/pull/N, GitLab's /-/ marker, Bitbucket pull-requests/N) rather than hostname — matching the existing github-links.ts/gitlab-links.ts approach, so GitHub Enterprise and self-hosted GitLab keep working while a stray cdn.example.com/assets/pull/2023/… path no longer mis-reads as a PR.
  • Ticket denylist so standards/cipher tokens (SHA-256, UTF-8, ISO-8601, RFC-2616) aren't mistaken for Jira/Linear keys — a real hazard in a coding tool. It keeps scanning past a denylisted token, so AES-256 … ENG-99 still resolves ENG-99.
  • Reconciled two naming paths onto one format. The app already named workspaces from linked items as action-first Review PR 1234; first-work auto-rename now produces identifier-first PR 1234 - Review. Both route through a shared formatIdentifierFirst so they can't drift (they had already diverged). This changes the branch/folder seed for create-from-linked-item (review-pr-1234 → pr-1234-review); no code depends on the old seed.
  • Fixed a pre-existing tab-title bug: markdown punctuation (incl. _) was stripped before URLs, so a GitLab …/merge_requests/42 URL split at its underscore and leaked requests into the title. URLs are now stripped first.

Inherent limits (best-effort, user can rename): a PR mentioned as context rather than the subject ("following PR 1033, build X") still leads with PR 1033, and multiple identifiers in one prompt resolve to the first by precedence.

Screenshots

No visual/layout change. The change is the generated name text in the sidebar and on tabs — see the before/after table above. Auto-generation is prompt-driven and not meaningfully screenshot-able as a static image; the behavior is pinned by unit tests instead.

Testing

  • pnpm lint — passes for everything this PR touches (oxlint, oxfmt, max-lines ratchet, reliability gates all clean). The only failure is a pre-existing, unrelated ja.json localization-parity mismatch (components.native-chat.composer.uploadingAttachments); this PR touches no locale catalogs or native-chat code.
  • pnpm typecheck — full (node + cli + web), clean.
  • pnpm test — all affected suites green (117 tests): work-item-reference, display-name-from-work, agent-tab-title, workspace-name, branch-name-from-work, agent-generated-tab-title, launch-work-item-direct, github-work-item-background-create. Full suite runs in CI.
  • pnpm build — not run locally; the full three-project typecheck stands in as the compile check.
  • Added or updated high-quality tests — new work-item-reference.test.ts and display-name-from-work.test.ts; updated tab-title, workspace-name, and work-item caller tests to the new format.

AI Review Report

Ran a multi-agent review (three independent reviewers — reuse, quality, efficiency — over two rounds) plus manual analysis. Risks checked and outcomes:

  • Duplication with existing URL parsers — confirmed github-links.ts/gitlab-links.ts can't be imported from src/shared (dependency direction), so the shared parser mirrors their path-structure validation; consolidating the renderer pickers onto it is noted as follow-up.
  • False positives — flagged the ticket regex matching SHA-256/UTF-8; added the denylist and host-structure URL validation (rejects CDN/doc lookalikes).
  • Perf on paste-sized prompts — flagged an unbounded scan; capped identifier extraction to a bounded prefix and aligned the tab-title call to the existing 512-char budget. A renderer perf test confirms no regex runs over the scan limit.
  • Format drift — flagged the same <id> - <detail> format hand-written in three places (root cause of the action-vs-identifier-first inconsistency); centralized in formatIdentifierFirst.
  • Removed a dead .toUpperCase() no-op and a redundant capitalize call.

Cross-platform (macOS/Linux/Windows): explicitly checked. Pure string/regex logic in src/shared + src/main — no filesystem paths, no shell/child-process execution, no keyboard shortcuts or metaKey/accelerators, no navigator/UA branching, no Electron platform APIs. Nothing platform-dependent was touched.

Security Audit

The parser consumes untrusted prompt text. Reviewed:

  • ReDoS — all regexes are linear (no catastrophic backtracking); input is bounded (4096-char cap in the parser, 512 on the tab path) before any regex runs.
  • Dynamic RegExp in stripWorkIdentifierEcho — built only from identifier tokens that are controlled lowercase-alphanumeric strings (pr/mr/digits/ticket keys), never raw user text, so no injection.
  • new URL() on arbitrary substrings — wrapped in try/catch; failures fall through.
  • Downstream use — extracted identifiers feed only display strings and git branch seeds, and seeds still pass through the existing slugify/sanitizeBranchSlug sanitizers, so nothing new reaches git refs unsanitized.

No command execution, path handling, auth, secrets, dependency, or IPC surface is involved. No follow-up required.

Notes

  • Behavior change: create-from-linked-item branch/folder seeds change format (review-pr-1234 → pr-1234-review) as a consequence of the identifier-first reconciliation. Cosmetic; no code depends on the old seed string.
  • Follow-up: fold the renderer github-links.ts/gitlab-links.ts pickers onto the shared work-item-reference.ts parser to remove the remaining path-parsing overlap (left out here to limit blast radius; ~11 importers).
  • No platform-specific behavior introduced.

Compound Engineering
Claude Code

Auto-generated workspace names, branch-rename display names, and tab
titles now lead with the referenced PR/MR/issue/ticket — e.g.
`PR 1033 - Review` instead of a paraphrase like "Review community pr
1094" that buried or dropped the number. Identifiers are the highest-
signal, most searchable token, so leading with them makes the sidebar
and tabs scannable and disambiguates same-verb work items.

- New shared `work-item-reference.ts` extracts the identifier from the
  raw prompt: URLs are validated by path structure (owner/repo/pull/N,
  GitLab's `/-/` marker) so GitHub Enterprise / self-hosted GitLab still
  resolve while stray `/pull/<n>` paths (CDN, docs) do not; a ticket-
  prefix denylist keeps `SHA-256` / `UTF-8` / `ISO-8601` from being read
  as Jira/Linear keys.
- Reconciles the existing create-from-work-item naming (was action-first
  `Review PR 1033`) with the first-work auto-rename onto one identifier-
  first format via a shared `formatIdentifierFirst`, so the two paths
  can't drift.
- Fixes a pre-existing tab-title bug where markdown punctuation was
  stripped before URLs, splitting a GitLab `merge_requests` URL at its
  underscore and leaking "requests" into the title.
@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b104d19d-aa0e-4294-889a-bea209f2c6f2

📥 Commits

Reviewing files that changed from the base of the PR and between a350d50 and 98a491e.

📒 Files selected for processing (4)
  • src/shared/agent-tab-title.test.ts
  • src/shared/agent-tab-title.ts
  • src/shared/work-item-reference.test.ts
  • src/shared/work-item-reference.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/shared/agent-tab-title.test.ts
  • src/shared/agent-tab-title.ts
  • src/shared/work-item-reference.test.ts
  • src/shared/work-item-reference.ts

📝 Walkthrough

Walkthrough

Adds shared parsing for work identifiers from provider URLs, textual references, ticket keys, and numeric references. Updates generated agent tab titles to place extracted identifiers before cleaned descriptions. Changes workspace intent names and auto-renamed workspace display names to use identifier-first formatting, action words from branch slugs, and collision suffixes. Updates related tests for issue, PR, MR, URL, ticket, and fallback naming cases.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: identifier-first workspace and tab naming.
Description check ✅ Passed The description follows the required template and covers summary, screenshots, testing, AI review, security, and notes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AmethystLiang AmethystLiang self-assigned this Jul 11, 2026
@AmethystLiang
AmethystLiang self-requested a review July 11, 2026 16:47
The URL/markdown strip reorder left the tab-title URL strip anchored on
\b, which fails when a URL is wrapped in markdown emphasis (_...pull/5_)
and leaked URL fragments into the title. Drop the \b anchor and trim
trailing markdown emphasis (*_~) in the URL identifier parser, keeping
interior underscores (merge_requests) intact. Adds regression tests.

Co-authored-by: Orca <[email protected]>

@AmethystLiang AmethystLiang 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.

Thanks Trevin — solid, well-tested change. Verified the identifier-first output across the sidebar, tab titles, and create-from-linked-item, plus the parser's path-structure URL validation (GHE/self-hosted GitLab safe) and the ticket denylist keeping SHA-256/RFC-2616 off the ticket path.

One fix on review, pushed as a follow-up commit: a markdown-emphasis-wrapped URL (_…/pull/5_) was leaking URL fragments into the tab title after the URL/markdown strip reorder — the \b anchor in the tab-title URL strip fails when the URL is preceded by _. Dropped the anchor and extended the URL parser's trailing-trim to markdown emphasis (*_~), keeping interior underscores (merge_requests) intact. Added two regression tests (both fail on revert).

Validation: typecheck + lint clean, 66 unit tests green, and a perf pass confirmed the tab-title hot path stays within the 512/4096-char scan bounds with no ReDoS risk.

@AmethystLiang
AmethystLiang merged commit b18ec39 into stablyai:main Jul 11, 2026
2 of 3 checks passed
AmethystLiang added a commit that referenced this pull request Jul 12, 2026
* fix: work-item naming, usage % rounding, and terminal/delete copy

Address prod-release-scan P2s:

- #8238: recognize Bitbucket Server (/projects|users/.../repos/.../pull-requests/N)
  and Azure DevOps (/_git/REPO/pullrequest/N) PR URL shapes in
  work-item-reference, alongside Bitbucket Cloud; graceful fallback preserved.

- #7574: getDisplayedUsagePercentage now rounds the used value before taking the
  `remaining` complement, so the compact status bar (raw usedPercent) and tooltip
  (pre-rounded clampUsedPercent) can no longer disagree by 1% at a .5 fraction.
  clampUsedPercent moves to the shared module as the single rounding source.

- #7459: mixed remote+local batch delete confirm no longer claims the whole
  batch is a permanent "remote host" delete — it now states remote items are
  permanent while local items move to the Trash/Recycle Bin.

- #8322: right-click-to-paste settings copy is platform-aware — "Control-click"
  on macOS, "Ctrl+right-click" on Windows/Linux — matching the ctrlKey gate.

Localization catalog synced (also picks up pre-existing UsagePercentageDisplayChangeNotice drift).

* Fix NaN% usage bar and label for non-finite provider values

Non-finite usedPercent inputs (NaN/Infinity) propagated through Math.round/min/max into the CSS bar width (`NaN%`) and displayed copy. clampUsedPercent now short-circuits to 0 in that case, with a test covering the divergence from getDisplayedUsagePercentage for the 'remaining' case.
brennanb2025 added a commit that referenced this pull request Jul 22, 2026
* fix(naming): remove identifier-first name post-processing

Workspace display names and tab titles were being rewritten after
generation by prompt-scanning heuristics from #8238 — a stray "#1" in
prose became a workspace named "#1 - Fix", and the rewrite ran
downstream of generation so user naming instructions couldn't override
it. Per the same principle as #9088, naming defaults stay minimal and
user overrides own the style.

- Delete work-item-reference.ts and display-name-from-work.ts (+tests).
- Auto-rename display names return to the humanized branch slug; tab
  titles return to the cleaned first prompt clause.
- Explicit create-from-work-item naming returns to action-first
  ("Review PR 1234").
- Keep #8238's URL-before-markdown strip-order bugfix in tab titles,
  with regression tests adjusted to the natural expectations.

* test(naming): pin incidental marker regression
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…er (stablyai#8238)

* fix(naming): lead workspace and tab names with the work-item identifier

Auto-generated workspace names, branch-rename display names, and tab
titles now lead with the referenced PR/MR/issue/ticket — e.g.
`PR 1033 - Review` instead of a paraphrase like "Review community pr
1094" that buried or dropped the number. Identifiers are the highest-
signal, most searchable token, so leading with them makes the sidebar
and tabs scannable and disambiguates same-verb work items.

- New shared `work-item-reference.ts` extracts the identifier from the
  raw prompt: URLs are validated by path structure (owner/repo/pull/N,
  GitLab's `/-/` marker) so GitHub Enterprise / self-hosted GitLab still
  resolve while stray `/pull/<n>` paths (CDN, docs) do not; a ticket-
  prefix denylist keeps `SHA-256` / `UTF-8` / `ISO-8601` from being read
  as Jira/Linear keys.
- Reconciles the existing create-from-work-item naming (was action-first
  `Review PR 1033`) with the first-work auto-rename onto one identifier-
  first format via a shared `formatIdentifierFirst`, so the two paths
  can't drift.
- Fixes a pre-existing tab-title bug where markdown punctuation was
  stripped before URLs, splitting a GitLab `merge_requests` URL at its
  underscore and leaking "requests" into the title.

* fix(naming): keep emphasis-wrapped URLs intact in generated names

The URL/markdown strip reorder left the tab-title URL strip anchored on
\b, which fails when a URL is wrapped in markdown emphasis (_...pull/5_)
and leaked URL fragments into the title. Drop the \b anchor and trim
trailing markdown emphasis (*_~) in the URL identifier parser, keeping
interior underscores (merge_requests) intact. Adds regression tests.

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: Jinjing <[email protected]>
Co-authored-by: Orca <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix: work-item naming, usage % rounding, and terminal/delete copy

Address prod-release-scan P2s:

- stablyai#8238: recognize Bitbucket Server (/projects|users/.../repos/.../pull-requests/N)
  and Azure DevOps (/_git/REPO/pullrequest/N) PR URL shapes in
  work-item-reference, alongside Bitbucket Cloud; graceful fallback preserved.

- stablyai#7574: getDisplayedUsagePercentage now rounds the used value before taking the
  `remaining` complement, so the compact status bar (raw usedPercent) and tooltip
  (pre-rounded clampUsedPercent) can no longer disagree by 1% at a .5 fraction.
  clampUsedPercent moves to the shared module as the single rounding source.

- stablyai#7459: mixed remote+local batch delete confirm no longer claims the whole
  batch is a permanent "remote host" delete — it now states remote items are
  permanent while local items move to the Trash/Recycle Bin.

- stablyai#8322: right-click-to-paste settings copy is platform-aware — "Control-click"
  on macOS, "Ctrl+right-click" on Windows/Linux — matching the ctrlKey gate.

Localization catalog synced (also picks up pre-existing UsagePercentageDisplayChangeNotice drift).

* Fix NaN% usage bar and label for non-finite provider values

Non-finite usedPercent inputs (NaN/Infinity) propagated through Math.round/min/max into the CSS bar width (`NaN%`) and displayed copy. clampUsedPercent now short-circuits to 0 in that case, with a test covering the divergence from getDisplayedUsagePercentage for the 'remaining' case.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
)

* fix(naming): remove identifier-first name post-processing

Workspace display names and tab titles were being rewritten after
generation by prompt-scanning heuristics from stablyai#8238 — a stray "stablyai#1" in
prose became a workspace named "stablyai#1 - Fix", and the rewrite ran
downstream of generation so user naming instructions couldn't override
it. Per the same principle as stablyai#9088, naming defaults stay minimal and
user overrides own the style.

- Delete work-item-reference.ts and display-name-from-work.ts (+tests).
- Auto-rename display names return to the humanized branch slug; tab
  titles return to the cleaned first prompt clause.
- Explicit create-from-work-item naming returns to action-first
  ("Review PR 1234").
- Keep stablyai#8238's URL-before-markdown strip-order bugfix in tab titles,
  with regression tests adjusted to the natural expectations.

* test(naming): pin incidental marker regression
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.

2 participants