Skip to content

minor bugs and terminal naming#138

Merged
Kitenite merged 2 commits intomainfrom
minor-bugs
Nov 24, 2025
Merged

minor bugs and terminal naming#138
Kitenite merged 2 commits intomainfrom
minor-bugs

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Nov 24, 2025

  • fix space rename
  • increment terminal names

Summary by CodeRabbit

  • Bug Fixes

    • Fixed keyboard input (Enter/Space) during tab rename operations to prevent accidental tab activation.
  • New Features

    • Implemented intelligent terminal naming system that automatically generates unique, sequential names when creating new terminals (e.g., Terminal, Terminal (2), Terminal (3)).
    • Improved tab creation logic to better handle collisions and maintain consistency across drag-and-drop operations.
  • Tests

    • Added comprehensive test suite for terminal naming with coverage for sequential naming, collision handling, and edge cases.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 24, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This PR implements terminal naming collision avoidance by introducing a naming strategy pattern and propagating existing tabs through the tab creation pipeline. It updates the createNewTab function to accept existing tabs and generate collision-free terminal names, modifies all tab creation call sites to pass the current tabs array, adds terminal naming strategy interfaces and implementations, and includes a rename-guard to prevent accidental tab activation during rename operations.

Changes

Cohort / File(s) Summary
Terminal Naming System
apps/desktop/src/renderer/stores/tabs/utils/terminal-naming.ts, apps/desktop/src/renderer/stores/tabs/utils/terminal-naming.test.ts
Introduces TerminalNamingStrategy interface with DefaultTerminalNamingStrategy implementation for generating unique terminal names with collision detection (Terminal, Terminal (1), Terminal (2), etc.). Adds comprehensive test suite covering collision handling, gaps in numbering, and custom base names.
Core Tab Creation
apps/desktop/src/renderer/stores/tabs/utils.ts
Extends createNewTab signature to accept optional existingTabs: Tab[] = [] parameter. Dynamically generates unique terminal names for Single-type tabs using generateTerminalName instead of hardcoded "New Terminal".
Tab Creation Call Sites
apps/desktop/src/renderer/stores/tabs/drag-logic.ts, apps/desktop/src/renderer/stores/tabs/helpers/split-operations.ts, apps/desktop/src/renderer/stores/tabs/helpers/tab-crud.ts
Updates all createNewTab invocations to pass state.tabs as third argument across three drag-and-drop paths, split-view operations, and add-tab handler. Refactors split-operations to use newChildTabWithParent when creating grouped child tabs.
UI Rename Guard
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/TabItem/index.tsx
Adds conditional guard to keyDown handler preventing Enter/Space from triggering handleTabClick when a tab is actively being renamed.

Sequence Diagram

sequenceDiagram
    participant Caller as Tab Creation Caller
    participant CRUD as createNewTab()
    participant Naming as Terminal Naming
    
    Caller->>CRUD: createNewTab(workspaceId, type, state.tabs)
    activate CRUD
    alt Single Tab Type
        CRUD->>Naming: generateTerminalName(existingNames, strategy)
        activate Naming
        Naming->>Naming: Check for collision
        alt No Collision
            Naming-->>CRUD: baseName
        else Collision Detected
            Naming->>Naming: Increment suffix (n)
            Naming-->>CRUD: "BaseName (n)"
        end
        deactivate Naming
        CRUD->>CRUD: title = generated name
    else Group Tab Type
        CRUD->>CRUD: title = "New Split View"
    end
    CRUD-->>Caller: Tab with unique name
    deactivate CRUD
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Terminal naming strategy logic: Verify collision detection algorithm correctly identifies in-use names and increments suffix properly
  • Call site consistency: Ensure all createNewTab invocations properly pass state.tabs; check drag-logic, split-operations, and tab-crud for completeness
  • Parameter threading: Confirm the new optional parameter doesn't break existing callers and defaults work as expected
  • Rename guard interaction: Validate the keyDown guard doesn't inadvertently block other keyboard functionality
  • Test coverage: Review test suite comprehensiveness for terminal naming edge cases (gaps in numbering, large terminal counts, etc.)

Possibly related PRs

  • xterm ui #115: Modifies the same TabItem keyDown handler for Enter/Space keyboard interactions in tab activation flow
  • tabs mangement interaction #105: Updates createNewTab function signature in the same utils file with different parameter changes
  • tabs interaction #111: Modifies tab drag-to-tab logic and createNewTab invocations across drag-logic and related modules

Poem

🐰 A rabbit hops through tabs with glee,
No more collisions, Terminal (3)!
Names now unique, with strategy bold,
And rename-safe—no more accidental hold! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch minor-bugs

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3af106f and 14b5b3d.

📒 Files selected for processing (7)
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/TabItem/index.tsx (1 hunks)
  • apps/desktop/src/renderer/stores/tabs/drag-logic.ts (3 hunks)
  • apps/desktop/src/renderer/stores/tabs/helpers/split-operations.ts (4 hunks)
  • apps/desktop/src/renderer/stores/tabs/helpers/tab-crud.ts (1 hunks)
  • apps/desktop/src/renderer/stores/tabs/utils.ts (2 hunks)
  • apps/desktop/src/renderer/stores/tabs/utils/terminal-naming.test.ts (1 hunks)
  • apps/desktop/src/renderer/stores/tabs/utils/terminal-naming.ts (1 hunks)

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 and usage tips.

@Kitenite Kitenite changed the title minor bugs minor bugs and terminal naming Nov 24, 2025
@Kitenite Kitenite merged commit 515b82c into main Nov 24, 2025
0 of 5 checks passed
@Kitenite Kitenite deleted the minor-bugs branch November 24, 2025 06:48
This was referenced Nov 24, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Nov 25, 2025
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.

1 participant