Skip to content

fix av switch hiding branches in tall stacks - #796

Merged
aviator-app[bot] merged 1 commit into
masterfrom
fix/switch-scroll-tall-stacks
Oct 8, 2026
Merged

aviator-app[bot] merged 1 commit into
masterfrom
fix/switch-scroll-tall-stacks

Conversation

@simsinght

@simsinght simsinght commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Reported on Discord: in a 12-branch stack in a ~20-row terminal, av switch only showed av-stack-04 and below (and no header), but the hidden branches were still selectable.

Bubbletea v2's inline renderer drops the top lines of any frame taller than the terminal, and av switch rendered the whole tree without handling WindowSizeMsg. The tree now scrolls to keep the selected branch on screen, with the header and help line always visible. When the tree fits, output is unchanged.

Also accepts esc to cancel av switch, and its help line now says esc cancel. Other prompts are unchanged since they still only accept ctrl+c.

Adds stackutils.RenderTreeWithLineRanges so the view knows which lines each branch occupies; RenderTree output is unchanged.

Follow-up, not in this PR: adopt_tree_selector likely has the same tall-tree issue.

Tested: TestSwitchViewScrollsToChosenBranch (fails on master: 41 lines vs a 20-row limit), TestSwitchViewEscCancels, and manually in a 20-row tmux pane with the reported stack.

Summary by CodeRabbit

  • Usability
    • The branch switch screen now keeps the selected branch visible as you navigate, including when the terminal is resized.
    • Press Escape or Ctrl+C to cancel switching.
    • The screen displays contextual status information and help for its available controls.

Bubbletea drops the top of any frame taller than the terminal, so in a
stack that didn't fit, branches above the cutoff were invisible but still
selectable. Scroll the tree to keep the chosen branch on screen, keeping
the header and help line visible.

Also accept esc to cancel, and show it in the help line.
@simsinght
simsinght requested a review from a team as a code owner October 7, 2026 22:47
@aviator-app

aviator-app Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged using Aviator (commit 6e88f3e).


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

@aviator-app

aviator-app Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ FlexReview Status

Common Owner: aviator-co/engineering (expert-load-balance assignment)
Owner and Assignment:

  • ✅ aviator-co/engineering (expert-load-balance assignment)
    Owned Files
    • 🔒 cmd/av/switch.go
    • 🔒 cmd/av/switch_test.go
    • 🔒 internal/utils/stackutils/render_tree.go

Review SLO: 7 business hours if PR size is <= 200 LOC for the first response.

@aviator-app
aviator-app Bot requested a review from jainankit October 7, 2026 22:47
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b5001bad-7f24-481f-89ee-f633eb43920e
📥 Commits

Reviewing files that changed from the base of the PR and between 6a11f1e and 43eba41.

📒 Files selected for processing (3)
  • cmd/av/switch.go
  • cmd/av/switch_test.go
  • internal/utils/stackutils/render_tree.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The switch view now keeps the selected branch in the visible tree viewport, updates the viewport on navigation and resize, and accepts Escape as a cancel key. The tree renderer can return line ranges for rendered branches.

Changes

Switch view

Layer / File(s) Summary
Track rendered branch line ranges
internal/utils/stackutils/render_tree.go
RenderTreeWithLineRanges returns the rendered tree and a line range for each branch. The existing RenderTree uses the renderer without range tracking.
Keep the selected branch visible
cmd/av/switch.go, cmd/av/switch_test.go
The switch view uses branch ranges to limit the tree to the visible viewport and adjusts its scroll offset on navigation and resize. Escape and Ctrl+C both cancel. Tests check branch visibility while scrolling and cancellation with Escape.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant KeyInput
  participant SwitchViewModel
  participant RenderTreeWithLineRanges
  participant TerminalView
  KeyInput->>SwitchViewModel: Send selection or resize message
  SwitchViewModel->>RenderTreeWithLineRanges: Render tree and collect branch ranges
  RenderTreeWithLineRanges-->>SwitchViewModel: Return tree lines and branch ranges
  SwitchViewModel->>TerminalView: Display visible tree lines and help bindings
Loading

Suggested reviewers: tulioz

Merge Risk: ⚪ Minimal · up to 43eba

No confirmed issue blocks merging after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing hidden branches in av switch for tall stacks.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@aviator-app
aviator-app Bot merged commit 6e88f3e into master Oct 8, 2026
6 checks passed
@aviator-app
aviator-app Bot deleted the fix/switch-scroll-tall-stacks branch October 8, 2026 17:30
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