Skip to content

Comments

fix(terminal): renumber auto-named tabs to prevent duplicate labels#447

Merged
Dimillian merged 1 commit intoDimillian:mainfrom
bilalbayram:codex/fix/terminal-tabs-indexing
Feb 17, 2026
Merged

fix(terminal): renumber auto-named tabs to prevent duplicate labels#447
Dimillian merged 1 commit intoDimillian:mainfrom
bilalbayram:codex/fix/terminal-tabs-indexing

Conversation

@bilalbayram
Copy link
Contributor

@bilalbayram bilalbayram commented Feb 16, 2026

Problem

Screenshot 2026-02-16 at 2 47 40 PM

Summary

  • Reindex auto-created terminal tab labels after create/close so labels stay contiguous (Terminal 1..N).
  • Preserve custom terminal tab titles (for example Launch, Setup) while only renumbering auto-generated tabs.
  • Keep the public TerminalTab API unchanged and track auto-named behavior with internal hook metadata.
  • Add regression tests for close reindexing, duplicate prevention after close+create, mixed custom/auto tabs, and auto-to-custom conversion.

Testing

  • npm run test -- src/features/terminal/hooks/useTerminalTabs.test.tsx
  • npm run test
  • npm run typecheck (currently fails on pre-existing unrelated GitLogEntry.refs errors in git/review files)

Root cause: createTerminal used existing tab count to assign labels, and closing tabs did not reindex remaining auto-created terminals. After closing Terminal 1, creating another tab could produce duplicate labels such as two Terminal 2 tabs.

Implementation: useTerminalTabs now stores internal tab metadata with an autoNamed flag and uses a shared renumberAutoNamedTabs helper. createTerminal appends an auto-named tab and reindexes auto-named labels. closeTerminal reindexes remaining auto-named tabs after removal. ensureTerminalWithTitle marks tabs as custom titled and triggers auto-tab reindexing when converting an existing auto tab to custom.

Behavior guarantees: only auto-generated Terminal N tabs are renumbered; custom titles such as Launch and Setup are preserved; numbering of auto tabs ignores custom tabs; active-terminal fallback on close remains unchanged.

Tests: expanded useTerminalTabs.test.tsx to cover renumber-on-close, duplicate-prevention after close plus create, mixed custom and auto tab numbering, and conversion of an auto-named tab to a custom title.
@Dimillian
Copy link
Owner

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. You're on a roll.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Dimillian Dimillian merged commit ed76f8d into Dimillian:main Feb 17, 2026
9 checks passed
@bilalbayram bilalbayram deleted the codex/fix/terminal-tabs-indexing branch February 17, 2026 07:54
xiaojiou176 pushed a commit to xiaojiou176/CodexMonitor that referenced this pull request Feb 17, 2026
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