Skip to content

refactor (Desktop): Make it so when you make a new terminal it makes it in your screen#381

Merged
AviPeltz merged 4 commits intomainfrom
unlikely-mite-b065d6
Dec 17, 2025
Merged

refactor (Desktop): Make it so when you make a new terminal it makes it in your screen#381
AviPeltz merged 4 commits intomainfrom
unlikely-mite-b065d6

Conversation

@AviPeltz
Copy link
Copy Markdown
Collaborator

@AviPeltz AviPeltz commented Dec 16, 2025

Description

Related Issues

Type of Change

  • [] Bug fix
  • New feature
  • Documentation
  • [x ] Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes

Summary by CodeRabbit

  • New Features

    • Create panes directly within existing tabs (instead of always opening new tabs).
    • Set a custom name when creating a new pane.
  • Improvements

    • Configure new panes with initial commands and working directory.
    • Smarter tab/pane creation that adapts to the active tab and preserves renaming behavior for newly created tabs.

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 16, 2025

Walkthrough

Adds optional pane-creation options to the tabs store and updates the TabsView to create either a new pane on the active tab (with options) or a new tab, refining preset handling and command UI closure.

Changes

Cohort / File(s) Summary
Tabs store: API & implementation
apps/desktop/src/renderer/stores/tabs/types.ts, apps/desktop/src/renderer/stores/tabs/store.ts, apps/desktop/src/renderer/stores/tabs/utils.ts
addPane signature changed to addPane(tabId, options?: CreatePaneOptions); CreatePaneOptions may include initialCommands, initialCwd, and name; implementation now calls createPane(tabId, "terminal", options) and assigns pane name from options.name when present. AddTabOptions gains optional name.
TabsView: pane vs tab flow & presets
apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/index.tsx
handleAddTab and preset handlers refactored to derive activeTabId and either call addPane(activeTabId, presetOptions) or addTab(activeWorkspaceId, presetOptions); preserves renaming only for new tabs; moves setCommandOpen(false) to run after creation.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant User as User (UI)
    participant TabsView as TabsView Component
    participant TabsStore as Tabs Store
    participant PaneFactory as Pane Creation Logic

    User->>TabsView: Trigger "Add Tab"/select preset
    TabsView->>TabsView: Determine activeWorkspaceId / activeTabId
    alt activeTab exists
        TabsView->>TabsStore: addPane(activeTabId, options)
        TabsStore->>PaneFactory: createPane(activeTabId, "terminal", options)
        PaneFactory-->>TabsStore: newPaneId
        TabsStore-->>TabsView: pane created
    else no activeTab
        TabsView->>TabsStore: addTab(activeWorkspaceId, options)
        TabsStore-->>TabsView: newTabId
        TabsView->>TabsStore: (optional) renameTab(newTabId, name)
    end
    TabsView->>TabsView: setCommandOpen(false)
    TabsView-->>User: UI updated (tab/pane shown)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Review areas:
    • addPane signature/type propagation across types.ts, store.ts, and utils.ts
    • TabsView decision logic for activeTab vs new tab and correct options propagation
    • Ensure renaming behavior is applied only on new-tab path (not pane path)

Possibly related PRs

Poem

🐰 I hopped from tab to pane with glee,

Passed commands and cwd, name, and key,
A little rename for a newborn tab,
While panes keep cozy — no fuss, no drab,
Hooray for options, carrot tea! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete. It contains only template sections with no actual implementation details, related issues, testing steps, or context about the changes. Fill in the Description section explaining what changed and why. Link any related issues if applicable. Add specific testing steps to verify the terminal creation behavior works correctly.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: when creating a new terminal, it should be created in the user's visible screen instead of elsewhere.
✨ 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 unlikely-mite-b065d6

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.

@AviPeltz AviPeltz changed the title refactore (Desktop): Make it so when you make a new terminal it makes it in your screen refactor (Desktop): Make it so when you make a new terminal it makes it in your screen Dec 16, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d9c6056 and bfe546d.

📒 Files selected for processing (3)
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/index.tsx (3 hunks)
  • apps/desktop/src/renderer/stores/tabs/store.ts (1 hunks)
  • apps/desktop/src/renderer/stores/tabs/types.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
apps/desktop/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc

Files:

  • apps/desktop/src/renderer/stores/tabs/types.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/index.tsx
  • apps/desktop/src/renderer/stores/tabs/store.ts
apps/desktop/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

apps/desktop/**/*.{ts,tsx}: Please use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary

Files:

  • apps/desktop/src/renderer/stores/tabs/types.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/index.tsx
  • apps/desktop/src/renderer/stores/tabs/store.ts
**/*.{ts,tsx,js,jsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Use Biome for code formatting and linting, running at root level for speed

Files:

  • apps/desktop/src/renderer/stores/tabs/types.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/index.tsx
  • apps/desktop/src/renderer/stores/tabs/store.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Avoid any type and prioritize type safety in TypeScript code

Files:

  • apps/desktop/src/renderer/stores/tabs/types.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/index.tsx
  • apps/desktop/src/renderer/stores/tabs/store.ts
apps/desktop/src/renderer/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Call IPC methods from renderer process using window.ipcRenderer.invoke with type-safe object parameters

Files:

  • apps/desktop/src/renderer/stores/tabs/types.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/index.tsx
  • apps/desktop/src/renderer/stores/tabs/store.ts
**/components/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/components/**/*.{ts,tsx}: Structure project folders as one folder per component with PascalCase naming (ComponentName/ComponentName.tsx + index.ts barrel export)
Co-locate component dependencies (utils, hooks, constants, config, tests, stories) next to the file using them
Use one component per file (no multi-component files)

Files:

  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/index.tsx
🧬 Code graph analysis (1)
apps/desktop/src/renderer/stores/tabs/store.ts (1)
apps/desktop/src/renderer/stores/tabs/utils.ts (2)
  • CreatePaneOptions (38-41)
  • createPane (46-62)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Deploy Docs
  • GitHub Check: Deploy API
  • GitHub Check: Deploy Admin
  • GitHub Check: Deploy Web
  • GitHub Check: Deploy Marketing
  • GitHub Check: Build
🔇 Additional comments (4)
apps/desktop/src/renderer/stores/tabs/store.ts (1)

321-326: LGTM! Clean extension of pane creation API.

The signature extension to accept optional CreatePaneOptions and passing them to createPane is correct and enables callers to specify initial commands and working directory when adding panes.

apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/index.tsx (3)

58-60: LGTM! Active tab resolution.

Correctly derives activeTabId from the store's activeTabIds map using the current activeWorkspaceId, enabling the new pane-vs-tab logic.


62-72: LGTM! Pane-first creation strategy.

The new logic aligns with the PR objective: when an active tab exists, a pane is added to it (keeping the terminal in the visible screen); otherwise, a new tab is created. The guard clause and command dialog closure are correctly placed.


79-99: LGTM! Consistent preset handling with conditional tab renaming.

The preset handling correctly:

  • Builds presetOptions with the preset's commands and cwd
  • Follows the same pane-first strategy (adds pane to active tab when available)
  • Only renames the tab when creating a new one (line 93-95), which makes sense since renaming an existing tab would be unexpected

Comment thread apps/desktop/src/renderer/stores/tabs/types.ts Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 16, 2025

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

Service Status
Neon Database (Neon)

Thank you for your contribution! 🎉


Preview resources have been processed for cleanup

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/desktop/src/renderer/stores/tabs/utils.ts (1)

27-31: Consider consolidating AddTabOptions with CreatePaneOptions.

Both AddTabOptions (lines 27-31) and CreatePaneOptions (imported from utils.ts) now have identical structure with fields initialCommands, initialCwd, and name. This duplication violates the DRY principle and creates maintenance overhead.

Consider one of these approaches:

Option 1: Use CreatePaneOptions directly

-/**
- * Options for creating a tab with preset configuration
- */
-export interface AddTabOptions {
-	initialCommands?: string[];
-	initialCwd?: string;
-	name?: string;
-}

 /**
  * Actions available on the tabs store
  */
 export interface TabsStore extends TabsState {
 	// Tab operations
 	addTab: (
 		workspaceId: string,
-		options?: AddTabOptions,
+		options?: CreatePaneOptions,
 	) => { tabId: string; paneId: string };

Option 2: Make AddTabOptions extend CreatePaneOptions if future divergence is expected

 /**
  * Options for creating a tab with preset configuration
  */
-export interface AddTabOptions {
-	initialCommands?: string[];
-	initialCwd?: string;
-	name?: string;
-}
+export interface AddTabOptions extends CreatePaneOptions {
+	// Add tab-specific options here if needed in the future
+}
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bfe546d and 6f511da.

📒 Files selected for processing (3)
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/index.tsx (3 hunks)
  • apps/desktop/src/renderer/stores/tabs/types.ts (3 hunks)
  • apps/desktop/src/renderer/stores/tabs/utils.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
apps/desktop/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc

Files:

  • apps/desktop/src/renderer/stores/tabs/utils.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/index.tsx
  • apps/desktop/src/renderer/stores/tabs/types.ts
apps/desktop/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

apps/desktop/**/*.{ts,tsx}: Please use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary

Files:

  • apps/desktop/src/renderer/stores/tabs/utils.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/index.tsx
  • apps/desktop/src/renderer/stores/tabs/types.ts
**/*.{ts,tsx,js,jsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Use Biome for code formatting and linting, running at root level for speed

Files:

  • apps/desktop/src/renderer/stores/tabs/utils.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/index.tsx
  • apps/desktop/src/renderer/stores/tabs/types.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Avoid any type and prioritize type safety in TypeScript code

Files:

  • apps/desktop/src/renderer/stores/tabs/utils.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/index.tsx
  • apps/desktop/src/renderer/stores/tabs/types.ts
apps/desktop/src/renderer/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Call IPC methods from renderer process using window.ipcRenderer.invoke with type-safe object parameters

Files:

  • apps/desktop/src/renderer/stores/tabs/utils.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/index.tsx
  • apps/desktop/src/renderer/stores/tabs/types.ts
**/components/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/components/**/*.{ts,tsx}: Structure project folders as one folder per component with PascalCase naming (ComponentName/ComponentName.tsx + index.ts barrel export)
Co-locate component dependencies (utils, hooks, constants, config, tests, stories) next to the file using them
Use one component per file (no multi-component files)

Files:

  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/index.tsx
🧠 Learnings (3)
📚 Learning: 2025-12-12T05:45:09.686Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-12T05:45:09.686Z
Learning: Applies to apps/desktop/src/main/lib/*.ts : Implement IPC handlers accepting object parameters (not positional parameters) in apps/desktop/src/main/lib/*.ts files

Applied to files:

  • apps/desktop/src/renderer/stores/tabs/types.ts
📚 Learning: 2025-11-24T21:33:13.267Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: apps/desktop/AGENTS.md:0-0
Timestamp: 2025-11-24T21:33:13.267Z
Learning: Applies to apps/desktop/**/*.{ts,tsx} : Please use alias as defined in `tsconfig.json` when possible

Applied to files:

  • apps/desktop/src/renderer/stores/tabs/types.ts
📚 Learning: 2025-12-12T05:45:09.686Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-12T05:45:09.686Z
Learning: Applies to apps/desktop/src/shared/ipc-channels.ts : Define IPC channel types in apps/desktop/src/shared/ipc-channels.ts before implementing handlers

Applied to files:

  • apps/desktop/src/renderer/stores/tabs/types.ts
🧬 Code graph analysis (1)
apps/desktop/src/renderer/stores/tabs/types.ts (1)
apps/desktop/src/renderer/stores/tabs/utils.ts (1)
  • CreatePaneOptions (38-42)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Deploy Marketing
  • GitHub Check: Deploy Docs
  • GitHub Check: Deploy API
  • GitHub Check: Deploy Admin
  • GitHub Check: Deploy Web
  • GitHub Check: Build
🔇 Additional comments (6)
apps/desktop/src/renderer/stores/tabs/utils.ts (1)

41-41: LGTM! Clean implementation of optional pane naming.

The addition of the name field to CreatePaneOptions and its usage in createPane is well-implemented with a sensible fallback to "Terminal".

Also applies to: 58-58

apps/desktop/src/renderer/screens/main/components/WorkspaceView/Sidebar/TabsView/index.tsx (3)

58-60: LGTM! Clean derivation of active tab.

The activeTabId derivation correctly handles the case when there's no active workspace.


62-76: LGTM! Correct implementation of the PR objective.

The refactored logic correctly adds a pane to the active tab (keeping the terminal in the current view) before falling back to creating a new tab. The early return, fallback logic, and command dialog closure are all properly handled.


83-111: LGTM! Preset handling with correct tab naming.

The preset flow correctly:

  • Adds pane to the active tab with preset options when possible
  • Falls back to creating a new tab when needed
  • Only renames the tab to the preset name when creating a new tab (not when adding a pane to an existing tab)

The comment on line 104 clearly documents the intentional behavior.

apps/desktop/src/renderer/stores/tabs/types.ts (2)

3-3: LGTM! Import addition supports the enhanced addPane signature.

The type-only import of CreatePaneOptions is correctly added to support the updated addPane method signature, addressing the previous review comment about type consistency.


55-55: LGTM! Signature correctly uses CreatePaneOptions.

The addPane signature has been properly updated to accept optional CreatePaneOptions, successfully addressing the previous review comment about type consistency. This enhancement allows callers to specify name, initialCommands, and initialCwd when creating panes.

Comment on lines 27 to 31
export interface AddTabOptions {
initialCommands?: string[];
initialCwd?: string;
name?: string;
}
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.

🛠️ Refactor suggestion | 🟠 Major

Consolidate duplicate type definitions.

AddTabOptions and CreatePaneOptions now have identical shapes (all three fields match: initialCommands?, initialCwd?, and name?). This duplication violates DRY principles and creates maintenance risk—if one interface changes, the other must be kept in sync manually.

Consider one of these approaches:

Option 1 (recommended): Use CreatePaneOptions directly

Remove AddTabOptions and use CreatePaneOptions everywhere:

-/**
- * Options for creating a tab with preset configuration
- */
-export interface AddTabOptions {
-	initialCommands?: string[];
-	initialCwd?: string;
-	name?: string;
-}
-
 /**
  * Actions available on the tabs store
  */
 export interface TabsStore extends TabsState {
 	// Tab operations
 	addTab: (
 		workspaceId: string,
-		options?: AddTabOptions,
+		options?: CreatePaneOptions,
 	) => { tabId: string; paneId: string };

Option 2: Make AddTabOptions extend CreatePaneOptions

If AddTabOptions may diverge in the future:

 /**
  * Options for creating a tab with preset configuration
  */
-export interface AddTabOptions {
-	initialCommands?: string[];
-	initialCwd?: string;
-	name?: string;
-}
+export interface AddTabOptions extends CreatePaneOptions {
+	// Add tab-specific options here if needed in the future
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export interface AddTabOptions {
initialCommands?: string[];
initialCwd?: string;
name?: string;
}
export interface AddTabOptions extends CreatePaneOptions {
// Add tab-specific options here if needed in the future
}
🤖 Prompt for AI Agents
In apps/desktop/src/renderer/stores/tabs/types.ts around lines 27-31,
AddTabOptions duplicates CreatePaneOptions; remove the duplicate by deleting the
AddTabOptions interface and replace its usages with CreatePaneOptions (or, if
you expect divergence, make AddTabOptions extend CreatePaneOptions instead).
Update all imports/usages across the codebase to reference CreatePaneOptions,
export CreatePaneOptions if not already exported, and run the TypeScript
build/tests to ensure no remaining references to AddTabOptions.

@AviPeltz AviPeltz merged commit 6b961f3 into main Dec 17, 2025
12 checks passed
This was referenced Dec 17, 2025
Kitenite added a commit that referenced this pull request Dec 17, 2025
…t makes it in your screen (#381)"

This reverts commit 6b961f3.
Kitenite added a commit that referenced this pull request Dec 17, 2025
… presets (#393)

* chore(desktop): bump version to 0.0.24

* remove presets

* Revert "refactor (Desktop): Make it so when you make a new terminal it makes it in your screen (#381)"

This reverts commit 6b961f3.

* add opencode support
@Kitenite Kitenite deleted the unlikely-mite-b065d6 branch December 18, 2025 01:31
This was referenced Dec 18, 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