Skip to content

feat(chat): switch between versions and regenerate answers in the web app - #471

Merged
adeelahmad merged 5 commits into
mainfrom
claude/project-thread-r960xc-c2-ui
Oct 17, 2026
Merged

adeelahmad merged 5 commits into
mainfrom
claude/project-thread-r960xc-c2-ui

Conversation

@adeelahmad

Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Stacked on #467 (versions in the backend). Until #467 merges, this diff includes its commit. After that, only the web app commit and a cherry-picked test fix remain.

Before: "Try another model" asked the question again as a new pair at the end of the conversation. Edit said it would replace the answer and everything after it. There was no way to see earlier versions.

After:

  • Regenerate is an icon button on every finished answer. It writes a new answer to the same question, which streams in place of the old one. Its menu, "Regenerate with…", offers the other models, and it replaces "Try another model".
  • Edit on a question makes a new version beside it. The new answer streams in place, and the editor now says the old version stays.
  • ‹ 2 / 3 › appears under a question or an answer that has versions. It moves between them, and so do the arrow keys while it has focus. Each version shows what followed it.
  • Switching to a version you've already seen shows it at once, then PUT /chats/{cid}/head saves the choice. A version not seen yet loads from that call.
  • The next question goes on from the version showing (parent = the last message shown).
  • An approval shows in the version it was proposed in, using tree timestamps.
  • Retry on a failed answer now regenerates it as a version instead of asking again at the end.
  • /clear and /compact replies get no Regenerate, since the model never answered them.

How: components/chat/versions.tsx holds the switch and pure tree helpers (versionsOf, newestBelow, lineage, switched) that mirror the backend. chat-app.tsx passes regenerate / edit / parent and switches the version. The answer being written streams in place of the message it is a version of (live.beside).

Also cherry-picks f6fd6c7 from #470 (test_daily_notes failed on 2026-10-17). It drops out once #470 is in main.

Motivation and Context

Part of the chat gaps Adeel listed: regenerate, navigating the response tree, and carrying on from any version. This is module C2 of the plan, web app part.

Screenshots (if appropriate):

Steps to reproduce (if appropriate):

  1. Ask a question, then press Regenerate under the answer. The new answer streams in place, and ‹ 2 / 2 › appears under it.
  2. Press ‹. The first answer shows again, with what followed it.
  3. Edit the question. ‹ 2 / 2 › appears under it.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests.
  • My change requires documentation updates, and I have updated docs/ accordingly.
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

Done questions (AGENTS.md)

  • Goal: delivers what the user wanted, merged on green CI. With feat(chat): versions: regenerate, edit and switch in a conversation tree #467, this completes versions: regenerate, edit, switch, and carrying on from any version.
  • Agents: everything here goes through the API from feat(chat): versions: regenerate, edit and switch in a conversation tree #467 (regenerate, edit, parent, PUT /chats/{cid}/head).
  • Zero setup: nothing to set up.
  • Fewest clicks and keystrokes: Regenerate is one click and Regenerate with another model is two. Switching is one click or one arrow key, and it is instant for versions already seen. Nothing is deleted, so nothing needs confirming.
  • Configurable: n/a, there are no new settings.
  • Light: n/a, no new dependency.
  • Private and secure: n/a, there is no new surface. The calls are the owner's own conversation.
  • Cost: a regenerate is one more answer, logged like any other. Switching calls no model.
  • User decides: nothing happens until a person presses Regenerate, edits or switches.
  • Upgrades: n/a here. The stored-data change and its upgrade step are in feat(chat): versions: regenerate, edit and switch in a conversation tree #467.
  • Honest: the docs (docs/assistant.md › Versions, Choosing the model) and the CHANGELOG describe what's built.
  • Tests, docs and generated files updated: __tests__/chat-versions.test.tsx covers the tree helpers, the switch (arrows, keys, ends) and Regenerate with its model menu. The docs are updated, and there is no API change here.
  • Open standards: n/a.
  • Result reported with evidence; "refine later" items written down: deleting or naming a version, side-by-side compare, loading every version's text up front so the first switch to an unseen version is instant too, and versions as preference pairs for fine-tuning.

Generated by Claude Code

A conversation is now a tree: chat_message.parent and chat.head. Regenerate
writes a new answer beside the old one, edit makes a new version of a question
beside it instead of deleting what followed, and parent goes on from any
message. GET /chats/{cid} adds tree, head and each message's versions; PUT
/chats/{cid}/head switches. The model reads only the version showing; a
summary written on another version is ignored and rewritten for this one.
Upgrade step chat-tree lines existing conversations up, safe to run twice.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
… app

A question or an answer with versions shows ‹ 2 / 3 › to move between them
(arrow keys too); a version already seen shows at once, then PUT
/chats/{cid}/head saves it. Regenerate (and Regenerate with… another model)
replaces Try another model and streams the new answer in place, as does an
edit. The next question goes on from the version showing, and approvals show
in the version they were proposed in.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
The last check asked for 2026-10-17's note after the call without a date had made today's note, so on that day it
found the note the deleted root had left behind. It now asks for a day no earlier call makes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
@adeelahmad adeelahmad self-assigned this Oct 17, 2026
…-r960xc-c2-ui

# Conflicts:
#	CHANGELOG.md
#	docs/assistant.md
@adeelahmad
adeelahmad merged commit 0e1eb6a into main Oct 17, 2026
10 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-r960xc-c2-ui branch October 17, 2026 00:45
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