feat: add dialog for "Start new session from this answer" (#1501)

* feat: add dialog for "Start new session from this answer"

Replace the one-click fork action on assistant messages with a dialog
(ForkSessionDialog) that lets the user pick model, thinking level, and
agent, plus edit the instructions sent to the new session.

The instructions field is prefilled with the previous fixed fork prompt
and is mandatory. The composed message is now fully visible (no synthetic
preface): the user's instructions sit above a short fixed connective that
opens the assistant content. createSessionFromAssistantMessage takes the
chosen execution params instead of reading from config.

Also fix TodoSendDialog visuals: narrower vertical layout, model trigger
no longer stretches with centered text, and the agent/thinking dropdowns
portal to body so opening them no longer nudges the dialog height. Extract
the shared ThinkingPill into its own component.

* fix: address review feedback on fork session dialog

- Fix "bellow" -> "below" typo in the fork content preface (now user-visible
  since the message is no longer synthetic)
- Reset ForkSessionDialog state only on open transition, reading the config
  store snapshot via getState() so background store refreshes can't discard
  in-progress instruction edits
This commit is contained in:
Bohdan Triapitsyn
2026-06-02 12:53:30 +03:00
committed by GitHub
parent aefbdbc52f
commit 6a88cd09cc
17 changed files with 334 additions and 74 deletions
+2
View File
@@ -1692,6 +1692,8 @@ export const dict = {
'chat.messageBody.actions.saveAsPlan': 'Save as plan',
'chat.messageBody.actions.startNewSession': 'Start new session from this answer',
'chat.messageBody.actions.startNewMultiRun': 'Start new multi-run from this answer',
'chat.messageBody.forkDialog.instructions.label': 'Instructions',
'chat.messageBody.forkDialog.instructions.placeholder': 'Add instructions for the new session…',
'chat.generatedResult.actions.copy': 'Copy',
'chat.generatedResult.actions.copied': 'Copied',
'chat.generatedResult.commit.title': 'Generated commit message',
+2
View File
@@ -1658,6 +1658,8 @@ export const dict: Record<I18nKey, string> = {
"chat.messageBody.actions.saveAsPlan": "Guardar como plan",
"chat.messageBody.actions.startNewSession": "Iniciar nueva sesión desde esta respuesta",
"chat.messageBody.actions.startNewMultiRun": "Iniciar nuevo multi-run desde esta respuesta",
"chat.messageBody.forkDialog.instructions.label": "Instrucciones",
"chat.messageBody.forkDialog.instructions.placeholder": "Añade instrucciones para la nueva sesión…",
"chat.generatedResult.actions.copy": "Copiar",
"chat.generatedResult.actions.copied": "Copiado",
"chat.generatedResult.commit.title": "Mensaje de commit generado",
+2
View File
@@ -1692,6 +1692,8 @@ export const dict: Record<I18nKey, string> = {
'chat.messageBody.actions.saveAsPlan': '플랜으로 저장',
'chat.messageBody.actions.startNewSession': '이 응답에서 새 세션 시작',
'chat.messageBody.actions.startNewMultiRun': '이 응답에서 새 멀티런 시작',
'chat.messageBody.forkDialog.instructions.label': '지침',
'chat.messageBody.forkDialog.instructions.placeholder': '새 세션에 대한 지침을 입력하세요…',
'chat.generatedResult.actions.copy': '복사',
'chat.generatedResult.actions.copied': '복사됨',
'chat.generatedResult.commit.title': '생성된 커밋 메시지',
+2
View File
@@ -677,6 +677,8 @@ export const dict: Record<I18nKey, string> = {
'chat.messageBody.actions.saveAsPlan': 'Zapisz jako plan',
'chat.messageBody.actions.startNewSession': 'Rozpocznij nową sesję z tej odpowiedzi',
'chat.messageBody.actions.startNewMultiRun': 'Rozpocznij nowe wielokrotne uruchomienie z tej odpowiedzi',
'chat.messageBody.forkDialog.instructions.label': 'Instrukcje',
'chat.messageBody.forkDialog.instructions.placeholder': 'Dodaj instrukcje dla nowej sesji…',
'chat.generatedResult.actions.copy': 'Kopiuj',
'chat.generatedResult.actions.copied': 'Skopiowano',
'chat.generatedResult.commit.title': 'Wygenerowana wiadomość commita',
@@ -1658,6 +1658,8 @@ export const dict: Record<I18nKey, string> = {
"chat.messageBody.actions.saveAsPlan": "Salvar como plano",
"chat.messageBody.actions.startNewSession": "Iniciar nova sessão a partir desta resposta",
"chat.messageBody.actions.startNewMultiRun": "Iniciar novo multi-run a partir desta resposta",
"chat.messageBody.forkDialog.instructions.label": "Instruções",
"chat.messageBody.forkDialog.instructions.placeholder": "Adicione instruções para a nova sessão…",
"chat.generatedResult.actions.copy": "Copiar",
"chat.generatedResult.actions.copied": "Copiado",
"chat.generatedResult.commit.title": "Mensagem de commit gerada",
+2
View File
@@ -1658,6 +1658,8 @@ export const dict: Record<I18nKey, string> = {
"chat.messageBody.actions.saveAsPlan": "Зберегти як план",
"chat.messageBody.actions.startNewSession": "Почати нову сесію із цієї відповіді",
"chat.messageBody.actions.startNewMultiRun": "Почніть новий Multi-run із цієї відповіді",
"chat.messageBody.forkDialog.instructions.label": "Інструкції",
"chat.messageBody.forkDialog.instructions.placeholder": "Додайте інструкції для нової сесії…",
"chat.generatedResult.actions.copy": "Копіювати",
"chat.generatedResult.actions.copied": "Скопійовано",
"chat.generatedResult.commit.title": "Згенероване повідомлення коміту",
@@ -1658,6 +1658,8 @@ export const dict: Record<I18nKey, string> = {
'chat.messageBody.actions.saveAsPlan': '保存为计划',
'chat.messageBody.actions.startNewSession': '基于此回答开始新会话',
'chat.messageBody.actions.startNewMultiRun': '基于此回答开始新的多运行',
'chat.messageBody.forkDialog.instructions.label': '说明',
'chat.messageBody.forkDialog.instructions.placeholder': '为新会话添加说明…',
'chat.generatedResult.actions.copy': '复制',
'chat.generatedResult.actions.copied': '已复制',
'chat.generatedResult.commit.title': '生成的提交消息',
@@ -1662,6 +1662,8 @@ export const dict: Record<I18nKey, string> = {
'chat.messageBody.actions.saveAsPlan': '儲存為計畫',
'chat.messageBody.actions.startNewSession': '基於此回答開始新會話',
'chat.messageBody.actions.startNewMultiRun': '基於此回答開始新的 Multi-run',
'chat.messageBody.forkDialog.instructions.label': '說明',
'chat.messageBody.forkDialog.instructions.placeholder': '為新工作階段新增說明…',
'chat.generatedResult.actions.copy': '複製',
'chat.generatedResult.actions.copied': '已複製',
'chat.generatedResult.commit.title': '生成的提交訊息',
@@ -14,3 +14,25 @@ export const MULTIRUN_EXECUTION_FORK_PROMPT_META_TEXT =
export const isExecutionForkMetaText = (text: string | null | undefined): boolean =>
typeof text === 'string' && text.trim() === EXECUTION_FORK_META_TEXT.trim();
// Default, user-editable instructions prefilled in the "Start new session from
// this answer" dialog. Mirrors the previous fixed fork instruction so existing
// behavior is preserved unless the user edits it.
export const EXECUTION_FORK_DEFAULT_INSTRUCTIONS =
"I want you to respond according to the content of message I share: " +
"if it is an implementation plan, your task is to implement that plan; " +
"if it is a conclusion or summary, your task is to verify it, explain whether you agree or disagree, and correct it if needed. " +
"Always clearly state what you understand your task to be, and wait for the user's approval of your conclusions before taking any further actions.";
// Fixed connective that opens the forked assistant content. Not editable by the
// user — it sits between the user's instructions and the assistant message.
export const EXECUTION_FORK_CONTENT_PREFACE =
"This message below comes from an AI agent in another session. Here is the content of the message:";
// Builds the final message sent to the new session:
// <user instructions>
//
// This message below comes from an AI agent in another session. Here is the content of the message:
// <assistant content>
export const composeForkSessionMessage = (instructions: string, assistantContent: string): string =>
`${instructions.trim()}\n\n${EXECUTION_FORK_CONTENT_PREFACE}\n${assistantContent}`;