Skip to content

feat(review): ask the agent about lines, with the answer in a box under them - #215

Open
harshavamsi wants to merge 2 commits into
plannotator:mainfrom
harshavamsi:feat/ask-ai
Open

harshavamsi wants to merge 2 commits into
plannotator:mainfrom
harshavamsi:feat/ask-ai

Conversation

@harshavamsi

@harshavamsi harshavamsi commented Nov 26, 2026 •

Copy link
Copy Markdown

For #191.

Problem

In a code review there is no way to ask the agent a question about some lines without
sending a note. A note goes as feedback, and its answer shows only in the agent's pane, far
from the lines. #191 asks for "Ask AI in the review pane".

Change

  • a (ask), or the new ❓ ask button on the toolbar after a drag, opens the comment box
    for a question about the selection or the cursor's line. Enter sends it with the same
    Delivery that Send uses (its size limit and its notice too), with the file, the lines
    and their code. So this is "Ask this session" from Ask AI in the review pane (port from Plannotator) #191: the question and its answer are
    part of the agent's own conversation.
  • The answer is read from the agent's transcript, found the way last finds it
    (last/transcript.rs: a small type on top of locate and the readers, which keeps the
    prompts). Only the agent's own session counts (Discovery::Exact): the newest session in
    a folder is a guess, and another session's answer would show as this one's, so asking
    says so instead. A target that names the agent's process gives the exact session for
    Claude Code, Copilot and Pi: Rex and hc have the pid, and Delivery::agent_pid passes it
    (the Pi target now has it too).
  • Each question has a thread (review/ask/watch.rs) that finds the transcript, notes the
    newest prompt, and only then lets the question go. It then reads the transcript each
    time the file grows. The question is the first prompt after the noted one that holds the
    question's first line and its text, so a prompt typed into the agent meanwhile, or
    another question still in the agent's queue, is not taken for it. The answer is the
    replies up to the next prompt. A failed read is tried again at the next change. Nothing
    is saved: the transcript is the record.
  • The answer shows as it is written in a box under the lines (the inline insets,
    Card::of_thread), whatever the Notes setting. Each message is under who wrote it: You,
    then the agent's host (claude, pi, ...).
  • More questions on those lines, or on lines inside them, go into the same box. Enter or a
    on the box asks again, and the question box opens under the box's end. If that end is
    below the pane, the diff scrolls it into view first. Delete on the box, or on one of its
    lines, removes the box. The border names both keys.
  • Claude Code stores a prompt typed while the agent works as a queued_command
    attachment. claude/entries.rs now reads it as a human prompt, so such a question gets
    its answer. last also shows it now.
  • Codex is refused with a message: its reader returns only the replies of the newest turn,
    so the question cannot be found there.
  • Keys: ask on a, in LATE, so an older config that uses a keeps loading.

Not changed: Send, notes and their boxes, the data contract, and the Markdown view (where
a stays "looks good").

Testing

  • review/tests/ask_flow.rs, one test each:
    • the prompt the agent gets;
    • the answer in a box under line 9, each message under who wrote it;
    • asking again from the box, into the same box, with the question box at the box's end;
    • the question box at the end of an answer taller than the pane;
    • lines inside a box;
    • removing a box from the box and from one of its lines;
    • two questions waiting at once, each getting its own answer;
    • an answer that ends with no text;
    • an Ask box and a note's box on one line;
    • nothing sent without a readable transcript;
    • a Pi transcript;
    • Codex refused.
  • review/ask/watch/tests.rs: how the question and its answer are found, including a prompt
    typed in between and a noted prompt out of reach; Copilot's events.jsonl is watched.
  • plannotator-tui-hosts/tests/claude.rs: a queued prompt is a human prompt, and other
    attachments are not.
  • keys/tests.rs: a config that gave a away still loads.
  • review/tests/mouse_flow.rs: the toolbar's ask button opens the question box.
  • cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings and
    python3 herdr/test-manifest.py: clean. cargo test --workspace: 1,375 passed, 1 failed. The one
    failure, pi::tests::the_review_command_puts_pis_screen_back_and_ends_the_review_with_pi,
    fails the same way on main here: Node 26 has no --experimental-transform-types.
  • The Ask tests passed 100 runs filtered to them (100 of 100). 100 runs of the whole test
    binary: running, and this line will say the result.
  • Used live with Claude Code in Rex: questions about a commit's lines, follow-ups, and
    questions sent while the agent was working.
  • Not tested: Herdr and hc targets live, and agents other than Claude Code live.

Review guide

Read review/ask.rs first (the flow), then review/ask/watch.rs (the thread and how the
answer is found, answer), last/transcript.rs, then the box (review/ask/boxes.rs,
review/ask/text.rs, inline.rs, inline/card.rs, inline/paint.rs) and where the
question box opens (compose_at.rs).

Known limits:

  • Two questions with the same text on the same lines, both waiting at once, are told apart
    by order only.
  • The box cannot tell that an answer is complete until the next prompt comes.
  • Each question's thread reads the whole transcript again on each change (a shortcut:
    comment says when to read only the tail). One watcher for each transcript, serving every
    question, is a follow-up.
  • Droid, Command Code, Antigravity, Hermes and OpenCode have no exact session lookup from
    a pid, so Ask refuses them for now.

…er them

`a` (or the toolbar's ask button after a drag) asks the agent the review sends to about the
selection or the cursor's line. The question goes the way Send goes, with the file, the
lines and their code, so it is part of the agent's own conversation. The answer is read
back from the agent's transcript, found as `last` finds it, on a thread, and shows as it is
written in a box under the lines, whatever the Notes setting. More questions on those lines
go into the same box, and the question box opens at its end.

- A prompt Claude Code queued while it worked (`queued_command`) counts as a prompt.
- Codex is refused: its reader has no prompts to find the question by.
- `Delivery::agent_pid` names the agent's process for Rex and hc targets.
- `remove` also takes Backspace, the Mac's delete key.

Signed-off-by: Harsha Vamsi Kalluri <harshavamsi096@gmail.com>
@harshavamsi
harshavamsi marked this pull request as ready for review November 26, 2026 17:31
…ent's own session

- The question is the first prompt after the noted one that holds the question's first
  line and its text, so a prompt typed meanwhile, or another question still in the agent's
  queue, is not taken for it.
- Only an exact session counts: a folder guess could show another session's answer. The
  Pi target names its process too. The transcript is found for each question.
- An answer that ends with no text says so; a noted prompt out of reach ends the watch; a
  failed read is tried again. Copilot's events.jsonl is the file watched.
- Send's size limit and notice apply. Choosing nothing in the picker drops the question.
- `remove` keeps upstream's keys (no Backspace); `ask` yields `a` to an older config.
- The README's "Pick what to review" heading is back.
- ask.rs is split into boxes.rs, text.rs and watch.rs; threads are named; one card cache.

Signed-off-by: Harsha Vamsi Kalluri <harshavamsi096@gmail.com>
@harshavamsi

Copy link
Copy Markdown
Author

AI disclosure: the code was entirely written with the help of AI agents. I, as a human, planned, tested, and reviewed the code.

@harshavamsi

Copy link
Copy Markdown
Author
image

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