Skip to content

⚡ Bolt: [performance improvement] - #383

Open
Lucenx9 wants to merge 1 commit into
mainfrom
bolt-optimize-pane-tree-search-5271728735500450484
Open

⚡ Bolt: [performance improvement]#383
Lucenx9 wants to merge 1 commit into
mainfrom
bolt-optimize-pane-tree-search-5271728735500450484

Conversation

@Lucenx9

@Lucenx9 Lucenx9 commented Jul 28, 2026

Copy link
Copy Markdown
Owner

💡 What: Changed push_tab_to_leaf to return a Result<(), SurfaceId> instead of bool to thread the ownership of new_tab_id through the recursive search of PaneNode child nodes.
🎯 Why: The previous code cloned SurfaceId (a heap allocated String type) inside a .any() closure when searching the PaneNode::Split children array. This resulted in eager O(N) allocations for every single child node checked, even if the node was ultimately not a match.
📊 Impact: Reduces GC and memory allocation pressure by turning O(N) heap allocations into zero allocations during the search algorithm.
🔬 Measurement: The performance improvement can be measured via flamegraphs or memory profilers when extensively opening, closing, or rearranging tabs to observe reduced time spent in string clone operations.


PR created automatically by Jules for task 5271728735500450484 started by @Lucenx9

Summary

  • Refactors recursive tab insertion to return Result<(), SurfaceId>, transferring ownership without repeated SurfaceId clones.
  • Preserves tab insertion and focus behavior while reducing allocations during pane-tree traversal.
  • No GTK/VTE or socket behavior changes.
  • No tests or security/privacy changes identified.

Co-authored-by: Lucenx9 <185146821+Lucenx9@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The recursive pane-tree tab insertion function now returns Result<(), SurfaceId>, threading ownership through failed searches instead of cloning. WorkspaceModel::add_tab handles the new result contract, and .jules/bolt.md documents the pattern.

Changes

Tab insertion refactor

Layer / File(s) Summary
Result-based tab insertion
crates/forktty-core/src/model/pane_tree.rs, crates/forktty-core/src/model.rs, .jules/bolt.md
push_tab_to_leaf propagates SurfaceId through Err on failed traversal, while add_tab checks .is_err() and the ownership pattern is documented.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: rust

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is too generic and does not clearly describe the affected area or main change. Use a concise descriptive title that mentions the Rust pane-tree/tab ownership optimization, such as avoiding SurfaceId cloning in push_tab_to_leaf.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.
Privacy Boundary ✅ Passed PASS: Diff only refactors pane-tree tab insertion and add_tab control flow; no telemetry, network, or new persistence paths were added.
Terminal Command Safety ✅ Passed No PTY/socket/shell/worktree/notification command-execution code changed; the patch only refactors pane-tree tab insertion and a doc note.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bolt-optimize-pane-tree-search-5271728735500450484

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3c3b90ec64

ℹ️ 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".

Comment thread .jules/bolt.md
@@ -0,0 +1,3 @@
## 2026-07-28 - Avoid eager cloning in recursive search

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove the bot-only root metadata directory

A repo-wide search finds no consumer of .jules/bolt.md, and this commit creates .jules/ solely for a generic bot learning note. This introduces an undocumented top-level content bucket despite the repository contract reserving new root directories for durable project-content categories; omit the note or place genuinely durable documentation under an existing owner.

AGENTS.md reference: AGENTS.md:L131-L131

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
crates/forktty-core/src/model/pane_tree.rs (1)

646-675: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add regression coverage for the returned-ownership path.

The implementation looks correct, but the supplied crates/forktty-core/src/model/tests/pane_tabs.rs test covers only a single leaf. Add a case where the target is in a later split child to verify that Err(id) neither drops nor duplicates the tab ID.

As per coding guidelines, add behavior-boundary tests for model invariants during extraction or refactoring.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/forktty-core/src/model/pane_tree.rs` around lines 646 - 675, Add
regression coverage in the pane-tabs model tests for push_tab_to_leaf when the
target surface is located in a later child of a split node. Verify the returned
ownership path preserves the new tab ID exactly once—without dropping or
duplicating it—and confirm the target leaf becomes active with the inserted tab.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/forktty-core/src/model/pane_tree.rs`:
- Around line 646-675: Add regression coverage in the pane-tabs model tests for
push_tab_to_leaf when the target surface is located in a later child of a split
node. Verify the returned ownership path preserves the new tab ID exactly
once—without dropping or duplicating it—and confirm the target leaf becomes
active with the inserted tab.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f8b32192-b154-4667-a7e1-93c253822c1c

📥 Commits

Reviewing files that changed from the base of the PR and between 5b45feb and 3c3b90e.

📒 Files selected for processing (3)
  • .jules/bolt.md
  • crates/forktty-core/src/model.rs
  • crates/forktty-core/src/model/pane_tree.rs

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