Skip to content

ADFA-6276 | Allow editing sent prompts and branching chat versions - #115

Merged
jatezzz merged 4 commits into
mainfrom
feat/ADFA-6276-edit-last-prompt
Oct 5, 2026
Merged

jatezzz merged 4 commits into
mainfrom
feat/ADFA-6276-edit-last-prompt

Conversation

@jatezzz

@jatezzz jatezzz commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR allows users to edit a prompt they have already sent to the agent. If the user edits their most recent message, the original prompt and everything after it are removed, and the agent runs on the edited text. If they edit an older message, it creates a new branch or version of the conversation from that point instead of discarding the original.

Details

  • Added an Edit action to user messages, which places the prompt and its attached context files back into the composer.
  • Introduced a pulsing blue border to indicate the message currently being edited.
  • Implemented ChatBranches and PromptEdit utilities to manage conversation tree logic, history rewinds, and switching between prompt versions.
  • Added previous_version and next_version navigation arrows to switch between branches of an older edited message.
  • Added an "Editing message" banner with a cancel button that reverts the input field back to its previous draft.
  • Added unit tests to cover chat branch switching, history rewinding, and view model edit handling.

Demo

https://drive.google.com/file/d/1hblBbmvyO4X7tJRNgAW2rsAG0UmINamw/view?usp=sharing

Ticket

ADFA-6276

Observation

Changes to files made by the agent in a discarded run are not automatically undone. Edit and version actions are hidden or disabled while the agent is actively generating or waiting on a tool approval.

@jatezzz
jatezzz requested review from a team, Daniel-ADFA and itsaky-adfa October 1, 2026 17:49
Edit loads a prompt and its files into the composer, pulsing its bubble; sending replaces the latest prompt or forks an earlier one, chevrons switch versions, and history commits on Main so Stop, clear or a chat switch can't race the run.

Refs: ADFA-6276
@jatezzz
jatezzz force-pushed the feat/ADFA-6276-edit-last-prompt branch from ef815ee to 39876ae Compare October 1, 2026 20:14

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

IMPORTANT

  • ChatFragment.kt:210 - a tab switch ends edit mode but keeps the edited text, so Send appends a new prompt
  • ChatViewModel.kt:335 - after Stop, Edit is offered while isGenerating still refuses it

MINOR

  • ChatViewModel.kt:2348 - finalizeInProgressMessages removes messages without relinking stored versions

NITPICK - 1 inline, not listed

ADFA-6276 acceptance criteria, against the code at this head:

  • Edit is shown on user messages only, and Cancel leaves the transcript and history untouched.
  • Confirming cuts the transcript and the model's history. Covered by givenAFinishedRun_whenEditingItsPrompt_thenTheNextRunStartsFromBeforeIt and the fork tests.
  • Edit is hidden while the agent is generating or waiting for approval, except in the window after Stop described at ChatViewModel.kt:335.
  • Edits survive reopening the chat (givenARewind_whenTheChatIsReopened_thenTheDiscardedPromptIsGone).
  • Tooltips are registered for Edit and the version switcher, and the Tier 2 text says file changes are not undone. I did not long-press them on a device.
  • The new strings are in strings.xml, and the tests use the givenX_whenY_thenZ names.
  • Scope: the ticket limited a first version to the newest prompt. Editing older prompts here keeps the original as a version instead of discarding it, so the confirmation step the ticket wanted for that case is not needed.

Checked and not posted:

  • Editing a newest prompt that is itself a version replaces it. That is the documented rule, and givenTheNewestPromptIsAVersion_whenEditingIt_thenItIsReplacedAndTheOriginalVersionStays covers it.
  • The composer can fold away during an edit with blank text. The banner folds with it and comes back when the composer reopens.
  • removeFromScreen uses mapKeys, so two collapsed keys can overwrite each other. I found no way for a current caller to remove two keyed messages at once.
  • rewind drops the generated title while other versions of the first prompt are still stored, whereas a fork keeps it. I read that as a design choice, not a defect.
  • Per-token work in promptVersions: an id list per emission. Small next to the per-token rendering.

Not verified on a device. Findings come from reading this head together with CoGo's EditorBottomSheetTabAdapter and GradleSyncHandler.

This repo has no written approve or request-changes rule, so these findings are graded against the default scale.

Restore an in-progress edit from saved state, gate Edit on isGenerating, relink versions when Stop drops empty bubbles, share showTranscript.

Refs: ADFA-6276
@jatezzz
jatezzz requested a review from Daniel-ADFA October 2, 2026 13:37
Resolve ChatViewModel against main's prompt/ extraction, use runFiles
for context files and the web check, and preload prompt config in tests.

Refs: ADFA-6276
plugin-api's PromptConfigStore logs through slf4j, which only the host provides.

Refs: ADFA-6276
@jatezzz
jatezzz merged commit 486e8fc into main Oct 5, 2026
1 check passed
@jatezzz
jatezzz deleted the feat/ADFA-6276-edit-last-prompt branch October 5, 2026 13:32
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