Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(ok): keep agent thread settings across archive and resume (#3095)

sarahe16b3f77182b
diff --git a/.changeset/acp-resume-applies-settled-config.md b/.changeset/acp-resume-applies-settled-config.md
new file mode 100644
index 000000000..5d35a9f58
--- /dev/null
+++ b/.changeset/acp-resume-applies-settled-config.md
@@ -0,0 +1,7 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Agent thread settings now survive archiving and resuming. Picking up an archived conversation started a fresh agent session on the agent's own defaults, so a thread you had set to a particular model quietly went back to answering on a different one while the settings menu still showed your choice. The settled model, reasoning effort, and mode are now captured before the resume response overwrites them and re-applied to the new session, in the same order a new thread applies them, so an option the agent has since retired is skipped rather than failing the resume. An agent that resumes without reporting its configuration is re-sent the values rather than trusted, since in that case the cached ones describe the session that ended.
+
+Changing a setting on an archived conversation also works now instead of being silently dropped. There is no agent to apply it to yet, so the choice is recorded against the thread and applied to the session the resume starts, and the menu says so rather than leaving a pick that appears to have done nothing.
diff --git a/packages/app/src/components/acp/ThreadView.dom.test.tsx b/packages/app/src/components/acp/ThreadView.dom.test.tsx
index 95b284701..b79f062b4 100644
--- a/packages/app/src/components/acp/ThreadView.dom.test.tsx
+++ b/packages/app/src/components/acp/ThreadView.dom.test.tsx
@@ -315,6 +315,78 @@ describe('ThreadView agent settings', () => {
expect(document.activeElement).not.toBe(screen.getByTestId('agent-thread-composer'));
});
+ test('an archived thread keeps the menu usable and says when a pick lands', async () => {
+ // The server records a pick against an archived thread and the resume
+ // applies it. A pick that sticks in the menu but changes nothing until the
+ // conversation wakes is indistinguishable from a menu that silently failed,
+ // so the row that explains it is part of the behaviour, not decoration.
+ render(
+ <ThreadView
+ info={makeInfo({
+ status: 'exited',
+ archived: true,
+ configOptions: [
+ {
+ id: 'model',
+ name: 'Model',
+ category: 'model',
+ type: 'select',
+ currentValue: 'sonnet',
+ options: [
+ { value: 'sonnet', name: 'Sonnet' },
+ { value: 'opus', name: 'Opus' },
+ ],
+ },
+ ],
+ })}
+ />,
+ );
+
+ // The caveat rides the trigger's accessible name too. A menu label is a
+ // bare div outside both the roving-focus collection and the menu's
+ // accessible name, so on its own it never reaches a screen reader — the
+ // one audience the "did my pick do anything?" confusion hits hardest.
+ const trigger = screen.getByRole('button', { name: /Agent settings/ });
+ expect(trigger.getAttribute('aria-label')).toMatch(/pick this conversation back up/);
+
+ await userEvent.click(trigger);
+ expect(screen.getByTestId('agent-thread-settings-archived-hint')).toBeTruthy();
+
+ await userEvent.click(screen.getByTestId('agent-thread-config-model'));
+ await userEvent.click(await screen.findByTestId('agent-thread-config-option-opus'));
+ expect(setConfigOption).toHaveBeenCalledWith('thread-1', 'model', 'opus');
+ });
+
+ test('a live thread carries no archived hint', async () => {
+ render(
+ <ThreadView
+ info={makeInfo({
+ status: 'ready',
+ configOptions: [
+ {
+ id: 'model',
+ name: 'Model',
+ category: 'model',
+ type: 'select',
+ currentValue: 'sonnet',
+ options: [
+ { value: 'sonnet', name: 'Sonnet' },
+ { value: 'opus', name: 'Opus' },
+ ],
+ },
+ ],
+ })}
+ />,
+ );
+
+ // Both channels, not just the visible one: an inverted archived check would
+ // otherwise announce the caveat on every live thread and still pass here.
+ const trigger = screen.getByRole('button', { name: 'Agent settings' });
+ expect(trigger.getAttribute('aria-label')).not.toMatch(/pick this conversation back up/);
+ await userEvent.click(trigger);
+ expect(screen.queryByTestId('agent-thread-settings-archived-hint')).toBeNull();
+ });
+
test('remembers every pick for this agent, modes included', async () => {
const key = agentSettingsKey({ source: 'registry', id: 'claude' });
render(
diff --git a/packages/app/src/components/acp/ThreadView.tsx b/packages/app/src/components/acp/ThreadView.tsx
index 703c7b2c7..c1318e6fd 100644
--- a/packages/app/src/components/acp/ThreadView.tsx
+++ b/packages/app/src/components/acp/ThreadView.tsx
@@ -1609,10 +1609,17 @@ function AgentSettingsPopover({ info }: { info: ThreadInfo }): ReactNode {
primarySelect !== undefined
? selectOptionSummary(info.agent.id, primarySelect)
: (legacyModeName ?? t`Settings`);
+ // The archived caveat rides the trigger's label as well as the row inside the
+ // menu: a menu label is a bare div outside the roving-focus collection and
+ // outside the menu's accessible name, so on its own it would leave exactly
+ // the "picked it and nothing happened" impression it exists to prevent for
+ // anyone not reading the menu visually.
const accentTooltip =
- permissiveMode && modeSurface !== null
- ? t`${modeSurface.currentName} lets ${info.agent.name} act without asking`
- : t`Agent settings`;
+ info.archived === true
+ ? t`Agent settings — changes apply when you pick this conversation back up`
+ : permissiveMode && modeSurface !== null
+ ? t`${modeSurface.currentName} lets ${info.agent.name} act without asking`
+ : t`Agent settings`;
return (
<DropdownMenu>
@@ -1649,6 +1656,19 @@ function AgentSettingsPopover({ info }: { info: ThreadInfo }): ReactNode {
as agents expose more (and longer-described) options — the sprawl lives
in the submenus instead of stretching one flat panel. */}
<DropdownMenuContent align="end" className="w-60" data-testid="agent-thread-settings-popover">
+ {/* An archived thread has no agent to apply a pick to — the server
+ records it against the thread and the resume starts on it. Without
+ saying so, a pick that visibly sticks but changes nothing until you
+ send a message is indistinguishable from a menu that silently
+ failed. */}
+ {info.archived === true ? (
+ <DropdownMenuLabel
+ className="font-normal text-muted-foreground"
+ data-testid="agent-thread-settings-archived-hint"
+ >
+ {t`Applies when you pick this conversation back up`}
+ </DropdownMenuLabel>
+ ) : null}
{configOptions.map((option) =>
option.type === 'select' ? (
<ConfigSelectSub
diff --git a/packages/app/src/locales/ar/messages.json b/packages/app/src/locales/ar/messages.json
index 4962be8e7..b5aba847c 100644
--- a/packages/app/src/locales/ar/messages.json
+++ b/packages/app/src/locales/ar/messages.json
@@ -1607,6 +1607,7 @@
"IKoTAC": ["إبقاؤه معطّلًا"],
"IMLUBh": ["قيمة لون غير صالحة"],
"INN7OX": ["إظهار ", ["hiddenCount"], " إضافية"],
+ "INZWqo": ["إعدادات الوكيل: تسري التغييرات عند استئناف هذه المحادثة"],
"INp_z6": ["علّق على ", ["0"], " هذا أو اسأل الذكاء الاصطناعي عنه"],
"IO8REi": ["تعذّر فتح «", ["name"], "»: ", ["0"]],
"IQPyrD": ["صفحة مفقودة — انقر لإنشائها"],
@@ -2135,6 +2136,7 @@
"Oos8fo": ["نسخ الأمر"],
"OplnBG": ["إدارة أدوات الذكاء الاصطناعي غير متاحة في هذه النسخة."],
"OsSaYm": ["فشل الاستنساخ: ", ["title"]],
+ "OuQezS": ["يسري عند استئناف هذه المحادثة"],
"OuY8t9": ["الفتح في الفرع الحالي"],
"OvEjsP": ["يجري النسخ..."],
"OxplNM": ["حُدِّث «", ["0"], "»: أُضيف ", ["1"], "، وأُزيل ", ["2"]],
diff --git a/packages/app/src/locales/ar/messages.po b/packages/app/src/locales/ar/messages.po
index 7a7b64823..4d307647d 100644
--- a/packages/app/src/locales/ar/messages.po
+++ b/packages/app/src/locales/ar/messages.po
@@ -1525,6 +1525,10 @@ msgstr "أُغلقت لوحة الوكيل لإبقاء Terminal سهل القر
msgid "Agent settings"
msgstr "إعدادات الوكيل"
+#: src/components/acp/ThreadView.tsx
+msgid "Agent settings — changes apply when you pick this conversation back up"
+msgstr "إعدادات الوكيل: تسري التغييرات عند استئناف هذه المحادثة"
+
#: src/components/acp/ThreadView.tsx
msgid "Agent transcript"
msgstr "نص جلسة الوكيل"
@@ -1734,6 +1738,10 @@ msgstr "ينطبق على كل المشاريع على هذا الجهاز. يو
msgid "Applies to this project on this computer only. Stored in .ok/local, not shared via git."
msgstr "ينطبق على هذا المشروع على هذا الكمبيوتر فقط. يُخزَّن في ‎.ok/local ولا يُشارك عبر git."
+#: src/components/acp/ThreadView.tsx
+msgid "Applies when you pick this conversation back up"
+msgstr "يسري عند استئناف هذه المحادثة"
+
#: src/components/settings/NetworkAccessSection.tsx
msgid "Apply and restart project server"
msgstr "تطبيق وإعادة تشغيل خادم المشروع"
diff --git a/packages/app/src/locales/bn/messages.json b/packages/app/src/locales/bn/messages.json
index 74d473b5a..f0f7c0b37 100644
--- a/packages/app/src/locales/bn/messages.json
+++ b/packages/app/src/locales/bn/messages.json
@@ -1356,6 +1356,7 @@
"IKoTAC": ["নিষ্ক্রিয়ই রাখুন"],
"IMLUBh": ["অবৈধ রঙের মান"],
"INN7OX": ["আরও ", ["hiddenCount"], "টি দেখান"],
+ "INZWqo": ["এজেন্ট সেটিং: আপনি এই কথোপকথন আবার শুরু করলে পরিবর্তনগুলি প্রযোজ্য হবে"],
"INp_z6": ["এই ", ["0"], " নিয়ে মন্তব্য করুন বা AI-কে জিজ্ঞাসা করুন"],
"IO8REi": ["\"", ["name"], "\" খোলা যায়নি: ", ["0"]],
"IQPyrD": ["অনুপস্থিত পাতা — তৈরি করতে ক্লিক করুন"],
@@ -1819,6 +1820,7 @@
"Oos8fo": ["কমান্ড কপি করুন"],
"OplnBG": ["এই বিল্ডে AI টুল সামলানো যায় না।"],
"OsSaYm": ["ক্লোন ব্যর্থ: ", ["title"]],
+ "OuQezS": ["আপনি এই কথোপকথন আবার শুরু করলে প্রযোজ্য হবে"],
"OuY8t9": ["বর্তমান ব্রাঞ্চে খুলুন"],
"OvEjsP": ["কপি করা হচ্ছে…"],
"OxplNM": ["\"", ["0"], "\" হালনাগাদ হয়েছে: ", ["1"], " যোগ হয়েছে, ", ["2"], " সরানো হয়েছে"],
diff --git a/packages/app/src/locales/bn/messages.po b/packages/app/src/locales/bn/messages.po
index 635fd4b52..1569a1614 100644
--- a/packages/app/src/locales/bn/messages.po
+++ b/packages/app/src/locales/bn/messages.po
@@ -1521,6 +1521,10 @@ msgstr "Terminal পাঠযোগ্য রাখতে এজেন্ট প
msgid "Agent settings"
msgstr "এজেন্ট সেটিং"
+#: src/components/acp/ThreadView.tsx
+msgid "Agent settings — changes apply when you pick this conversation back up"
+msgstr "এজেন্ট সেটিং: আপনি এই কথোপকথন আবার শুরু করলে পরিবর্তনগুলি প্রযোজ্য হবে"
+
#: src/components/acp/ThreadView.tsx
msgid "Agent transcript"
msgstr "এজেন্ট প্রতিলিপি"
@@ -1730,6 +1734,10 @@ msgstr "এই মেশিনের সব প্রকল্পে প্র
msgid "Applies to this project on this computer only. Stored in .ok/local, not shared via git."
msgstr "শুধু এই কম্পিউটারে এই প্রকল্পের জন্য প্রযোজ্য। .ok/local-এ সংরক্ষিত, git-এর মাধ্যমে ভাগ করা হয় না।"
+#: src/components/acp/ThreadView.tsx
+msgid "Applies when you pick this conversation back up"
+msgstr "আপনি এই কথোপকথন আবার শুরু করলে প্রযোজ্য হবে"
+
#: src/components/settings/NetworkAccessSection.tsx
msgid "Apply and restart project server"
msgstr "প্রয়োগ করুন এবং প্রজেক্ট সার্ভার পুনরায় চালু করুন"
diff --git a/packages/app/src/locales/en/messages.json b/packages/app/src/locales/en/messages.json
index a130f9a85..fe4ed1288 100644
--- a/packages/app/src/locales/en/messages.json
+++ b/packages/app/src/locales/en/messages.json
@@ -1395,6 +1395,7 @@
"IKoTAC": ["Keep disabled"],
"IMLUBh": ["Invalid color value"],
"INN7OX": ["Show ", ["hiddenCount"], " more"],
+ "INZWqo": ["Agent settings — changes apply when you pick this conversation back up"],
"INp_z6": ["Comment or ask AI about this ", ["0"]],
"IO8REi": ["Couldn't open \"", ["name"], "\": ", ["0"]],
"IQPyrD": ["Missing page — click to create"],
@@ -1871,6 +1872,7 @@
"Oos8fo": ["Copy command"],
"OplnBG": ["Managing AI tools is unavailable in this build."],
"OsSaYm": ["Clone failed: ", ["title"]],
+ "OuQezS": ["Applies when you pick this conversation back up"],
"OuY8t9": ["Open in current branch"],
"OvEjsP": ["Copying..."],
"OxplNM": ["Updated \"", ["0"], "\": added ", ["1"], ", removed ", ["2"]],
diff --git a/packages/app/src/locales/en/messages.po b/packages/app/src/locales/en/messages.po
index 2f2103f7a..caf81ea25 100644
--- a/packages/app/src/locales/en/messages.po
+++ b/packages/app/src/locales/en/messages.po
@@ -1525,6 +1525,10 @@ msgstr "Agent panel closed to keep Terminal readable."
msgid "Agent settings"
msgstr "Agent settings"
+#: src/components/acp/ThreadView.tsx
+msgid "Agent settings — changes apply when you pick this conversation back up"
+msgstr "Agent settings — changes apply when you pick this conversation back up"
+
#: src/components/acp/ThreadView.tsx
msgid "Agent transcript"
msgstr "Agent transcript"
@@ -1734,6 +1738,10 @@ msgstr "Applies to all projects on this machine. Claude and Codex, started from
msgid "Applies to this project on this computer only. Stored in .ok/local, not shared via git."
msgstr "Applies to this project on this computer only. Stored in .ok/local, not shared via git."
+#: src/components/acp/ThreadView.tsx
+msgid "Applies when you pick this conversation back up"
+msgstr "Applies when you pick this conversation back up"
+
#: src/components/settings/NetworkAccessSection.tsx
msgid "Apply and restart project server"
msgstr "Apply and restart project server"
diff --git a/packages/app/src/locales/es/messages.json b/packages/app/src/locales/es/messages.json
index 381dc3921..9d2dcddbf 100644
--- a/packages/app/src/locales/es/messages.json
+++ b/packages/app/src/locales/es/messages.json
@@ -1632,6 +1632,7 @@
"IKoTAC": ["Dejarlo desactivado"],
"IMLUBh": ["Valor de color no válido"],
"INN7OX": ["Mostrar ", ["hiddenCount"], " más"],
+ "INZWqo": ["Ajustes del agente: los cambios se aplican cuando retomes esta conversación"],
"INp_z6": ["Comenta o pregunta a la IA sobre este ", ["0"]],
"IO8REi": ["No se pudo abrir \"", ["name"], "\": ", ["0"]],
"IQPyrD": ["Página inexistente: haz clic para crearla"],
@@ -2163,6 +2164,7 @@
"Oos8fo": ["Copiar comando"],
"OplnBG": ["La gestión de herramientas de IA no está disponible en esta compilación."],
"OsSaYm": ["No se pudo clonar: ", ["title"]],
+ "OuQezS": ["Se aplica cuando retomes esta conversación"],
"OuY8t9": ["Abrir en la rama actual"],
"OvEjsP": ["Copiando..."],
"OxplNM": ["Se actualizó \"", ["0"], "\": ", ["1"], " añadidos, ", ["2"], " eliminados"],
diff --git a/packages/app/src/locales/es/messages.po b/packages/app/src/locales/es/messages.po
index 0e44da386..6ae448a42 100644
--- a/packages/app/src/locales/es/messages.po
+++ b/packages/app/src/locales/es/messages.po
@@ -1525,6 +1525,10 @@ msgstr "Se cerró el panel de agentes para mantener Terminal legible."
msgid "Agent settings"
msgstr "Ajustes del agente"
+#: src/components/acp/ThreadView.tsx
+msgid "Agent settings — changes apply when you pick this conversation back up"
+msgstr "Ajustes del agente: los cambios se aplican cuando retomes esta conversación"
+
#: src/components/acp/ThreadView.tsx
msgid "Agent transcript"
msgstr "Transcripción del agente"
@@ -1734,6 +1738,10 @@ msgstr "Se aplica a todos los proyectos de este equipo. Claude y Codex, iniciado
msgid "Applies to this project on this computer only. Stored in .ok/local, not shared via git."
msgstr "Se aplica a este proyecto solo en este equipo. Se guarda en .ok/local y no se comparte mediante git."
+#: src/components/acp/ThreadView.tsx
+msgid "Applies when you pick this conversation back up"
+msgstr "Se aplica cuando retomes esta conversación"
+
#: src/components/settings/NetworkAccessSection.tsx
msgid "Apply and restart project server"
msgstr "Aplicar y reiniciar el servidor del proyecto"
diff --git a/packages/app/src/locales/fr/messages.json b/packages/app/src/locales/fr/messages.json
index 814f6e78d..1a8321391 100644
--- a/packages/app/src/locales/fr/messages.json
+++ b/packages/app/src/locales/fr/messages.json
@@ -1657,6 +1657,9 @@
"IKoTAC": ["Laisser désactivé"],
"IMLUBh": ["Valeur de couleur non valide"],
"INN7OX": ["Afficher ", ["hiddenCount"], " de plus"],
+ "INZWqo": [
+ "Paramètres de l'agent : les modifications s'appliquent lorsque vous reprendrez cette conversation"
+ ],
"INp_z6": ["Commenter ce ", ["0"], " ou interroger l’IA à son sujet"],
"IO8REi": ["Impossible d'ouvrir « ", ["name"], " » : ", ["0"]],
"IQPyrD": ["Page manquante — cliquez pour la créer"],
@@ -2188,6 +2191,7 @@
"Oos8fo": ["Copier la commande"],
"OplnBG": ["La gestion des outils IA n'est pas disponible dans cette version."],
"OsSaYm": ["Échec du clonage : ", ["title"]],
+ "OuQezS": ["S'applique lorsque vous reprendrez cette conversation"],
"OuY8t9": ["Ouvrir dans la branche actuelle"],
"OvEjsP": ["Copie en cours…"],
"OxplNM": ["« ", ["0"], " » mis à jour : ", ["1"], " ajouté(s), ", ["2"], " retiré(s)"],
diff --git a/packages/app/src/locales/fr/messages.po b/packages/app/src/locales/fr/messages.po
index 1b68702d9..8555f3e77 100644
--- a/packages/app/src/locales/fr/messages.po
+++ b/packages/app/src/locales/fr/messages.po
@@ -1525,6 +1525,10 @@ msgstr "Le panneau des agents a été fermé pour que Terminal reste lisible."
msgid "Agent settings"
msgstr "Paramètres de l'agent"
+#: src/components/acp/ThreadView.tsx
+msgid "Agent settings — changes apply when you pick this conversation back up"
+msgstr "Paramètres de l'agent : les modifications s'appliquent lorsque vous reprendrez cette conversation"
+
#: src/components/acp/ThreadView.tsx
msgid "Agent transcript"
msgstr "Transcription de l'agent"
@@ -1734,6 +1738,10 @@ msgstr "S'applique à tous les projets de cette machine. Claude et Codex, lancé
msgid "Applies to this project on this computer only. Stored in .ok/local, not shared via git."
msgstr "S'applique à ce projet sur cet ordinateur uniquement. Stocké dans .ok/local, non partagé via git."
+#: src/components/acp/ThreadView.tsx
+msgid "Applies when you pick this conversation back up"
+msgstr "S'applique lorsque vous reprendrez cette conversation"
+
#: src/components/settings/NetworkAccessSection.tsx
msgid "Apply and restart project server"
msgstr "Appliquer et redémarrer le serveur du projet"
diff --git a/packages/app/src/locales/hi/messages.json b/packages/app/src/locales/hi/messages.json
index b16a623d4..28a88652f 100644
--- a/packages/app/src/locales/hi/messages.json
+++ b/packages/app/src/locales/hi/messages.json
@@ -1354,6 +1354,7 @@
"IKoTAC": ["अक्षम ही रखें"],
"IMLUBh": ["अमान्य रंग मान"],
"INN7OX": [["hiddenCount"], " और दिखाएँ"],
+ "INZWqo": ["एजेंट सेटिंग: परिवर्तन तब लागू होंगे जब आप यह बातचीत फिर से शुरू करेंगे"],
"INp_z6": ["इस ", ["0"], " पर टिप्पणी करें या AI से पूछें"],
"IO8REi": ["\"", ["name"], "\" नहीं खोली जा सकी: ", ["0"]],
"IQPyrD": ["अनुपस्थित पेज — बनाने के लिए क्लिक करें"],
@@ -1820,6 +1821,7 @@
"Oos8fo": ["कमांड कॉपी करें"],
"OplnBG": ["इस बिल्ड में AI टूल सँभालना उपलब्ध नहीं है।"],
"OsSaYm": ["क्लोन विफल: ", ["title"]],
+ "OuQezS": ["जब आप यह बातचीत फिर से शुरू करेंगे तब लागू होगा"],
"OuY8t9": ["मौजूदा ब्रांच में खोलें"],
"OvEjsP": ["कॉपी किया जा रहा है…"],
"OxplNM": ["\"", ["0"], "\" अपडेट किया गया: ", ["1"], " जोड़े गए, ", ["2"], " हटाए गए"],
diff --git a/packages/app/src/locales/hi/messages.po b/packages/app/src/locales/hi/messages.po
index 8ac7c7988..76a0c95e6 100644
--- a/packages/app/src/locales/hi/messages.po
+++ b/packages/app/src/locales/hi/messages.po
@@ -1521,6 +1521,10 @@ msgstr "Terminal को पढ़ने योग्य बनाए रखन
msgid "Agent settings"
msgstr "एजेंट सेटिंग"
+#: src/components/acp/ThreadView.tsx
+msgid "Agent settings — changes apply when you pick this conversation back up"
+msgstr "एजेंट सेटिंग: परिवर्तन तब लागू होंगे जब आप यह बातचीत फिर से शुरू करेंगे"
+
#: src/components/acp/ThreadView.tsx
msgid "Agent transcript"
msgstr "एजेंट प्रतिलेख"
@@ -1730,6 +1734,10 @@ msgstr "इस मशीन के सभी प्रोजेक्ट पर
msgid "Applies to this project on this computer only. Stored in .ok/local, not shared via git."
msgstr "केवल इस कंप्यूटर पर इस प्रोजेक्ट पर लागू होता है। .ok/local में सहेजा जाता है, git के ज़रिए साझा नहीं होता।"
+#: src/components/acp/ThreadView.tsx
+msgid "Applies when you pick this conversation back up"
+msgstr "जब आप यह बातचीत फिर से शुरू करेंगे तब लागू होगा"
+
#: src/components/settings/NetworkAccessSection.tsx
msgid "Apply and restart project server"
msgstr "लागू करें और प्रोजेक्ट सर्वर पुनः प्रारंभ करें"
diff --git a/packages/app/src/locales/id/messages.json b/packages/app/src/locales/id/messages.json
index 82d5dc5a7..334856be1 100644
--- a/packages/app/src/locales/id/messages.json
+++ b/packages/app/src/locales/id/messages.json
@@ -1406,6 +1406,7 @@
"IKoTAC": ["Biarkan nonaktif"],
"IMLUBh": ["Nilai warna tidak valid"],
"INN7OX": ["Tampilkan ", ["hiddenCount"], " lagi"],
+ "INZWqo": ["Pengaturan agen: perubahan berlaku saat Anda melanjutkan percakapan ini"],
"INp_z6": ["Beri komentar atau tanya AI tentang ", ["0"], " ini"],
"IO8REi": ["\"", ["name"], "\" tidak bisa dibuka: ", ["0"]],
"IQPyrD": ["Halaman belum ada — klik untuk membuat"],
@@ -1881,6 +1882,7 @@
"Oos8fo": ["Salin perintah"],
"OplnBG": ["Pengelolaan alat AI tidak tersedia pada build ini."],
"OsSaYm": ["Kloning gagal: ", ["title"]],
+ "OuQezS": ["Berlaku saat Anda melanjutkan percakapan ini"],
"OuY8t9": ["Buka di cabang saat ini"],
"OvEjsP": ["Menyalin..."],
"OxplNM": ["\"", ["0"], "\" diperbarui: ", ["1"], " ditambahkan, ", ["2"], " dihapus"],
diff --git a/packages/app/src/locales/id/messages.po b/packages/app/src/locales/id/messages.po
index 095e0d2d1..01b530208 100644
--- a/packages/app/src/locales/id/messages.po
+++ b/packages/app/src/locales/id/messages.po
@@ -1521,6 +1521,10 @@ msgstr "Panel agen ditutup agar Terminal tetap mudah dibaca."
msgid "Agent settings"
msgstr "Pengaturan agen"
+#: src/components/acp/ThreadView.tsx
+msgid "Agent settings — changes apply when you pick this conversation back up"
+msgstr "Pengaturan agen: perubahan berlaku saat Anda melanjutkan percakapan ini"
+
#: src/components/acp/ThreadView.tsx
msgid "Agent transcript"
msgstr "Transkrip agen"
@@ -1730,6 +1734,10 @@ msgstr "Berlaku untuk semua proyek di komputer ini. Claude dan Codex, yang dijal
msgid "Applies to this project on this computer only. Stored in .ok/local, not shared via git."
msgstr "Berlaku untuk proyek ini hanya di komputer ini. Disimpan di .ok/local, tidak dibagikan lewat git."
+#: src/components/acp/ThreadView.tsx
+msgid "Applies when you pick this conversation back up"
+msgstr "Berlaku saat Anda melanjutkan percakapan ini"
+
#: src/components/settings/NetworkAccessSection.tsx
msgid "Apply and restart project server"
msgstr "Terapkan dan mulai ulang server proyek"
diff --git a/packages/app/src/locales/ko/messages.json b/packages/app/src/locales/ko/messages.json
index 5c6aee309..fc0757256 100644
--- a/packages/app/src/locales/ko/messages.json
+++ b/packages/app/src/locales/ko/messages.json
@@ -1348,6 +1348,7 @@
"IKoTAC": ["사용 안 함 유지"],
"IMLUBh": ["잘못된 색상 값"],
"INN7OX": [["hiddenCount"], "개 더 보기"],
+ "INZWqo": ["에이전트 설정: 변경 사항은 이 대화를 다시 시작할 때 적용됩니다"],
"INp_z6": ["이 ", ["0"], "에 댓글을 남기거나 AI에 질문"],
"IO8REi": ["\"", ["name"], "\" 열기 실패: ", ["0"]],
"IQPyrD": ["누락된 페이지, 클릭하여 만들기"],
@@ -1808,6 +1809,7 @@
"Oos8fo": ["명령 복사"],
"OplnBG": ["이 빌드에서는 AI 도구를 관리할 수 없습니다."],
"OsSaYm": ["클론 실패: ", ["title"]],
+ "OuQezS": ["이 대화를 다시 시작할 때 적용됩니다"],
"OuY8t9": ["현재 브랜치에서 열기"],
"OvEjsP": ["복사 중…"],
"OxplNM": ["\"", ["0"], "\" 업데이트됨: ", ["1"], " 추가, ", ["2"], " 제거"],
diff --git a/packages/app/src/locales/ko/messages.po b/packages/app/src/locales/ko/messages.po
index 230f979d0..1300031b6 100644
--- a/packages/app/src/locales/ko/messages.po
+++ b/packages/app/src/locales/ko/messages.po
@@ -1525,6 +1525,10 @@ msgstr "Terminal을 읽기 쉽게 에이전트 패널을 닫았습니다."
msgid "Agent settings"
msgstr "에이전트 설정"
+#: src/components/acp/ThreadView.tsx
+msgid "Agent settings — changes apply when you pick this conversation back up"
+msgstr "에이전트 설정: 변경 사항은 이 대화를 다시 시작할 때 적용됩니다"
+
#: src/components/acp/ThreadView.tsx
msgid "Agent transcript"
msgstr "에이전트 대화 기록"
@@ -1734,6 +1738,10 @@ msgstr "이 컴퓨터의 모든 프로젝트에 적용됩니다. 기본 제공
msgid "Applies to this project on this computer only. Stored in .ok/local, not shared via git."
msgstr "이 컴퓨터의 이 프로젝트에만 적용됩니다. .ok/local에 저장되며 git으로 공유되지 않습니다."
+#: src/components/acp/ThreadView.tsx
+msgid "Applies when you pick this conversation back up"
+msgstr "이 대화를 다시 시작할 때 적용됩니다"
+
#: src/components/settings/NetworkAccessSection.tsx
msgid "Apply and restart project server"
msgstr "적용하고 프로젝트 서버 재시작"
diff --git a/packages/app/src/locales/pseudo/messages.json b/packages/app/src/locales/pseudo/messages.json
index c5ffa4508..15c1bcd94 100644
--- a/packages/app/src/locales/pseudo/messages.json
+++ b/packages/app/src/locales/pseudo/messages.json
@@ -1395,6 +1395,7 @@
"IKoTAC": ["Ķēēƥ ďĩśàƀĺēď"],
"IMLUBh": ["Ĩńvàĺĩď ćōĺōŕ vàĺũē"],
"INN7OX": ["Śĥōŵ ", ["hiddenCount"], " ḿōŕē"],
+ "INZWqo": ["Àĝēńţ śēţţĩńĝś — ćĥàńĝēś àƥƥĺŷ ŵĥēń ŷōũ ƥĩćķ ţĥĩś ćōńvēŕśàţĩōń ƀàćķ ũƥ"],
"INp_z6": ["Ćōḿḿēńţ ōŕ àśķ ÀĨ àƀōũţ ţĥĩś ", ["0"]],
"IO8REi": ["Ćōũĺďń'ţ ōƥēń \"", ["name"], "\": ", ["0"]],
"IQPyrD": ["Ḿĩśśĩńĝ ƥàĝē — ćĺĩćķ ţō ćŕēàţē"],
@@ -1871,6 +1872,7 @@
"Oos8fo": ["Ćōƥŷ ćōḿḿàńď"],
"OplnBG": ["Ḿàńàĝĩńĝ ÀĨ ţōōĺś ĩś ũńàvàĩĺàƀĺē ĩń ţĥĩś ƀũĩĺď."],
"OsSaYm": ["Ćĺōńē ƒàĩĺēď: ", ["title"]],
+ "OuQezS": ["Àƥƥĺĩēś ŵĥēń ŷōũ ƥĩćķ ţĥĩś ćōńvēŕśàţĩōń ƀàćķ ũƥ"],
"OuY8t9": ["Ōƥēń ĩń ćũŕŕēńţ ƀŕàńćĥ"],
"OvEjsP": ["Ćōƥŷĩńĝ..."],
"OxplNM": ["Ũƥďàţēď \"", ["0"], "\": àďďēď ", ["1"], ", ŕēḿōvēď ", ["2"]],
diff --git a/packages/app/src/locales/pseudo/messages.po b/packages/app/src/locales/pseudo/messages.po
index 3d90ad2ec..a53626a5b 100644
--- a/packages/app/src/locales/pseudo/messages.po
+++ b/packages/app/src/locales/pseudo/messages.po
@@ -1521,6 +1521,10 @@ msgstr ""
msgid "Agent settings"
msgstr ""
+#: src/components/acp/ThreadView.tsx
+msgid "Agent settings — changes apply when you pick this conversation back up"
+msgstr ""
+
#: src/components/acp/ThreadView.tsx
msgid "Agent transcript"
msgstr ""
@@ -1730,6 +1734,10 @@ msgstr ""
msgid "Applies to this project on this computer only. Stored in .ok/local, not shared via git."
msgstr ""
+#: src/components/acp/ThreadView.tsx
+msgid "Applies when you pick this conversation back up"
+msgstr ""
+
#: src/components/settings/NetworkAccessSection.tsx
msgid "Apply and restart project server"
msgstr ""
diff --git a/packages/app/src/locales/pt-BR/messages.json b/packages/app/src/locales/pt-BR/messages.json
index 77e0bf7d9..838bfb3c2 100644
--- a/packages/app/src/locales/pt-BR/messages.json
+++ b/packages/app/src/locales/pt-BR/messages.json
@@ -1606,6 +1606,9 @@
"IKoTAC": ["Deixar desativado"],
"IMLUBh": ["Valor de cor inválido"],
"INN7OX": ["Mostrar mais ", ["hiddenCount"]],
+ "INZWqo": [
+ "Configurações do agente: as alterações se aplicam quando você retomar esta conversa"
+ ],
"INp_z6": ["Comente ou pergunte à IA sobre este ", ["0"]],
"IO8REi": ["Não deu para abrir \"", ["name"], "\": ", ["0"]],
"IQPyrD": ["Página inexistente — clique para criar"],
@@ -2131,6 +2134,7 @@
"Oos8fo": ["Copiar comando"],
"OplnBG": ["O gerenciamento de ferramentas de IA não está disponível nesta compilação."],
"OsSaYm": ["Falha ao clonar: ", ["title"]],
+ "OuQezS": ["Aplica-se quando você retomar esta conversa"],
"OuY8t9": ["Abrir no ramo atual"],
"OvEjsP": ["Copiando..."],
"OxplNM": ["\"", ["0"], "\" atualizado: ", ["1"], " adicionados, ", ["2"], " removidos"],
diff --git a/packages/app/src/locales/pt-BR/messages.po b/packages/app/src/locales/pt-BR/messages.po
index 32beaf0e2..6074d54fb 100644
--- a/packages/app/src/locales/pt-BR/messages.po
+++ b/packages/app/src/locales/pt-BR/messages.po
@@ -1521,6 +1521,10 @@ msgstr "O painel de agentes foi fechado para manter o Terminal legível."
msgid "Agent settings"
msgstr "Configurações do agente"
+#: src/components/acp/ThreadView.tsx
+msgid "Agent settings — changes apply when you pick this conversation back up"
+msgstr "Configurações do agente: as alterações se aplicam quando você retomar esta conversa"
+
#: src/components/acp/ThreadView.tsx
msgid "Agent transcript"
msgstr "Transcrição do agente"
@@ -1730,6 +1734,10 @@ msgstr "Aplica-se a todos os projetos deste computador. Claude e Codex, iniciado
msgid "Applies to this project on this computer only. Stored in .ok/local, not shared via git."
msgstr "Aplica-se a este projeto somente neste computador. Guardado em .ok/local, não compartilhado pelo git."
+#: src/components/acp/ThreadView.tsx
+msgid "Applies when you pick this conversation back up"
+msgstr "Aplica-se quando você retomar esta conversa"
+
#: src/components/settings/NetworkAccessSection.tsx
msgid "Apply and restart project server"
msgstr "Aplicar e reiniciar o servidor do projeto"
diff --git a/packages/app/src/locales/ur/messages.json b/packages/app/src/locales/ur/messages.json
index 5809ef225..beccba41f 100644
--- a/packages/app/src/locales/ur/messages.json
+++ b/packages/app/src/locales/ur/messages.json
@@ -1425,6 +1425,7 @@
"IKoTAC": ["بند ہی رکھیں"],
"IMLUBh": ["رنگ کی قدر درست نہیں"],
"INN7OX": [["hiddenCount"], " مزید دکھائیں"],
+ "INZWqo": ["ایجنٹ کی ترتیبات: تبدیلیاں اس وقت لاگو ہوں گی جب آپ یہ گفتگو دوبارہ شروع کریں گے"],
"INp_z6": ["اس ", ["0"], " پر تبصرہ کریں یا AI سے پوچھیں"],
"IO8REi": ["«", ["name"], "» نہیں کھل سکی: ", ["0"]],
"IQPyrD": ["غائب صفحہ — بنانے کے لیے کلک کریں"],
@@ -1915,6 +1916,7 @@
"Oos8fo": ["کمانڈ نقل کریں"],
"OplnBG": ["اس بلڈ میں AI ٹولز کا انتظام دستیاب نہیں۔"],
"OsSaYm": ["کلون ناکام: ", ["title"]],
+ "OuQezS": ["جب آپ یہ گفتگو دوبارہ شروع کریں گے تو لاگو ہوگا"],
"OuY8t9": ["موجودہ برانچ میں کھولیں"],
"OvEjsP": ["نقل کیا جا رہا ہے..."],
"OxplNM": ["«", ["0"], "» تازہ ہوا: ", ["1"], " شامل، ", ["2"], " ہٹائے گئے"],
diff --git a/packages/app/src/locales/ur/messages.po b/packages/app/src/locales/ur/messages.po
index 44b3fb7ba..b439e04da 100644
--- a/packages/app/src/locales/ur/messages.po
+++ b/packages/app/src/locales/ur/messages.po
@@ -1525,6 +1525,10 @@ msgstr "Terminal کو پڑھنے کے قابل رکھنے کے لیے ایجنٹ
msgid "Agent settings"
msgstr "ایجنٹ کی ترتیبات"
+#: src/components/acp/ThreadView.tsx
+msgid "Agent settings — changes apply when you pick this conversation back up"
+msgstr "ایجنٹ کی ترتیبات: تبدیلیاں اس وقت لاگو ہوں گی جب آپ یہ گفتگو دوبارہ شروع کریں گے"
+
#: src/components/acp/ThreadView.tsx
msgid "Agent transcript"
msgstr "ایجنٹ کا ٹرانسکرپٹ"
@@ -1734,6 +1738,10 @@ msgstr "اس مشین کے تمام پروجیکٹس پر لاگو ہوتا ہے
msgid "Applies to this project on this computer only. Stored in .ok/local, not shared via git."
msgstr "صرف اسی کمپیوٹر پر اس پروجیکٹ پر لاگو ہوتا ہے۔ ‎.ok/local میں محفوظ، git کے ذریعے مشترک نہیں۔"
+#: src/components/acp/ThreadView.tsx
+msgid "Applies when you pick this conversation back up"
+msgstr "جب آپ یہ گفتگو دوبارہ شروع کریں گے تو لاگو ہوگا"
+
#: src/components/settings/NetworkAccessSection.tsx
msgid "Apply and restart project server"
msgstr "لاگو کریں اور پروجیکٹ سرور دوبارہ شروع کریں"
diff --git a/packages/app/src/locales/zh-Hans/messages.json b/packages/app/src/locales/zh-Hans/messages.json
index 143c7f8f0..6c8ec2040 100644
--- a/packages/app/src/locales/zh-Hans/messages.json
+++ b/packages/app/src/locales/zh-Hans/messages.json
@@ -1229,6 +1229,7 @@
"IKoTAC": ["保持关闭"],
"IMLUBh": ["无效的颜色值"],
"INN7OX": ["再显示 ", ["hiddenCount"], " 个"],
+ "INZWqo": ["智能体设置:更改将在继续此对话时生效"],
"INp_z6": ["对此", ["0"], "发表评论或询问 AI"],
"IO8REi": ["无法打开“", ["name"], "”:", ["0"]],
"IQPyrD": ["页面不存在——点击可创建"],
@@ -1653,6 +1654,7 @@
"Oos8fo": ["复制命令"],
"OplnBG": ["这个版本不支持管理 AI 工具。"],
"OsSaYm": ["克隆失败:", ["title"]],
+ "OuQezS": ["继续此对话时生效"],
"OuY8t9": ["在当前分支中打开"],
"OvEjsP": ["正在复制…"],
"OxplNM": ["已更新“", ["0"], "”:新增 ", ["1"], ",移除 ", ["2"]],
diff --git a/packages/app/src/locales/zh-Hans/messages.po b/packages/app/src/locales/zh-Hans/messages.po
index 15010f52b..fe1e0590e 100644
--- a/packages/app/src/locales/zh-Hans/messages.po
+++ b/packages/app/src/locales/zh-Hans/messages.po
@@ -1525,6 +1525,10 @@ msgstr "为保持 Terminal 清晰可读,已关闭智能体面板。"
msgid "Agent settings"
msgstr "智能体设置"
+#: src/components/acp/ThreadView.tsx
+msgid "Agent settings — changes apply when you pick this conversation back up"
+msgstr "智能体设置:更改将在继续此对话时生效"
+
#: src/components/acp/ThreadView.tsx
msgid "Agent transcript"
msgstr "智能体记录"
@@ -1734,6 +1738,10 @@ msgstr "适用于这台电脑上的所有项目。从内置终端启动的 Claud
msgid "Applies to this project on this computer only. Stored in .ok/local, not shared via git."
msgstr "仅在这台电脑上对本项目生效。保存在 .ok/local 中,不通过 git 共享。"
+#: src/components/acp/ThreadView.tsx
+msgid "Applies when you pick this conversation back up"
+msgstr "继续此对话时生效"
+
#: src/components/settings/NetworkAccessSection.tsx
msgid "Apply and restart project server"
msgstr "应用并重启项目服务器"
diff --git a/packages/app/src/locales/zh-Hant/messages.json b/packages/app/src/locales/zh-Hant/messages.json
index 0084bb770..30d7e7706 100644
--- a/packages/app/src/locales/zh-Hant/messages.json
+++ b/packages/app/src/locales/zh-Hant/messages.json
@@ -1243,6 +1243,7 @@
"IKoTAC": ["維持關閉"],
"IMLUBh": ["無效的色彩值"],
"INN7OX": ["再顯示 ", ["hiddenCount"], " 個"],
+ "INZWqo": ["代理設定:變更將在繼續此對話時生效"],
"INp_z6": ["對此", ["0"], "發表評論或詢問 AI"],
"IO8REi": ["無法開啟「", ["name"], "」:", ["0"]],
"IQPyrD": ["頁面不存在——點一下可建立"],
@@ -1677,6 +1678,7 @@
"Oos8fo": ["複製指令"],
"OplnBG": ["這個版本無法管理 AI 工具。"],
"OsSaYm": ["複製失敗:", ["title"]],
+ "OuQezS": ["繼續此對話時生效"],
"OuY8t9": ["在目前的分支中開啟"],
"OvEjsP": ["正在複製…"],
"OxplNM": ["已更新「", ["0"], "」:新增 ", ["1"], ",移除 ", ["2"]],
diff --git a/packages/app/src/locales/zh-Hant/messages.po b/packages/app/src/locales/zh-Hant/messages.po
index 418bed1b9..652a7c336 100644
--- a/packages/app/src/locales/zh-Hant/messages.po
+++ b/packages/app/src/locales/zh-Hant/messages.po
@@ -1525,6 +1525,10 @@ msgstr "為保持 Terminal 清晰可讀,已關閉智慧代理面板。"
msgid "Agent settings"
msgstr "代理設定"
+#: src/components/acp/ThreadView.tsx
+msgid "Agent settings — changes apply when you pick this conversation back up"
+msgstr "代理設定:變更將在繼續此對話時生效"
+
#: src/components/acp/ThreadView.tsx
msgid "Agent transcript"
msgstr "代理記錄"
@@ -1734,6 +1738,10 @@ msgstr "適用於這台電腦上的所有專案。從內建終端機啟動的 Cl
msgid "Applies to this project on this computer only. Stored in .ok/local, not shared via git."
msgstr "只在這台電腦上對這個專案生效。存在 .ok/local 中,不會透過 git 分享。"
+#: src/components/acp/ThreadView.tsx
+msgid "Applies when you pick this conversation back up"
+msgstr "繼續此對話時生效"
+
#: src/components/settings/NetworkAccessSection.tsx
msgid "Apply and restart project server"
msgstr "套用並重新啟動專案伺服器"
diff --git a/packages/server/src/acp/thread-manager.integration.test.ts b/packages/server/src/acp/thread-manager.integration.test.ts
index 5ac8fe291..7f5d6fbc0 100644
--- a/packages/server/src/acp/thread-manager.integration.test.ts
+++ b/packages/server/src/acp/thread-manager.integration.test.ts
@@ -772,7 +772,51 @@ function writeResumableAgentEntry(localDir: string, id: string, env: Record<stri
writeFileSync(
agentPath,
`
+import { appendFileSync } from 'node:fs';
const caps = (process.env.FAKE_CAPS ?? '').split(',').filter(Boolean);
+const withConfig = process.env.FAKE_CONFIG === '1';
+const withModes = process.env.FAKE_MODES === '1';
+let modeValue = 'ask';
+const modeState = () => ({
+ currentModeId: modeValue,
+ availableModes: [
+ { id: 'ask', name: 'Ask#' + process.pid },
+ { id: 'plan', name: 'Plan#' + process.pid },
+ ],
+});
+// applyInitialMode records a successful set locally rather than storing an
+// agent-returned object, so unlike configOptions the mode cannot be proven to
+// have reached the agent by inspecting the manager. This log is that proof:
+// the test truncates it before resuming, so any line in it came from the
+// process the resume started.
+const logSetMode = (modeId) => {
+ if (process.env.FAKE_LOG) appendFileSync(process.env.FAKE_LOG, modeId + '\\n');
+};
+// A resumed agent is a NEW process, so this resets to the default on every
+// resume — which is exactly what a real agent does with a fresh session.
+let modelValue = 'sonnet';
+// The pid tags every option this process hands out, so a test can tell values
+// that came from THIS session's response apart from ones the manager merely
+// replayed out of the persisted meta.
+const configOptions = () => [
+ {
+ id: 'model',
+ name: 'Model#' + process.pid,
+ type: 'select',
+ category: 'model',
+ currentValue: modelValue,
+ options: [{ value: 'sonnet', name: 'Sonnet' }, { value: 'opus', name: 'Opus' }],
+ },
+];
+// FAKE_CONFIG_ON_RESUME=0 models an agent that resumes without reporting its
+// config — legal per ACP, both response types mark configOptions optional.
+const resumeReply = () => {
+ const reportState = process.env.FAKE_CONFIG_ON_RESUME !== '0';
+ const out = {};
+ if (withConfig && reportState) out.configOptions = configOptions();
+ if (withModes && reportState) out.modes = modeState();
+ return out;
+};
const write = (msg) => process.stdout.write(JSON.stringify(msg) + '\\n');
let buffer = '';
process.stdin.setEncoding('utf8');
@@ -795,11 +839,25 @@ process.stdin.on('data', (chunk) => {
if (caps.includes('resume')) agentCapabilities.sessionCapabilities = { resume: {} };
reply({ protocolVersion: 1, agentCapabilities });
} else if (msg.method === 'session/new') {
- reply({ sessionId: 'sess-fixed' });
+ const newSession = { sessionId: 'sess-fixed' };
+ if (withConfig) newSession.configOptions = configOptions();
+ if (withModes) newSession.modes = modeState();
+ reply(newSession);
notify({
sessionUpdate: 'available_commands_update',
availableCommands: [{ name: 'fresh_only', description: 'advertised on session/new only' }],
});
+ } else if (msg.method === 'session/set_config_option') {
+ if (msg.params.configId === 'model') modelValue = msg.params.value;
+ reply({ configOptions: configOptions() });
+ } else if (msg.method === 'session/set_mode') {
+ if (!modeState().availableModes.some((m) => m.id === msg.params.modeId)) {
+ replyErr(-32602, 'unknown mode');
+ } else {
+ modeValue = msg.params.modeId;
+ logSetMode(msg.params.modeId);
+ reply({});
+ }
} else if (msg.method === 'session/prompt') {
notify({
sessionUpdate: 'agent_message_chunk',
@@ -812,11 +870,16 @@ process.stdin.on('data', (chunk) => {
} else {
notify({ sessionUpdate: 'user_message_chunk', content: { type: 'text', text: 'old-user' } });
notify({ sessionUpdate: 'agent_message_chunk', content: { type: 'text', text: 'old-agent' } });
- reply({});
+ reply(resumeReply());
}
} else if (msg.method === 'session/resume') {
if (msg.params.sessionId !== 'sess-fixed') replyErr(-32002, 'unknown session');
- else reply({});
+ // Holding the reply widens the window between the manager clearing
+ // 'archived' and the session actually being back, which is the state a
+ // concurrency guard has to be tested against.
+ else if (Number(process.env.FAKE_RESUME_DELAY_MS ?? 0) > 0)
+ setTimeout(() => reply(resumeReply()), Number(process.env.FAKE_RESUME_DELAY_MS));
+ else reply(resumeReply());
} else if (msg.id !== undefined) {
reply({});
}
@@ -1093,6 +1156,233 @@ describe('AcpThreadManager persistence + resume', () => {
expect(manager.getInfo(info.threadId)?.title).toBe('Fix the login redirect');
}, 45_000);
+ /**
+ * A resumed thread keeps answering on the model it was answering on. The
+ * agent comes up on its own defaults (the fake resets `modelValue` because
+ * resume spawns a new process), and the manager re-applies what the thread
+ * had settled on.
+ *
+ * The pid tag is what makes the assertion honest: the manager's cached
+ * options survive the archive, so `currentValue` alone would read 'opus'
+ * whether or not anything reached the agent. A name carrying the NEW pid can
+ * only have come from the resumed session's own response.
+ */
+ async function resumeWithConfig(reportOnResume: boolean): Promise<void> {
+ const contentDir = tmp();
+ const localDir = tmp();
+ writeResumableAgentEntry(localDir, 'fake-resume', {
+ FAKE_CAPS: 'resume,load',
+ FAKE_CONFIG: '1',
+ ...(reportOnResume ? {} : { FAKE_CONFIG_ON_RESUME: '0' }),
+ });
+ const manager = makeManager(contentDir, localDir);
+ await manager.init();
+ const threadId = await runOneTurn(manager, 'fake-resume', 'first message');
+
+ manager.setConfigOption(threadId, 'model', 'opus');
+ await waitUntil(
+ () => manager.getInfo(threadId)?.configOptions?.[0]?.currentValue === 'opus',
+ 15_000,
+ 'model applied before archive',
+ );
+ const beforeArchive = manager.getInfo(threadId)?.configOptions?.[0];
+
+ await manager.closeThread(threadId);
+ expect(manager.getInfo(threadId)?.archived).toBe(true);
+ await manager.resumeThread(threadId);
+ await waitUntil(
+ () => manager.getInfo(threadId)?.status === 'ready',
+ 15_000,
+ 'resumed thread ready',
+ );
+
+ const afterResume = manager.getInfo(threadId)?.configOptions?.[0];
+ expect(afterResume?.currentValue).toBe('opus');
+ // Different pid ⇒ these options came back from the resumed agent, so the
+ // set actually reached it rather than the manager replaying stale meta.
+ expect(afterResume?.name).not.toBe(beforeArchive?.name);
+
+ await manager.closeThread(threadId);
+ }
+
+ test('resume re-applies the thread settled config when the agent reports it', async () => {
+ await resumeWithConfig(true);
+ }, 45_000);
+
+ test('resume re-applies the thread settled config when the agent reports none', async () => {
+ // configOptions is optional in both resume responses. With none reported,
+ // the cached values look already-correct, so the re-apply has to fire on
+ // the unverified-cache path or the agent silently stays on its default.
+ await resumeWithConfig(false);
+ }, 45_000);
+
+ /**
+ * The mode half of the same contract. The manager records a successful mode
+ * set locally instead of storing an agent-returned object, so — unlike the
+ * config options — its own state cannot show whether the set reached the
+ * agent. The fake's set_mode log is the evidence: it is truncated before the
+ * resume, so anything in it afterwards came from the resumed process.
+ */
+ async function resumeWithMode(reportOnResume: boolean): Promise<void> {
+ const contentDir = tmp();
+ const localDir = tmp();
+ const setModeLog = join(tmp(), 'set-mode.log');
+ writeResumableAgentEntry(localDir, 'fake-resume', {
+ FAKE_CAPS: 'resume,load',
+ FAKE_MODES: '1',
+ FAKE_LOG: setModeLog,
+ ...(reportOnResume ? {} : { FAKE_CONFIG_ON_RESUME: '0' }),
+ });
+ const manager = makeManager(contentDir, localDir);
+ await manager.init();
+ const threadId = await runOneTurn(manager, 'fake-resume', 'first message');
+
+ manager.setMode(threadId, 'plan');
+ await waitUntil(
+ () => manager.getInfo(threadId)?.modes?.currentModeId === 'plan',
+ 15_000,
+ 'mode applied before archive',
+ );
+
+ await manager.closeThread(threadId);
+ writeFileSync(setModeLog, '');
+ await manager.resumeThread(threadId);
+ await waitUntil(
+ () => manager.getInfo(threadId)?.status === 'ready',
+ 15_000,
+ 'resumed thread ready',
+ );
+
+ expect(manager.getInfo(threadId)?.modes?.currentModeId).toBe('plan');
+ expect(readFileSync(setModeLog, 'utf8')).toContain('plan');
+
+ await manager.closeThread(threadId);
+ }
+
+ test('resume re-applies the thread settled mode when the agent reports it', async () => {
+ await resumeWithMode(true);
+ }, 45_000);
+
+ test('resume re-applies the thread settled mode when the agent reports none', async () => {
+ await resumeWithMode(false);
+ }, 45_000);
+
+ test('a mode pick on an archived thread is kept and applied by the resume', async () => {
+ const contentDir = tmp();
+ const localDir = tmp();
+ const setModeLog = join(tmp(), 'set-mode.log');
+ writeResumableAgentEntry(localDir, 'fake-resume', {
+ FAKE_CAPS: 'resume,load',
+ FAKE_MODES: '1',
+ FAKE_LOG: setModeLog,
+ });
+ const manager = makeManager(contentDir, localDir);
+ await manager.init();
+ const threadId = await runOneTurn(manager, 'fake-resume', 'first message');
+ await manager.closeThread(threadId);
+ writeFileSync(setModeLog, '');
+
+ // No agent to call, so this records intent — nothing should reach the wire.
+ manager.setMode(threadId, 'plan');
+ expect(manager.getInfo(threadId)?.modes?.currentModeId).toBe('plan');
+ expect(readFileSync(setModeLog, 'utf8')).toBe('');
+ // A mode the settled surface does not offer is refused rather than stored.
+ expect(() => manager.setMode(threadId, 'nope')).toThrow();
+ expect(manager.getInfo(threadId)?.modes?.currentModeId).toBe('plan');
+
+ await manager.resumeThread(threadId);
+ await waitUntil(
+ () => manager.getInfo(threadId)?.status === 'ready',
+ 15_000,
+ 'resumed thread ready',
+ );
+ expect(readFileSync(setModeLog, 'utf8')).toContain('plan');
+
+ await manager.closeThread(threadId);
+ }, 45_000);
+
+ test('a pick mid-resume is refused rather than sent at a half-open session', async () => {
+ const contentDir = tmp();
+ const localDir = tmp();
+ writeResumableAgentEntry(localDir, 'fake-resume', {
+ FAKE_CAPS: 'resume,load',
+ FAKE_CONFIG: '1',
+ FAKE_RESUME_DELAY_MS: '2000',
+ });
+ const manager = makeManager(contentDir, localDir);
+ await manager.init();
+ const threadId = await runOneTurn(manager, 'fake-resume', 'first message');
+ await manager.closeThread(threadId);
+
+ const resuming = manager.resumeThread(threadId);
+ // The flag clears well before the session is back — two awaits precede it —
+ // so from here the archived branch no longer covers picks and the
+ // in-flight guard is the only thing standing between a pick and a session
+ // the agent has not resumed yet.
+ await waitUntil(
+ () => manager.getInfo(threadId)?.archived === false,
+ 15_000,
+ 'resume past the archived flip',
+ );
+ expect(() => manager.setConfigOption(threadId, 'model', 'opus')).toThrow(/still resuming/);
+ expect(() => manager.setMode(threadId, 'plan')).toThrow(/still resuming/);
+
+ await resuming;
+ await manager.closeThread(threadId);
+ }, 45_000);
+
+ test('a config pick on an archived thread is kept and applied by the resume', async () => {
+ const contentDir = tmp();
+ const localDir = tmp();
+ writeResumableAgentEntry(localDir, 'fake-resume', {
+ FAKE_CAPS: 'resume,load',
+ FAKE_CONFIG: '1',
+ });
+ const manager = makeManager(contentDir, localDir);
+ await manager.init();
+ const threadId = await runOneTurn(manager, 'fake-resume', 'first message');
+ await manager.closeThread(threadId);
+ expect(manager.getInfo(threadId)?.archived).toBe(true);
+ const beforePick = manager.getInfo(threadId)?.configOptions?.[0];
+ expect(beforePick?.currentValue).toBe('sonnet');
+
+ // No agent is running, so this records intent rather than calling one.
+ manager.setConfigOption(threadId, 'model', 'opus');
+ expect(manager.getInfo(threadId)?.configOptions?.[0]?.currentValue).toBe('opus');
+
+ await manager.resumeThread(threadId);
+ await waitUntil(
+ () => manager.getInfo(threadId)?.status === 'ready',
+ 15_000,
+ 'resumed thread ready',
+ );
+ const afterResume = manager.getInfo(threadId)?.configOptions?.[0];
+ expect(afterResume?.currentValue).toBe('opus');
+ // New pid ⇒ the pick reached the resumed agent, not just our own record.
+ expect(afterResume?.name).not.toBe(beforePick?.name);
+
+ await manager.closeThread(threadId);
+ }, 45_000);
+
+ test('an archived thread rejects a value its options do not offer', async () => {
+ const contentDir = tmp();
+ const localDir = tmp();
+ writeResumableAgentEntry(localDir, 'fake-resume', {
+ FAKE_CAPS: 'resume,load',
+ FAKE_CONFIG: '1',
+ });
+ const manager = makeManager(contentDir, localDir);
+ await manager.init();
+ const threadId = await runOneTurn(manager, 'fake-resume', 'first message');
+ await manager.closeThread(threadId);
+
+ // Recording intent still validates against the settled options — otherwise
+ // the resume would carry a value the agent will refuse.
+ expect(() => manager.setConfigOption(threadId, 'model', 'gpt-9')).toThrow();
+ expect(() => manager.setConfigOption(threadId, 'nonexistent', 'opus')).toThrow();
+ expect(manager.getInfo(threadId)?.configOptions?.[0]?.currentValue).toBe('sonnet');
+ }, 45_000);
+
test('resume via session/resume: same thread continues, no history duplication', async () => {
const contentDir = tmp();
const localDir = tmp();
diff --git a/packages/server/src/acp/thread-manager.ts b/packages/server/src/acp/thread-manager.ts
index d1b282208..dcc27d22d 100644
--- a/packages/server/src/acp/thread-manager.ts
+++ b/packages/server/src/acp/thread-manager.ts
@@ -2311,12 +2311,33 @@ export class AcpThreadManager {
);
}
t.sessionId = sessionId;
+ // The agent brings up a fresh session on its own defaults, and the
+ // response below overwrites the settled choices this thread was using
+ // (they survive a restart via the persisted meta). Capture them first:
+ // a resumed conversation continuing on a different model than it was
+ // answering with is a silent change of behaviour mid-thread.
+ const resumedConfig: Record<string, string | boolean> = Object.fromEntries(
+ (t.info.configOptions ?? []).map((option) => [option.id, option.currentValue]),
+ );
+ const resumedModeId = t.info.modes?.currentModeId;
const modes = response.modes as ThreadInfo['modes'] | undefined;
if (modes !== undefined && modes !== null) t.info.modes = modes;
const configOptions = response.configOptions as ThreadInfo['configOptions'] | undefined;
if (configOptions !== undefined && configOptions !== null) {
t.info.configOptions = configOptions;
}
+ // Same order as a fresh session: config first, then the mode, since a
+ // model pick can reshape the mode surface. Both are best-effort against
+ // the settled session, so an option the agent has since retired is
+ // skipped rather than failing the resume. Reporting is optional in both
+ // resume responses, and when it is absent the cached values describe
+ // the session that ended — so re-send rather than trust them.
+ await this.applyInitialConfig(t, conn, resumedConfig, configOptions == null);
+ if (t.closed) throw new ThreadOpError('not-ready', 'thread closed during resume');
+ if (resumedModeId !== undefined) {
+ await this.applyInitialMode(t, conn, resumedModeId, modes == null);
+ if (t.closed) throw new ThreadOpError('not-ready', 'thread closed during resume');
+ }
this.emitStatus(t, 'ready');
this.opts.log.info(
{
@@ -3085,6 +3106,20 @@ export class AcpThreadManager {
setMode(threadId: string, modeId: string): void {
const t = this.mustGet(threadId);
+ // Same as `setConfigOption`: record the pick against the archived thread so
+ // the resume starts on it.
+ if (t.info.archived === true) {
+ const modes = t.info.modes;
+ if (modes == null || !modes.availableModes.some((m) => m.id === modeId)) {
+ throw new ThreadOpError('not-ready', `no such mode: ${modeId}`);
+ }
+ t.info.modes = { ...modes, currentModeId: modeId };
+ this.emitInfo(t);
+ return;
+ }
+ if (t.resumeInFlight) {
+ throw new ThreadOpError('not-ready', 'the thread is still resuming');
+ }
if (t.conn === null || t.sessionId === null) {
throw new ThreadOpError('not-ready', 'thread has no live agent session');
}
@@ -3109,6 +3144,30 @@ export class AcpThreadManager {
*/
setConfigOption(threadId: string, configId: string, value: string | boolean): void {
const t = this.mustGet(threadId);
+ // An archived thread has no agent to ask, but it does have the settled
+ // options on record. Store the choice against them and the resume applies
+ // it to the session it starts — the alternative is refusing a pick the UI
+ // offered, which reads to the user as the menu doing nothing.
+ if (t.info.archived === true) {
+ const option = (t.info.configOptions ?? []).find((o) => o.id === configId);
+ if (option === undefined) {
+ throw new ThreadOpError('not-ready', `no such config option: ${configId}`);
+ }
+ if (!initialConfigValueValid(option, value)) {
+ throw new ThreadOpError('not-ready', `invalid value for ${configId}`);
+ }
+ t.info.configOptions = (t.info.configOptions ?? []).map((o) =>
+ o.id === configId ? ({ ...o, currentValue: value } as SessionConfigOption) : o,
+ );
+ this.emitInfo(t);
+ return;
+ }
+ if (t.resumeInFlight) {
+ // `archived` flips to false at the top of the resume, so the branch above
+ // stops catching picks well before the agent has the session back. Same
+ // race `sendPrompt` guards: the connection exists, the session does not.
+ throw new ThreadOpError('not-ready', 'the thread is still resuming');
+ }
if (t.conn === null || t.sessionId === null) {
throw new ThreadOpError('not-ready', 'thread has no live agent session');
}
@@ -3142,6 +3201,12 @@ export class AcpThreadManager {
record: ThreadRecord,
conn: NonNullable<ThreadRecord['conn']>,
config: Record<string, string | boolean>,
+ // A resumed session that reported no `configOptions` leaves the cached
+ // values unverified: they describe the session that ended, not the one that
+ // just came up. Skipping a set because the cache already reads as the
+ // wanted value would then leave the agent on its own default while we
+ // report the wanted one, so the caller can turn that shortcut off.
+ sessionStateUnknown = false,
): Promise<void> {
const sessionId = record.sessionId;
if (sessionId === null) return;
@@ -3155,7 +3220,7 @@ export class AcpThreadManager {
if (value === undefined) continue;
const option = (record.info.configOptions ?? []).find((o) => o.id === configId);
if (option === undefined) continue; // agent no longer offers this option
- if (option.currentValue === value) continue; // already the agent's default
+ if (!sessionStateUnknown && option.currentValue === value) continue; // already the agent's default
if (!initialConfigValueValid(option, value)) continue; // stored value gone (e.g. retired model)
const request: SetSessionConfigOptionRequest =
typeof value === 'boolean'
@@ -3182,7 +3247,7 @@ export class AcpThreadManager {
// didn't stick" diagnosable from a bundle without correlating per-id lines.
if (rejected.length > 0) {
this.opts.log.warn(
- { threadId: record.info.threadId, rejectedConfigIds: rejected },
+ { threadId: record.info.threadId, rejectedConfigIds: rejected, sessionStateUnknown },
'[acp-threads] some remembered config options could not be applied to the new session',
);
}
@@ -3201,6 +3266,8 @@ export class AcpThreadManager {
record: ThreadRecord,
conn: NonNullable<ThreadRecord['conn']>,
modeId: string,
+ /** See `applyInitialConfig` — same unverified-cache case, same shortcut. */
+ sessionStateUnknown = false,
): Promise<void> {
const sessionId = record.sessionId;
if (sessionId === null) return;
@@ -3208,7 +3275,7 @@ export class AcpThreadManager {
if (modes != null) {
// Legacy SessionModeState path (Claude's permission modes).
if (modes.availableModes.some((m) => m.id === modeId)) {
- if (modes.currentModeId === modeId) return; // already the session default
+ if (!sessionStateUnknown && modes.currentModeId === modeId) return; // already the session default
try {
await conn.agent.request(acpMethods.agent.session.setMode, { sessionId, modeId });
record.info.modes = { ...modes, currentModeId: modeId };
@@ -3226,7 +3293,8 @@ export class AcpThreadManager {
const option = (record.info.configOptions ?? []).find(
(o) => o.category === 'mode' && initialConfigValueValid(o, modeId),
);
- if (option === undefined || option.currentValue === modeId) return;
+ if (option === undefined) return;
+ if (!sessionStateUnknown && option.currentValue === modeId) return;
try {
const response: SetSessionConfigOptionResponse = await conn.agent.request(
acpMethods.agent.session.setConfigOption,