Skip to content

tui: selectable + clickable permission popup#232

Merged
gnanam1990 merged 1 commit into
mainfrom
fix/permission-popup-clickable
Jun 17, 2026
Merged

tui: selectable + clickable permission popup#232
gnanam1990 merged 1 commit into
mainfrom
fix/permission-popup-clickable

Conversation

@gnanam1990

@gnanam1990 gnanam1990 commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Makes the permission prompt navigable and clickable, on top of the existing a/y/d hotkeys (which still resolve directly):

  • ↑/↓ and Tab/Shift+Tab move the highlight across allow once / always / deny (resting default: allow once); Enter confirms the highlighted option.
  • Each option renders on its own row, and a left-click on a row resolves that choice directly — no per-column hit-testing.

Re-ports a local feature onto current main, adapted to main's refactored row-based selection layer (transcriptBodyItem render closures + layout.selectable).

How it works

  • permission_prompt.gopermissionOptions + cursor clamp/move/confirm helpers (the cursor lives on the pending prompt).
  • model.gopendingPermissionPrompt gains a cursor; Enter → confirmPermissionCursor, ↑/↓/Tab → movePermissionCursor; a/y/d unchanged and still ignore the cursor.
  • rendering.gorenderFocusedPermissionPrompt now renders one row per option with the cursor highlighted ( + reverse label) and returns each option's card-relative Y offset so the caller can register clickable rows.
  • transcript_selection.gotranscriptSelectableLine gains permOption/permChoice; the pending-permission item registers each option row as clickable, and a left-click on one calls resolvePermission.

Tests

  • cursor default (allow once) / move / wrap; Enter confirms the highlight; a/y/d still resolve directly; render emits highlighted clickable offsets that map to the right rows.
  • Existing card + submit-block tests updated for the per-option layout and Enter-confirms-the-highlight behavior.
  • Gate: gofmt, go vet, go build (host/linux/windows), go test ./internal/tui -race, staticcheck — all green (the two unused-func nits are pre-existing on main).

Note

Keyboard nav + the offset→row mapping are covered by tests; the end-to-end mouse click on an option is best confirmed interactively in a real terminal.

Summary by CodeRabbit

Release Notes

  • New Features
    • Permission prompt now supports keyboard navigation using Tab, Shift+Tab, and arrow keys to select between options
    • Added visual highlighting to indicate the currently selected permission choice
    • Permission options are now clickable with mouse support for direct selection
    • Improved permission prompt layout with each option displayed as a separate, selectable line

The permission prompt now has a moving cursor and clickable options, on top of
the existing a/y/d hotkeys (which still resolve directly):
- ↑/↓ and Tab/Shift+Tab move the highlight across allow once / always / deny
  (resting default: allow once); Enter confirms the highlighted option.
- each option is rendered on its own row, and a left-click on a row resolves
  that choice directly.

- permission_prompt.go: permissionOptions + cursor move/clamp/confirm helpers.
- model.go: pendingPermissionPrompt gains a cursor; Enter confirms it, ↑/↓/Tab
  move it; a/y/d are unchanged.
- rendering.go: renderFocusedPermissionPrompt renders per-option rows with the
  cursor highlighted (▸ + reverse label) and returns each option's card-relative
  Y offset so the caller can register clickable rows.
- transcript_selection.go: transcriptSelectableLine gains permOption/permChoice;
  the pending-permission item registers each option row as clickable, and a
  left-click on one resolves the permission.

Tests: cursor default/move/wrap, Enter confirms the highlight, hotkeys still
resolve directly, render emits highlighted clickable offsets. Existing card/
submit-block tests updated for the new per-option layout + Enter-confirms.
@github-actions

Copy link
Copy Markdown
Contributor

Zero automated PR review

Verdict: No blockers found

Blockers

  • None found.

Validation

  • [pass] Diff hygiene: git diff --check
  • [pass] Tests: go test ./...
  • [pass] Build: go run ./cmd/zero-release build
  • [pass] Smoke build: go run ./cmd/zero-release smoke

Scope

Head: e4d6d59b218a
Changed files (7): internal/tui/model.go, internal/tui/model_test.go, internal/tui/permission_prompt.go, internal/tui/permission_prompt_test.go, internal/tui/rendering.go, internal/tui/rendering_lime_test.go, internal/tui/transcript_selection.go

This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 79b0088a-e211-4ecf-b640-7a03c6889d93

📥 Commits

Reviewing files that changed from the base of the PR and between 0b496ce and e4d6d59.

📒 Files selected for processing (7)
  • internal/tui/model.go
  • internal/tui/model_test.go
  • internal/tui/permission_prompt.go
  • internal/tui/permission_prompt_test.go
  • internal/tui/rendering.go
  • internal/tui/rendering_lime_test.go
  • internal/tui/transcript_selection.go

Walkthrough

Adds cursor-based keyboard navigation (Tab, Shift+Tab, Up/Down, Enter) and mouse-click support to the TUI permission prompt. A new permission_prompt.go file defines the ordered option set and cursor operations. The renderer is updated to emit one line per option with Y-offsets, and transcript_selection.go uses those offsets to make each option directly clickable.

Changes

Permission Prompt Cursor Navigation and Mouse Support

Layer / File(s) Summary
Permission option model and cursor operations
internal/tui/permission_prompt.go, internal/tui/model.go, internal/tui/permission_prompt_test.go
Defines permissionOption and permissionOptions(), adds cursor int to pendingPermissionPrompt, implements clampPermissionCursor, movePermissionCursor (wrap-around), and confirmPermissionCursor. New tests cover default cursor, Up/Down movement, wrap, hotkey bypass, and rendering offsets.
Key binding wiring in TUI input loop
internal/tui/model.go, internal/tui/model_test.go
Wires Enter, Tab, Shift+Tab, Up, and Down to the cursor operations when a permission prompt is active. Test assertions updated to expect Enter to synchronously resolve "allow once" and clear the prompt.
Per-option renderer with Y-offsets
internal/tui/rendering.go, internal/tui/rendering_lime_test.go
Changes renderFocusedPermissionPrompt to return (string, []int) and accept a cursor, replacing the single-row chip with a per-option loop that emits a marker on the highlighted line and computes card-relative Y-offsets. Rendering test validates offset count and highlighted line content.
Mouse click resolution via transcript_selection
internal/tui/transcript_selection.go
Adds permOption/permChoice to transcriptSelectableLine, rebuilds the pending-permission branch to emit one selectable entry per option offset, and extends the left-click handler to call resolvePermission immediately on a permission-option line.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Gitlawb/zero#95: Implemented the initial runtime permission-request/decision wiring and the first version of renderFocusedPermissionPrompt in the same internal/tui/* code paths that this PR extends with cursor navigation and mouse support.

Suggested reviewers

  • Vasanthdev2004
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.71% 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 title accurately summarizes the main change: adding keyboard navigation and click functionality to the permission popup in the TUI.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/permission-popup-clickable

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

@Vasanthdev2004 Vasanthdev2004 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM ? no issues found. The permission popup cursor/click wiring is correct: heightCacheStable is a real field on transcriptBodyItem on main (added by #226), the cursor wraps correctly under Go signed modulo, and the option offsets match the styledBlockFill one-top-border contract.

@Vasanthdev2004 Vasanthdev2004 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM ? no issues found. The permission popup cursor/click wiring is correct: heightCacheStable is a real field on transcriptBodyItem on main (added by #226), the cursor wraps correctly under Go signed modulo, and the option offsets match the styledBlockFill one-top-border contract.

@gnanam1990
gnanam1990 merged commit b1cf248 into main Jun 17, 2026
7 checks passed
@Vasanthdev2004

Copy link
Copy Markdown
Collaborator

Parity check against the reference Droid (D) implementation.

D's SandboxPermissionPrompt offers context-dynamic options: for file-write violations it offers both 'Allow always (writes to )' and 'Allow always (writes to )'; for network violations it offers 'Allow always ()'; for deny-list entries it offers 'Remove from deny list'. See src/sandbox/SandboxPermissionPrompt.ts -> getSandboxPromptOptions. Zero's permissionOptions() is a fixed 3-item list (allow once / always / deny) with no path/domain context in the 'Allow always' label.

This is a known gap, not a bug in this PR's scope. The cursor/wrap/click wiring itself matches D's SandboxViolationPrompt behavior (up/down wraps, Enter confirms the highlighted option).

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