Skip to content

fix(tui): scroll setup agent selection#538

Open
daniel-baf wants to merge 2 commits into
Gentleman-Programming:mainfrom
daniel-baf:fix/setup-scroll-multiselect
Open

fix(tui): scroll setup agent selection#538
daniel-baf wants to merge 2 commits into
Gentleman-Programming:mainfrom
daniel-baf:fix/setup-scroll-multiselect

Conversation

@daniel-baf

@daniel-baf daniel-baf commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

🔗 Linked Issue

Closes #199

Scope note: this PR does not have a separately approved ticket. It is a small terminal usability fix for the setup-agent list expanded by #493 / #199: once more editors were added, short terminals could not reach every option cleanly. Keeping it linked here preserves the approved issue workflow while documenting that this is follow-up polish, not new product scope.


🏷️ PR Type

  • type:bug — Bug fix
  • type:feature — New feature
  • type:docs — Documentation only
  • type:refactor — Code refactoring (no behavior change)
  • type:chore — Maintenance, dependencies, tooling
  • type:breaking-change — Breaking change

📝 Summary

  • Makes the TUI setup-agent list scroll when the terminal is short, instead of rendering every editor option off-screen.
  • Adds checkbox-style multi-select with space, while keeping enter compatible with single-item installs when nothing is selected.
  • Preserves the Claude Code allowlist prompt when Claude Code is part of a multi-install.

📂 Changes

File Change
internal/tui/model.go Adds setup selection/scroll state and a sequential multi-agent install command.
internal/tui/update.go Handles setup scrolling, multi-select toggles, selected-agent install order, and scroll reset.
internal/tui/view.go Renders only the visible setup-agent window with checkbox state and scroll indicators.
internal/tui/update_test.go Covers setup scrolling, selection toggles, and multi-install aggregation.
internal/tui/view_test.go Covers short-terminal rendering and scroll indicators.

🧪 Test Plan

  • Unit tests pass locally: GOCACHE=/tmp/engram-go-build go test ./...
  • E2E tests pass locally: GOCACHE=/tmp/engram-go-build go test -tags e2e ./internal/server/...
  • Manually tested the affected functionality

Manual verification:

  • Tested engram tui with a temporary HOME and a short/shrunk terminal.
  • Verified j/k scrolls through 12 setup agents without printing all options at once.
  • Verified space can select multiple agents and the selected count appears.
  • Verified the visible window updates from showing 7-8 of 12 in a very short terminal to showing 7-12 of 12 after expanding height.

Screenshot evidence from local manual test:

image image

🤖 Automated Checks

These run automatically and all must pass before merge:

Check What it verifies Status
Check Issue Reference PR body contains Closes #N / Fixes #N / Resolves #N
Check Issue Has status:approved Linked issue has status:approved label
Check PR Has type:* Label PR has exactly one type:* label
Unit Tests go test ./... passes
E2E Tests go test -tags e2e ./internal/server/... passes

✅ Contributor Checklist

  • I linked an approved issue above (Closes #199)
  • I added exactly one type:* label to this PR (needs maintainer: type:bug; GitHub rejected label edit for this fork user)
  • I ran unit tests locally: go test ./...
  • I ran e2e tests locally: go test -tags e2e ./internal/server/...
  • Docs updated (if behavior changed)
  • Commits follow conventional commits format
  • No Co-Authored-By trailers in commits

💬 Notes for Reviewers

The setup screen still installs the current cursor item when no checkboxes are selected, so existing keyboard behavior remains available. Multi-install is sequential rather than batched because the current setup result UI has one installation/result state.

Maintainer action needed: add exactly one PR label, type:bug. The fork author account could open the PR but GitHub rejected AddLabelsToLabelable for the upstream repo.

Summary by CodeRabbit

  • New Features
    • Added multi-agent selection in the setup screen (space to select multiple, enter to install together).
    • Enabled paginated scrolling with a “showing X–Y of Z” indicator and an “N selected” summary.
    • Install output now reflects combined results across multiple agents, including the allowlist requirement when needed.
  • Bug Fixes
    • Improved setup success rendering to safely handle empty results.
  • Tests
    • Expanded coverage for multi-select, scrolling behavior, allowlist prompt flow, and partial-failure install aggregation.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The TUI setup screen gains multi-agent selection (space-bar toggling with checkboxes), paginated scrolling, and aggregated install results. The Model struct, setupInstallMsg, installAgents, key-handling logic, and view renderer are all updated together, with corresponding tests added.

Changes

Multi-agent setup screen

Layer / File(s) Summary
Model state and message contracts
internal/tui/model.go, internal/tui/model_test.go
Adds SetupSelectedAgents map[string]bool and SetupScroll int to Model; extends setupInstallMsg with needsAllowlist bool; imports fmt and strings.
Multi-agent install command logic
internal/tui/model.go, internal/tui/model_test.go
Rewrites installAgent to set needsAllowlist for claude-code; rewrites installAgents to validate selection, loop per agent, aggregate results and file counts, detect needsAllowlist, and synthesize a combined setup.Result for multiple agents; adds test for partial-failure aggregation.
Setup screen initialization, key handling, and helpers
internal/tui/update.go, internal/tui/update_test.go
Resets SetupScroll and initializes SetupSelectedAgents on screen entry; replaces single-agent enter with space-toggle multi-select and comma-joined install name; adds clampSetupScroll, selectedSetupAgentNames, and setupVisibleAgents helpers; switches allowlist condition to msg.needsAllowlist; validates space-toggle, multi-select install order, and allowlist prompt gating.
Paginated agent list with checkboxes
internal/tui/view.go, internal/tui/view_test.go
Replaces the flat agent loop with a scroll-clamped visible window rendering [ ]/[x] checkboxes, appends "showing X–Y of Z" and "N selected" summary lines, updates help text to include space select; tests scroll window clipping and partial success result rendering.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

type:feature

🚥 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%. 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 PR title directly describes the main change: adding scrolling functionality to the setup agent selection interface. It is concise, specific, and aligns with the primary objective of fixing the terminal usability issue.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@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.

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@internal/tui/model.go`:
- Around line 254-266: The installAgentFn loop has an early return on error that
discards results from already-installed agents. Instead of immediately returning
setupInstallMsg{err: err} when installAgentFn returns an error, collect the
error and continue iterating through the remaining agents in the names slice.
Aggregate both successful installation results and per-agent errors, then return
a setupInstallMsg that includes all results that succeeded along with
information about which agents failed, ensuring users know which agents were
installed before the error occurred.
- Around line 272-278: In the multi-agent installation result synthesis (the
setupInstallMsg return statement), two issues need to be fixed: First, add a
TUIPluginEnabled field to the returned setup.Result by iterating through the
results slice and OR-ing together all TUIPluginEnabled values from each result
to preserve this flag across multi-agent installs. Second, build the Agent
string by joining the agent names extracted from the results slice instead of
using the original names slice, ensuring that only agents with successful
results are included in the summary message.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 94eafdd9-b851-421d-808e-fbba534c02a5

📥 Commits

Reviewing files that changed from the base of the PR and between 44faeee and 315a689.

📒 Files selected for processing (5)
  • internal/tui/model.go
  • internal/tui/update.go
  • internal/tui/update_test.go
  • internal/tui/view.go
  • internal/tui/view_test.go

Comment thread internal/tui/model.go
Comment thread internal/tui/model.go Outdated

@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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@internal/tui/model.go`:
- Around line 257-259: The setupInstallMsg being returned at line 257 in the
aggregateSetupResults condition includes both an error (err) and needsAllowlist
flag set to true. However, the update.go error handler processes msg.err first
and exits before checking msg.needsAllowlist, making the allowlist prompt
unreachable in partial-failure scenarios. To fix this, modify the return
statement in the aggregateSetupResults check to not include the error in
setupInstallMsg when needsAllowlist is true, so that the allowlist prompt
handling takes precedence over error handling. This ensures the multi-select
allowlist contract is maintained even when partial failures occur.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6ddf81cf-a0fa-4134-b606-21f33abd7104

📥 Commits

Reviewing files that changed from the base of the PR and between 315a689 and fa87d61.

📒 Files selected for processing (6)
  • internal/tui/model.go
  • internal/tui/model_test.go
  • internal/tui/update.go
  • internal/tui/update_test.go
  • internal/tui/view.go
  • internal/tui/view_test.go

Comment thread internal/tui/model.go
Comment on lines +257 to +259
if partial := aggregateSetupResults(results, totalFiles); partial != nil {
return setupInstallMsg{result: partial, err: err, needsAllowlist: needsAllowlist}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Allowlist prompt is unreachable on partial-failure path.

Line 257 returns setupInstallMsg with both err and needsAllowlist, but internal/tui/update.go handles msg.err first and exits before checking msg.needsAllowlist. That means a successful claude-code install in a partial-failure batch will not surface the allowlist prompt, breaking the multi-select allowlist contract.

🤖 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 `@internal/tui/model.go` around lines 257 - 259, The setupInstallMsg being
returned at line 257 in the aggregateSetupResults condition includes both an
error (err) and needsAllowlist flag set to true. However, the update.go error
handler processes msg.err first and exits before checking msg.needsAllowlist,
making the allowlist prompt unreachable in partial-failure scenarios. To fix
this, modify the return statement in the aggregateSetupResults check to not
include the error in setupInstallMsg when needsAllowlist is true, so that the
allowlist prompt handling takes precedence over error handling. This ensures the
multi-select allowlist contract is maintained even when partial failures occur.

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.

feat(setup): add native setup support for additional agents using gentle-ai adapter mappings

1 participant