Skip to content

Commit 830ea83

Browse files
committed
refactor(chat): drop fork-and-send now that forking is per-message
The send button's dropdown forked at the TAIL and sent the draft in one action. "Fork from here" supersedes it: it forks at a turn the user points at, which includes the last one, so the only thing lost is having the draft ride along — now type it after the fork. Removing it takes the composer's split button with it, and the send button collapses back to the plain form the third branch already rendered. `forkSendBlockedByQueue` goes too: it existed because a fork-send carries a draft and must not jump items already queued for the current session. Fork-from-turn carries no draft, so it never needed the guard — the comment at its call site said as much by reference, and now says it outright. The welcome tip is rewritten rather than dropped, since the feature it advertises still exists in the message list.
1 parent d15c2ed commit 830ea83

17 files changed

Lines changed: 16 additions & 219 deletions

‎src/components/chat/chat-input.tsx‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ interface ChatInputProps {
5858
isEditingQueueItem?: boolean
5959
onSaveQueueEdit?: (draft: PromptDraft) => void
6060
onCancelQueueEdit?: () => void
61-
onForkSend?: (draft: PromptDraft, modeId?: string | null) => void
6261
/** Inject the draft's text into the RUNNING turn over the native steering
6362
* channel. Present only when the session's live-feedback channel is native
6463
* (`useSessionFeedback().channel === "native"`); resolves once recorded,
@@ -120,7 +119,6 @@ export const ChatInput = memo(function ChatInput({
120119
isEditingQueueItem,
121120
onSaveQueueEdit,
122121
onCancelQueueEdit,
123-
onForkSend,
124122
onSteer,
125123
onAddFeedback,
126124
feedbackAddDisabled,
@@ -216,7 +214,6 @@ export const ChatInput = memo(function ChatInput({
216214
isEditingQueueItem={isEditingQueueItem}
217215
onSaveQueueEdit={onSaveQueueEdit}
218216
onCancelQueueEdit={onCancelQueueEdit}
219-
onForkSend={onForkSend}
220217
onSteer={onSteer}
221218
onAddFeedback={onAddFeedback}
222219
feedbackAddDisabled={feedbackAddDisabled}

‎src/components/chat/conversation-shell.tsx‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ interface ConversationShellProps {
124124
isEditingQueueItem?: boolean
125125
onSaveQueueEdit?: (draft: PromptDraft) => void
126126
onCancelQueueEdit?: () => void
127-
onForkSend?: (draft: PromptDraft, modeId?: string | null) => void
128127
/** Inject the draft's text into the RUNNING turn (native live-feedback
129128
* steering). Present only for sessions on the native channel; threaded
130129
* straight through to the composer. */
@@ -195,7 +194,6 @@ export function ConversationShell({
195194
isEditingQueueItem,
196195
onSaveQueueEdit,
197196
onCancelQueueEdit,
198-
onForkSend,
199197
onSteer,
200198
topBanner,
201199
injectContent,
@@ -366,7 +364,6 @@ export function ConversationShell({
366364
isEditingQueueItem={isEditingQueueItem}
367365
onSaveQueueEdit={onSaveQueueEdit}
368366
onCancelQueueEdit={onCancelQueueEdit}
369-
onForkSend={onForkSend}
370367
onSteer={onSteer}
371368
onAddFeedback={onAddFeedback}
372369
feedbackAddDisabled={feedbackAddDisabled}

‎src/components/chat/message-input.tsx‎

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
ClipboardPaste,
1212
Cog,
1313
Copy,
14-
GitFork,
1514
MessageSquareText,
1615
Scissors,
1716
Send,
@@ -210,10 +209,6 @@ interface MessageInputProps {
210209
isEditingQueueItem?: boolean
211210
onSaveQueueEdit?: (draft: PromptDraft) => void
212211
onCancelQueueEdit?: () => void
213-
/** Fork the session and send `draft`. Fire-and-forget: the input consumes the
214-
* draft synchronously (clears on click); the parent re-queues it if the fork
215-
* can't run, so it is never lost. */
216-
onForkSend?: (draft: PromptDraft, modeId?: string | null) => void
217212
/** Inject the draft's TEXT into the RUNNING turn (native live-feedback
218213
* steering). Present only on sessions whose feedback channel is native —
219214
* when absent, the prompting branch renders its historical Stop-only form.
@@ -325,7 +320,6 @@ export function MessageInput({
325320
isEditingQueueItem = false,
326321
onSaveQueueEdit,
327322
onCancelQueueEdit,
328-
onForkSend,
329323
onSteer,
330324
onAddFeedback,
331325
feedbackAddDisabled,
@@ -1259,37 +1253,6 @@ export function MessageInput({
12591253
resetComposer,
12601254
])
12611255

1262-
const handleForkSendClick = useCallback(() => {
1263-
if (!onForkSend) return
1264-
// Same uploading gate as `handleSend`: a fork-send consumes the draft
1265-
// (and its blocks) immediately, so an unsettled upload would strip to
1266-
// nothing on the wire.
1267-
if (hasUploadingImage) {
1268-
toast.error(tAttach("attachUploadInProgress"))
1269-
return
1270-
}
1271-
const draft = buildDraft()
1272-
if (!draft) return
1273-
// Fork-send consumes the draft synchronously, exactly like a normal send:
1274-
// fire-and-forget and clear the input immediately, so there is no in-flight
1275-
// editable window. If the fork can't run (queue non-empty / disconnected /
1276-
// failure) the parent re-queues the draft, so it is never lost.
1277-
onForkSend(draft, showModeSelector ? effectiveModeId : null)
1278-
if (effectiveDraftStorageKey) {
1279-
clearMessageInputDraftV2(effectiveDraftStorageKey)
1280-
}
1281-
resetComposer()
1282-
}, [
1283-
onForkSend,
1284-
hasUploadingImage,
1285-
tAttach,
1286-
buildDraft,
1287-
effectiveModeId,
1288-
showModeSelector,
1289-
effectiveDraftStorageKey,
1290-
resetComposer,
1291-
])
1292-
12931256
// Mid-turn "insert into current turn" (native steering). Awaited, unlike
12941257
// the synchronous send/enqueue/fork paths: the draft clears ONLY once the
12951258
// backend confirms the injection was recorded — a turn-end race falls back
@@ -1720,36 +1683,6 @@ export function MessageInput({
17201683
<Square className="size-4" />
17211684
</Button>
17221685
)
1723-
) : onForkSend ? (
1724-
<div className="flex items-center">
1725-
<Button
1726-
onClick={handleSend}
1727-
disabled={disabled || !hasSendableContent}
1728-
size="icon"
1729-
className="h-8 w-8 rounded-r-none"
1730-
title={t("send")}
1731-
>
1732-
<Send className="size-4" />
1733-
</Button>
1734-
<DropdownMenu>
1735-
<DropdownMenuTrigger asChild>
1736-
<Button
1737-
disabled={disabled || !hasSendableContent}
1738-
size="icon"
1739-
className="h-8 w-5 rounded-l-none border-l border-primary-foreground/20"
1740-
aria-label={t("forkAndSend")}
1741-
>
1742-
<ChevronUp className="size-4" />
1743-
</Button>
1744-
</DropdownMenuTrigger>
1745-
<DropdownMenuContent align="end" side="top">
1746-
<DropdownMenuItem onSelect={handleForkSendClick}>
1747-
<GitFork className="h-4 w-4" />
1748-
{t("forkAndSend")}
1749-
</DropdownMenuItem>
1750-
</DropdownMenuContent>
1751-
</DropdownMenu>
1752-
</div>
17531686
) : (
17541687
<Button
17551688
onClick={handleSend}

‎src/components/chat/welcome-hero.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type TipKey =
1818
| "pasteDropFiles"
1919
| "queueMessage"
2020
| "draftAutoSave"
21-
| "forkSend"
21+
| "forkFromTurn"
2222
| "exportConversation"
2323
| "chatChannels"
2424
| "shortcutsAuxPanel"
@@ -65,7 +65,7 @@ const TIPS: TipDef[] = [
6565
{ key: "pasteDropFiles" },
6666
{ key: "queueMessage" },
6767
{ key: "draftAutoSave" },
68-
{ key: "forkSend" },
68+
{ key: "forkFromTurn" },
6969
{ key: "exportConversation" },
7070
{ key: "chatChannels" },
7171
{

‎src/components/conversations/conversation-detail-panel.tsx‎

Lines changed: 4 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ import {
8585
import { isWindowedDetail } from "@/lib/turn-window"
8686
import {
8787
flushRetryDelayMs,
88-
forkSendBlockedByQueue,
8988
isConnectionReady,
9089
shouldQueueDirectSend,
9190
shouldRejectDuplicateCreate,
@@ -1253,94 +1252,6 @@ const ConversationTabView = memo(function ConversationTabView({
12531252
handleSendRef.current = handleSend
12541253
}, [handleSend])
12551254

1256-
const handleForkSend = useCallback(
1257-
// Fire-and-forget: the input clears the draft synchronously on click (like a
1258-
// normal send), so there is no in-flight editable window. If the fork can't
1259-
// run right now — disconnected, or the queue is non-empty (a fork is an
1260-
// immediate session side effect and must not jump ahead of queued items) —
1261-
// the draft is NOT lost: it is queued as a normal send (it flushes after any
1262-
// queued items). The same on a fork failure.
1263-
async (draft: PromptDraft, selectedModeIdArg?: string | null) => {
1264-
const connectionId = conn.connectionId
1265-
if (
1266-
!connectionId ||
1267-
connStatus !== "connected" ||
1268-
// Read the queue length SYNCHRONOUSLY so a draft re-queued by a same-
1269-
// tick bounce is seen even before React commits. The UI also hides the
1270-
// fork affordance while the queue is non-empty; this is the guard.
1271-
forkSendBlockedByQueue(mqGetQueueLength())
1272-
) {
1273-
mqEnqueue(draft, selectedModeIdArg ?? null)
1274-
return
1275-
}
1276-
try {
1277-
// Backend performs all DB writes in one transaction-shaped call:
1278-
// - current row: external_id=S2, title="[Fork] ..."
1279-
// - sibling row: created with external_id=S1, status=pending_review
1280-
// Pass (conversationId, folderId) so a conversation opened from history
1281-
// — whose connection resumed via session_id but isn't row-linked until
1282-
// its first prompt — is adopted by the backend before forking (a
1283-
// fork-send forks BEFORE that prompt). No-op once already linked. Use
1284-
// the real persisted DB id (`dbConvIdRef`, same as the send path below),
1285-
// NOT the runtime key `effectiveConversationId` which can be virtual.
1286-
const { forkedSessionId } = await acpFork(
1287-
connectionId,
1288-
dbConvIdRef.current,
1289-
folderId
1290-
)
1291-
// Update runtime session id to S2 (frontend in-memory state only)
1292-
sessionIdRef.current = forkedSessionId
1293-
setExternalId(effectiveConversationId, forkedSessionId)
1294-
1295-
// NOTE: a fork is a transcript discontinuity — the row's session flips
1296-
// S1→S2, and S2 is a COPY of S1's transcript plus the turns to come.
1297-
// The pre-fork history is NOT re-surfaced here: the backend background
1298-
// watcher correctly excludes the fork-copied prefix from the out-of-turn
1299-
// overlay (see `baseline_offset_since`), so `detail.turns` (S1 parse) +
1300-
// the new local turns render each exchange exactly once. No detail
1301-
// refetch is needed or wanted — an early one races the forked turn and
1302-
// can drop the just-sent message.
1303-
refreshConversations()
1304-
// Send the message on the forked session (S2)
1305-
handleSend(draft, selectedModeIdArg)
1306-
} catch (err) {
1307-
// Busy (a turn is in flight, e.g. another co-controlling client started
1308-
// one): NOT a fork failure — silently re-queue, like a normal bounce.
1309-
// It sends after the current turn.
1310-
if (err instanceof TurnBusyError) {
1311-
mqEnqueue(draft, selectedModeIdArg ?? null)
1312-
return
1313-
}
1314-
// Real fork failure: surface it. EXPLICIT product decision — fork-send
1315-
// is best-effort, so the draft is never lost; it is re-queued and sent
1316-
// on the current (un-forked) session.
1317-
toast.error(
1318-
t("forkSessionFailed", {
1319-
error:
1320-
err instanceof Error
1321-
? err.message
1322-
: typeof err === "object" && err !== null
1323-
? JSON.stringify(err)
1324-
: String(err),
1325-
})
1326-
)
1327-
mqEnqueue(draft, selectedModeIdArg ?? null)
1328-
}
1329-
},
1330-
[
1331-
conn.connectionId,
1332-
connStatus,
1333-
mqGetQueueLength,
1334-
mqEnqueue,
1335-
effectiveConversationId,
1336-
folderId,
1337-
handleSend,
1338-
refreshConversations,
1339-
setExternalId,
1340-
t,
1341-
]
1342-
)
1343-
13441255
// "Fork from here": fork at a rendered assistant turn instead of at the tail,
13451256
// and DON'T send anything. Unlike fork-send there is no draft to protect, so a
13461257
// failure is just reported — the session is untouched, and the same click can
@@ -2052,10 +1963,10 @@ const ConversationTabView = memo(function ConversationTabView({
20521963
// rather than a usable composer here — a transcript whose composer is
20531964
// blocked (session/load failure) can still spawn the question elsewhere.
20541965
onAskSelection={canAskSelection ? handleAskSelection : undefined}
2055-
// Same three preconditions as fork-send, minus the queue guard: this
2056-
// fork carries no draft, so a non-empty queue is not at risk of being
2057-
// jumped. A turn in flight is still rejected — by the backend, which is
2058-
// the only place that can see it without racing.
1966+
// Fork carries no draft, so — unlike a send — a non-empty queue is
1967+
// not at risk of being jumped and needs no guard here. A turn in
1968+
// flight is still rejected, by the backend, which is the only place
1969+
// that can see it without racing.
20591970
onForkFromTurn={
20601971
connStatus === "connected" &&
20611972
hasPersistedConversation &&
@@ -2183,14 +2094,6 @@ const ConversationTabView = memo(function ConversationTabView({
21832094
isEditingQueueItem={mqEditingItemId != null}
21842095
onSaveQueueEdit={handleSaveQueueEdit}
21852096
onCancelQueueEdit={handleQueueCancelEdit}
2186-
onForkSend={
2187-
connStatus === "connected" &&
2188-
hasPersistedConversation &&
2189-
conn.supportsFork &&
2190-
!forkSendBlockedByQueue(msgQueue.length)
2191-
? handleForkSend
2192-
: undefined
2193-
}
21942097
onSteer={
21952098
// Native channel only: on pull sessions the prompting branch must
21962099
// stay pixel-identical (Stop button alone). The prompting scope

‎src/i18n/messages/ar.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,7 +2857,6 @@
28572857
"noModels": "لم يتم العثور على نماذج",
28582858
"cancel": "إلغاء",
28592859
"send": "إرسال",
2860-
"forkAndSend": "تفريع وإرسال",
28612860
"queueMessage": "إضافة إلى قائمة الانتظار",
28622861
"steerIntoTurn": "إدراج في الدور الحالي",
28632862
"steerQueuedInstead": "أُضيفت إلى قائمة الانتظار — ستُرسل مع الدور التالي.",
@@ -2916,7 +2915,7 @@
29162915
"pasteDropFiles": "ألصق لقطة شاشة أو اسحب ملفًا مباشرة إلى حقل الإدخال لإرفاقه.",
29172916
"queueMessage": "أثناء رد الوكيل، تابع الكتابة — ستوضع رسالتك التالية في الطابور وتُرسل تلقائيًا عند انتهائه.",
29182917
"draftAutoSave": "تُحفظ المسودات غير المُرسلة تلقائيًا لكل محادثة وتُستعاد عند العودة.",
2919-
"forkSend": "تتضمن قائمة زر الإرسال المنسدلة «تفرّع وأرسل» لإنشاء فرع من النقطة الحالية في تبويب جديد.",
2918+
"forkFromTurn": "يوفّر كل رد مكتمل «تفريع من هنا» لإنشاء فرع من تلك الرسالة في تبويب جديد.",
29202919
"exportConversation": "انقر بزر الفأرة الأيمن داخل المحادثة لتصديرها بصيغة Markdown أو HTML أو صورة.",
29212920
"chatChannels": "اربط Telegram / Lark / WeChat من «الإعدادات → قنوات الدردشة» للمتابعة من هاتفك.",
29222921
"shortcutsAuxPanel": "<shortcut>{toggleAuxPanel}</shortcut> يبدّل اللوحة اليمنى لعرض الملفات المعدّلة وتغييرات Git لهذه الجلسة.",

‎src/i18n/messages/de.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,7 +2857,6 @@
28572857
"noModels": "Keine Modelle gefunden",
28582858
"cancel": "Abbrechen",
28592859
"send": "Senden",
2860-
"forkAndSend": "Fork & Senden",
28612860
"queueMessage": "In Warteschlange stellen",
28622861
"steerIntoTurn": "In laufenden Turn einfügen",
28632862
"steerQueuedInstead": "Stattdessen in die Warteschlange gestellt – wird mit dem nächsten Turn gesendet.",
@@ -2916,7 +2915,7 @@
29162915
"pasteDropFiles": "Füge einen Screenshot ein oder ziehe eine Datei direkt ins Eingabefeld, um sie anzuhängen.",
29172916
"queueMessage": "Während der Agent antwortet, kannst du weitertippen – deine nächste Nachricht wird in die Warteschlange gestellt und automatisch gesendet.",
29182917
"draftAutoSave": "Nicht gesendete Entwürfe werden pro Konversation automatisch gespeichert und beim Zurückkehren wiederhergestellt.",
2919-
"forkSend": "Im Dropdown der Senden-Schaltfläche gibt es Verzweigen und senden – verzweige vom aktuellen Punkt in einen neuen Tab.",
2918+
"forkFromTurn": "Jede abgeschlossene Antwort bietet Ab hier verzweigen – verzweige das Gespräch an dieser Nachricht in einen neuen Tab.",
29202919
"exportConversation": "Klicke mit der rechten Maustaste in die Konversation, um sie als Markdown, HTML oder Bild zu exportieren.",
29212920
"chatChannels": "Verbinde Telegram / Lark / WeChat unter Einstellungen → Chat-Kanäle, um vom Handy aus weiterzuarbeiten.",
29222921
"shortcutsAuxPanel": "<shortcut>{toggleAuxPanel}</shortcut> blendet das rechte Panel ein – mit den geänderten Dateien und Git-Änderungen dieser Sitzung.",

‎src/i18n/messages/en.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2859,7 +2859,6 @@
28592859
"noModels": "No models found",
28602860
"cancel": "Cancel",
28612861
"send": "Send",
2862-
"forkAndSend": "Fork & Send",
28632862
"queueMessage": "Queue message",
28642863
"steerIntoTurn": "Insert into current turn",
28652864
"steerQueuedInstead": "Queued instead — it will be sent with the next turn.",
@@ -2916,7 +2915,7 @@
29162915
"pasteDropFiles": "Paste a screenshot or drop a file directly onto the input to attach it.",
29172916
"queueMessage": "While the agent is replying, keep typing — your next message gets queued and auto-sent when it finishes.",
29182917
"draftAutoSave": "Unsent drafts are auto-saved per conversation and restored when you come back.",
2919-
"forkSend": "The send button's dropdown has Fork and Send — branch from the current turn into a new tab.",
2918+
"forkFromTurn": "Any completed reply has Fork from here — branch the conversation at that message into a new tab.",
29202919
"exportConversation": "Right-click inside the conversation to export it as Markdown, HTML, or an image.",
29212920
"chatChannels": "Connect Telegram / Lark / WeChat under Settings → Chat Channels to continue from your phone.",
29222921
"shortcutsAuxPanel": "<shortcut>{toggleAuxPanel}</shortcut> toggles the right panel to view this session's touched files and Git changes.",

‎src/i18n/messages/es.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,7 +2857,6 @@
28572857
"noModels": "No se encontraron modelos",
28582858
"cancel": "Cancelar",
28592859
"send": "Enviar",
2860-
"forkAndSend": "Fork y Enviar",
28612860
"queueMessage": "Poner en cola",
28622861
"steerIntoTurn": "Insertar en el turno actual",
28632862
"steerQueuedInstead": "Se puso en cola: se enviará con el siguiente turno.",
@@ -2916,7 +2915,7 @@
29162915
"pasteDropFiles": "Pega una captura de pantalla o arrastra un archivo a la entrada para adjuntarlo.",
29172916
"queueMessage": "Mientras el agente responde, sigue escribiendo: tu próximo mensaje se pone en cola y se envía al terminar.",
29182917
"draftAutoSave": "Los borradores sin enviar se guardan automáticamente por conversación y se restauran al volver.",
2919-
"forkSend": "El desplegable del botón de enviar incluye Bifurcar y enviar, que ramifica desde el punto actual a una pestaña nueva.",
2918+
"forkFromTurn": "Cada respuesta completada tiene Bifurcar desde aquí: ramifica la conversación en ese mensaje hacia una pestaña nueva.",
29202919
"exportConversation": "Haz clic derecho dentro de la conversación para exportarla como Markdown, HTML o imagen.",
29212920
"chatChannels": "Conecta Telegram / Lark / WeChat en Ajustes → Canales de chat para continuar desde el móvil.",
29222921
"shortcutsAuxPanel": "<shortcut>{toggleAuxPanel}</shortcut> alterna el panel derecho para ver los archivos tocados y los cambios de Git de esta sesión.",

‎src/i18n/messages/fr.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,7 +2857,6 @@
28572857
"noModels": "Aucun modèle trouvé",
28582858
"cancel": "Annuler",
28592859
"send": "Envoyer",
2860-
"forkAndSend": "Fork & Envoyer",
28612860
"queueMessage": "Mettre en file d'attente",
28622861
"steerIntoTurn": "Insérer dans le tour en cours",
28632862
"steerQueuedInstead": "Mis en file d'attente — il sera envoyé au tour suivant.",
@@ -2916,7 +2915,7 @@
29162915
"pasteDropFiles": "Collez une capture d'écran ou déposez un fichier directement dans la zone de saisie pour le joindre.",
29172916
"queueMessage": "Pendant que l'agent répond, continuez à écrire : votre message suivant est mis en file et envoyé automatiquement à la fin.",
29182917
"draftAutoSave": "Les brouillons non envoyés sont sauvegardés automatiquement par conversation et restaurés à votre retour.",
2919-
"forkSend": "Le menu déroulant du bouton d'envoi propose Bifurquer et envoyer pour ouvrir une branche dans un nouvel onglet à partir du point actuel.",
2918+
"forkFromTurn": "Chaque réponse terminée propose Bifurquer d'ici pour ouvrir une branche dans un nouvel onglet à partir de ce message.",
29202919
"exportConversation": "Faites un clic droit dans la conversation pour l'exporter en Markdown, HTML ou image.",
29212920
"chatChannels": "Connectez Telegram / Lark / WeChat dans Paramètres → Canaux de discussion pour continuer depuis votre téléphone.",
29222921
"shortcutsAuxPanel": "<shortcut>{toggleAuxPanel}</shortcut> bascule le panneau droit pour voir les fichiers modifiés et les changements Git de cette session.",

0 commit comments

Comments
 (0)