Skip to content

Add diff comments for agent steering - #216

Draft
patrickdappollonio wants to merge 11 commits into
mainfrom
steering-ai-agents-with-pr-review
Draft

Add diff comments for agent steering#216
patrickdappollonio wants to merge 11 commits into
mainfrom
steering-ai-agents-with-pr-review

Conversation

@patrickdappollonio

Copy link
Copy Markdown
Owner

This adds inline comments to diff lines so users can queue review-style steering notes for the selected agent session. Comments include the file, line number, side, and saved line contents so the generated prompt has enough context even when the diff shifts.

Queued comments are stored per agent session in SQLite and recover after restarting the app. Matching comments render inline in the diff, while comments whose saved line no longer appears are shown as orphaned comments in the diff pane.

The flow uses the existing configurable keybinding and PTY steering model: users can add or edit comments, dismiss a highlighted line comment or orphaned comment, and send the queued comments to the running agent when they decide it is ready.

@patrickdappollonio
patrickdappollonio force-pushed the steering-ai-agents-with-pr-review branch 6 times, most recently from a8bc9aa to 4bfb487 Compare May 11, 2026 07:26
@sirpalee

Copy link
Copy Markdown

Tested with codex and it's passing the comments nicely to the agent, but I noticed that if the comment is too long, it is not displayed correctly. It stops at the end, you can still keep typing, and the text is preserved, but what you type is not visible.

It would be great if either the text scrolled or the comment box grew vertically when your text is too long.

This is on Linux + Wezterm.

@patrickdappollonio
patrickdappollonio force-pushed the steering-ai-agents-with-pr-review branch 2 times, most recently from e0ba882 to 395de74 Compare May 15, 2026 07:54
@patrickdappollonio

Copy link
Copy Markdown
Owner Author

@sirpalee thank you so much for testing! I often leave in draft those PRs that aren't fully feature complete and still working on them. I'm getting a bit more comfortable on this one and I've been running this locally for a bit. I've made quite a few changes, and I definitely wouldn't mind another pair of eyes on this!

Diff comments need to survive app restarts and still give users control when their line anchor no longer matches the current diff. This stores comments per agent session, renders matching comments inline, shows unmatched comments in the diff pane, and sends the queued review prompt through the existing PTY steering path.

Constraint: Comments must work with generic CLI providers through PTY input only

Constraint: Diff comment controls must remain configurable through the existing keybinding system

Rejected: Send every comment immediately | the app cannot reliably know whether the agent is accepting text or waiting for a choice

Confidence: medium

Scope-risk: moderate

Directive: Keep comment persistence and steering generic; do not add provider-specific protocols for this flow

Tested: cargo fmt --check; cargo clippy --all-targets --all-features -- -D warnings; cargo test

Not-tested: Manual interactive TUI smoke run
Diff comments now persist with line anchors, render inline in the fullscreen diff, and can be sent as a configured prompt to the selected agent once it is ready. The diff view reuses existing fullscreen, text input, scroll indicator, and footer patterns so the new workflow behaves like the rest of dux.

Constraint: Steering text must not be injected while an agent is still streaming or unavailable
Constraint: Diff comment prompts need configurable formatting before the PR ships
Rejected: Modal comment input | inline editing matches the diff workflow and avoids extra surface area
Rejected: Store prompt formatting under UI config | it is prompt behavior, so it belongs with defaults
Confidence: high
Scope-risk: moderate
Directive: Keep diff footer hints focused on actions; scrolling state belongs in the floating scroll indicator
Tested: cargo fmt --check; cargo clippy --all-targets --all-features -- -D warnings; cargo test diff_comment; cargo test mouse_wheel_center_diff_scrolls_lines; cargo test
The diff footer now advertises only actions that are valid in the current state: Ctrl+D appears only when a comment can be deleted or dismissed, and the close hint uses the fullscreen diff close binding instead of the generic overlay key.

Constraint: Footer hints should match the actual action taken by the displayed key
Rejected: Showing Esc as the close hint | Ctrl+G is the fullscreen close convention used by diff, agents, and terminals
Confidence: high
Scope-risk: narrow
Tested: cargo fmt --check; cargo clippy --all-targets --all-features -- -D warnings; cargo test diff_comment
Diff comments now appear as file-list metadata so reviewers can see where feedback is queued without opening every diff. The count is scoped to the selected session and matching file path.

Constraint: The project requires unit coverage for behavior changes.

Confidence: high

Scope-risk: narrow

Tested: cargo fmt --check; cargo test diff_comment_count_for_path_counts_selected_session_matching_file_only; cargo test file_row_metadata_joins_comment_count_and_stats; cargo test diff_comment; cargo clippy --all-targets --all-features -- -D warnings; cargo test; git diff --check
The queued comment indicator now uses the solid flag glyph in both diff rows and file-list metadata, keeping the visual language consistent across the PR review flow.

Confidence: high

Scope-risk: narrow

Tested: cargo fmt --check; cargo test file_row_metadata_joins_comment_count_and_stats; cargo test diff_comment
The agent fullscreen hint bar now surfaces the configured send-diff-comments key when comments are queued, matching how the macro key is exposed while interactive input is active.

Constraint: The send action must remain configurable and usable from fullscreen agent mode.

Confidence: high

Scope-risk: narrow

Tested: cargo fmt --check; cargo test fullscreen_agent_shows_configured_send_diff_comments_hint; cargo test diff_comment
@patrickdappollonio
patrickdappollonio force-pushed the steering-ai-agents-with-pr-review branch from 33bfce9 to 3398a06 Compare May 17, 2026 04:23
Diff comments now stay visible inline, use the shared text-input styling, and can be sent from both the diff and fullscreen agent paths with a tmux-friendly keybinding.

Constraint: Fullscreen agent mode sees raw terminal bytes rather than crossterm key events.

Constraint: Ctrl+Shift letter bindings collapsed under tmux/iTerm during testing.

Rejected: Keep tmux-specific passthrough setup | too fragile for this PR.

Rejected: Keep Ctrl+Y or Ctrl+^ | conflicted with terminal behavior or produced confusing reporting.

Confidence: high

Scope-risk: moderate

Directive: Preserve the raw-byte interception path when changing interactive agent keybindings.

Tested: cargo fmt --check; cargo check; cargo test keybindings::tests; focused diff comment and keybinding tests; git diff --check

Not-tested: Manual tmux run after the final Ctrl-; and Ctrl-: binding change
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