Skip to content

fix(desktop): change split commands back & make more robust#261

Merged
AviPeltz merged 5 commits intomainfrom
inherent-gerbil-a76172
Dec 5, 2025
Merged

fix(desktop): change split commands back & make more robust#261
AviPeltz merged 5 commits intomainfrom
inherent-gerbil-a76172

Conversation

@AviPeltz
Copy link
Copy Markdown
Collaborator

@AviPeltz AviPeltz commented Dec 5, 2025

Description

Related Issues

Type of Change

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

Testing

Screenshots (if applicable)

Additional Notes

Summary by CodeRabbit

  • Bug Fixes

    • Split pane operations now gracefully handle cases when the focused pane is unavailable by automatically falling back to the first available pane.
  • Changes

    • Updated keyboard shortcuts for split operations:
      • Split Right: meta+d
      • Split Down: meta+shift+d
      • Split Auto: meta+e

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

@vercel
Copy link
Copy Markdown

vercel Bot commented Dec 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
website Ready Ready Preview Comment Dec 5, 2025 7:59pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 5, 2025

Walkthrough

This pull request enhances pane-splitting functionality by introducing a utility to resolve valid target panes within mosaic layouts, fixing focus management when panes are unavailable, and updating split hotkey bindings. The changes include a new findPanePath function to traverse layouts and refactored hotkey handlers with improved target resolution logic.

Changes

Cohort / File(s) Summary
Split operation target resolution
apps/desktop/src/renderer/screens/main/index.tsx
Adds resolveSplitTarget helper to determine valid split target panes with fallback to first pane; updates SPLIT_AUTO, SPLIT_RIGHT, and SPLIT_DOWN hotkey handlers to resolve targets and invoke split functions; includes focus correction via setFocusedPane; updates dependency arrays for proper recomputation.
Mosaic layout utilities
apps/desktop/src/renderer/stores/tabs/utils.ts, apps/desktop/src/renderer/stores/tabs/utils.test.ts
Introduces findPanePath function to recursively traverse mosaic layouts and return the path to a given paneId; includes comprehensive test coverage for single-pane, nested, asymmetric, and missing-pane scenarios.
Hotkey configuration
apps/desktop/src/shared/hotkeys.ts
Updates SPLIT_RIGHT keys from meta+shift+d to meta+d; updates SPLIT_DOWN keys from meta+alt+d to meta+shift+d; updates SPLIT_AUTO keys to meta+e.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Key areas requiring attention:
    • Logic in resolveSplitTarget and its integration with focus management to ensure focus corrections work correctly
    • findPanePath recursive traversal logic and edge cases (verify all test scenarios align with production use)
    • Hotkey mapping changes and any potential conflicts with updated keybindings

Possibly related PRs

Poem

🐰 Split my panes with meta and ease,
Find the path through branches with glee,
Focus restored when layouts reshape,
Hotkeys rebound in rhythmic escape,
My warren grows tiles, pane after pane!

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description consists entirely of an empty template with only checkboxes marked, lacking any substantive information about the changes, rationale, testing approach, or related issues. Add detailed descriptions for each section: explain what changes were made and why, link related issues, describe testing performed, and include any additional context about the implementation.
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 accurately summarizes the main changes: reverting split command keybindings and improving robustness of split pane logic with fallback handling.
✨ 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 inherent-gerbil-a76172

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 marked this pull request as ready for review December 5, 2025 19:59
@AviPeltz AviPeltz changed the title change split commands back change split commands back & make more robust Dec 5, 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: 0

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

38-57: Consider splitting multi‑expect cases into single‑assert tests

The coverage for findPanePath is strong and the layouts are easy to follow. The last two test cases, however, bundle multiple expect calls into one it block. For maximum clarity and to align with the “one assert per test” guideline, you could split those into separate tests per pane ID (e.g., one test for "pane-1", another for "pane-2", etc.), while reusing a shared layout fixture.

As per coding guidelines, tests should have one assert per test.

Also applies to: 73-100

apps/desktop/src/renderer/screens/main/index.tsx (1)

2-2: Split target resolution and focus correction are robust; minor cleanups possible

Using activeWindow plus resolveSplitTarget is a nice way to guard split operations and automatically repair desynced focus when the focused pane no longer exists in the current layout. The fallback to getFirstPaneId, coupled with setFocusedPane, should keep window and focus state coherent while still allowing splits to proceed.

A couple of small nits you might consider (non‑blocking):

  • resolveSplitTarget always returns an object, so the if (!target) return; checks in the three hotkey handlers are currently unreachable. Either remove those checks for clarity, or—if you expect a “no target” scenario later—make that part of the helper’s explicit return type.
  • Since Window is also a global DOM type name, you could optionally alias the imported store type (e.g., import type { Window as TabsWindow }) to reduce ambiguity at call sites.

Also applies to: 12-15, 45-49, 58-59, 70-87, 89-109, 111-128, 130-147

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b22dcbe and e69b02e.

📒 Files selected for processing (4)
  • apps/desktop/src/renderer/screens/main/index.tsx (5 hunks)
  • apps/desktop/src/renderer/stores/tabs/utils.test.ts (1 hunks)
  • apps/desktop/src/renderer/stores/tabs/utils.ts (2 hunks)
  • apps/desktop/src/shared/hotkeys.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/utils.test.ts
  • apps/desktop/src/renderer/stores/tabs/utils.ts
  • apps/desktop/src/shared/hotkeys.ts
  • apps/desktop/src/renderer/screens/main/index.tsx
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.test.ts
  • apps/desktop/src/renderer/stores/tabs/utils.ts
  • apps/desktop/src/shared/hotkeys.ts
  • apps/desktop/src/renderer/screens/main/index.tsx
apps/desktop/**/*.test.{ts,tsx,js,jsx}

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

apps/desktop/**/*.test.{ts,tsx,js,jsx}: Tests should have one assert per test
Tests should be readable
Tests should be fast
Tests should be independent
Tests should be repeatable

Files:

  • apps/desktop/src/renderer/stores/tabs/utils.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Avoid using any type - use explicit types instead for type safety
Use camelCase for variable and function names following existing codebase patterns
Keep diffs minimal with targeted edits only - avoid unnecessary changes when making modifications
Follow existing patterns and match the codebase style when writing new code

Files:

  • apps/desktop/src/renderer/stores/tabs/utils.test.ts
  • apps/desktop/src/renderer/stores/tabs/utils.ts
  • apps/desktop/src/shared/hotkeys.ts
  • apps/desktop/src/renderer/screens/main/index.tsx
apps/desktop/src/renderer/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Never import Node.js modules (fs, path, os, net, etc.) in renderer process code - browser environment only

Files:

  • apps/desktop/src/renderer/stores/tabs/utils.test.ts
  • apps/desktop/src/renderer/stores/tabs/utils.ts
  • apps/desktop/src/renderer/screens/main/index.tsx
apps/desktop/src/renderer/**/*.tsx

📄 CodeRabbit inference engine (AGENTS.md)

Call IPC methods using window.ipcRenderer.invoke() with object parameters - TypeScript will infer the exact response type automatically

Files:

  • apps/desktop/src/renderer/screens/main/index.tsx
🧠 Learnings (8)
📚 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/**/*.test.{ts,tsx,js,jsx} : Tests should be independent

Applied to files:

  • apps/desktop/src/renderer/stores/tabs/utils.test.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/**/*.test.{ts,tsx,js,jsx} : Tests should be repeatable

Applied to files:

  • apps/desktop/src/renderer/stores/tabs/utils.test.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/**/*.test.{ts,tsx,js,jsx} : Tests should be readable

Applied to files:

  • apps/desktop/src/renderer/stores/tabs/utils.test.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/**/*.test.{ts,tsx,js,jsx} : Tests should be fast

Applied to files:

  • apps/desktop/src/renderer/stores/tabs/utils.test.ts
📚 Learning: 2025-11-28T01:03:47.963Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-28T01:03:47.963Z
Learning: Applies to **/components/**/*.tsx : Co-locate tests next to the component file they test (e.g., `ComponentName.test.tsx`)

Applied to files:

  • apps/desktop/src/renderer/stores/tabs/utils.test.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/**/*.test.{ts,tsx,js,jsx} : Tests should have one assert per test

Applied to files:

  • apps/desktop/src/renderer/stores/tabs/utils.test.ts
📚 Learning: 2025-11-28T01:03:47.963Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-28T01:03:47.963Z
Learning: Applies to apps/desktop/src/renderer/**/*.tsx : Call IPC methods using `window.ipcRenderer.invoke()` with object parameters - TypeScript will infer the exact response type automatically

Applied to files:

  • apps/desktop/src/renderer/screens/main/index.tsx
📚 Learning: 2025-11-28T01:03:47.963Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-28T01:03:47.963Z
Learning: Applies to apps/desktop/src/renderer/**/*.{ts,tsx} : Never import Node.js modules (fs, path, os, net, etc.) in renderer process code - browser environment only

Applied to files:

  • apps/desktop/src/renderer/screens/main/index.tsx
🧬 Code graph analysis (3)
apps/desktop/src/renderer/stores/tabs/utils.test.ts (2)
apps/desktop/src/shared/types.ts (1)
  • MosaicNode (35-35)
apps/desktop/src/renderer/stores/tabs/utils.ts (1)
  • findPanePath (203-225)
apps/desktop/src/renderer/stores/tabs/utils.ts (1)
apps/desktop/src/shared/types.ts (1)
  • MosaicNode (35-35)
apps/desktop/src/renderer/screens/main/index.tsx (4)
apps/desktop/src/renderer/stores/tabs/store.ts (1)
  • useWindowsStore (78-561)
apps/desktop/src/renderer/stores/tabs/types.ts (1)
  • Window (25-31)
apps/desktop/src/renderer/stores/tabs/utils.ts (2)
  • findPanePath (203-225)
  • getFirstPaneId (192-197)
apps/desktop/src/renderer/stores/tabs/pane-refs.ts (1)
  • getPaneDimensions (13-20)
⏰ 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). (1)
  • GitHub Check: Build
🔇 Additional comments (2)
apps/desktop/src/renderer/stores/tabs/utils.ts (1)

1-1: Pane path helper logic looks solid

The findPanePath helper correctly handles leaf and parent nodes, returns [] for a root leaf, and short‑circuits as soon as it finds a match. The traversal and return type line up with how split operations consume the path, and there are no obvious edge‑case or performance issues for typical layout depths.

Also applies to: 199-225

apps/desktop/src/shared/hotkeys.ts (1)

93-109: Layout hotkey remaps and SPLIT_AUTO definition look consistent

The updated keybindings for SPLIT_RIGHT, SPLIT_DOWN, and the reintroduced SPLIT_AUTO are self‑consistent, don’t collide with existing shortcuts in this table, and keep labels/descriptions aligned with the intended behavior.

@AviPeltz AviPeltz changed the title change split commands back & make more robust fix: change split commands back & make more robust Dec 5, 2025
@AviPeltz AviPeltz changed the title fix: change split commands back & make more robust fix(desktop): change split commands back & make more robust Dec 5, 2025
@AviPeltz AviPeltz merged commit 996e53e into main Dec 5, 2025
7 checks passed
@Kitenite Kitenite deleted the inherent-gerbil-a76172 branch December 7, 2025 01:58
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