Skip to content

feat: add "Fork from here" to start a thread from any message - #120

Merged
abhishekgahlot2 merged 3 commits into
useagenthq:mainfrom
Asymtode712:feat/fork-from-here
Nov 22, 2026
Merged

abhishekgahlot2 merged 3 commits into
useagenthq:mainfrom
Asymtode712:feat/fork-from-here

Conversation

@Asymtode712

@Asymtode712 Asymtode712 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #90

What

"Fork from here" on any settled answer opens the new-thread composer with the
conversation up to and including that turn, on the same repositories, branches,
engine and model. The new thread's first message links back to the original.
The original thread is never written to.

How

  • components/chat/thread-fork.ts: cuts the turns at the chosen run and builds
    the context with the existing formatThreadMarkdown. The draft rides
    sessionStorage to /agent/new?fork=<runId> (too large for a URL).
  • components/chat/fork-prompt.ts: the first prompt is a small header, the
    history (prefixed with its length so it parses exactly), then the person's
    request. Oldest history is trimmed to fit the backend prompt limits.
    cleanPrompt strips the wrapper, so the bubble and titles show only the request.
  • conversation.tsx: fork button beside Copy, plus a "Forked after turn N of
    the original thread" link above a forked thread's first message.
  • new-task-composer.tsx: reads the draft, preselects repos/branches/model,
    shows a removable "Forked from" chip and sends the wrapped prompt.

No backend changes: the fork is an ordinary root run via POST /api/runs.

Testing

  • components/chat/thread-fork.test.ts: cut at the chosen message (later
    turns excluded), compose/parse round trip, fork of a fork, size trimming.
  • bun run typecheck, bun run lint, bun run test (frontend). The one
    failing test, terminal-surface.test.ts, fails on main too.

Demo

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


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@Asymtode712

Copy link
Copy Markdown
Contributor Author

@abhishekgahlot please review this PR and kindly go through the demo link where I've tested the behavior after the change.
Thanks !

@abhishekgahlot2

Copy link
Copy Markdown
Contributor

recheck

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

github-actions Bot added a commit that referenced this pull request Oct 18, 2026
@Asymtode712

Copy link
Copy Markdown
Contributor Author

@abhishekgahlot2 Can you please review this PR too

@abhishekgahlot2
abhishekgahlot2 merged commit 6212b69 into useagenthq:main Nov 22, 2026
21 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 22, 2026
@github-actions github-actions Bot unlocked this conversation Nov 22, 2026
@github-actions

Copy link
Copy Markdown

Thanks @Asymtode712, merged. Fork from here is live on main.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fork a thread from any message

2 participants