From d67dffac7fed4c242feca093c52373579aa0f576 Mon Sep 17 00:00:00 2001 From: Joe Guo Date: Wed, 18 Nov 2026 19:54:15 +0000 Subject: [PATCH] fix(dashboard): show a worker-hosted discussion on the conductor mode Board --- test/test_work_ledger_board.py | 11 +++ .../capture/conductor-mode-discussing.html | 11 +++ website/capture/conductor-mode-discussing.tsx | 64 +++++++++++++ website/src/api/crewBoard.ts | 17 ++++ website/src/i18n/locales/bn.json | 11 +++ website/src/i18n/locales/de.json | 11 +++ website/src/i18n/locales/en-XA.json | 11 +++ website/src/i18n/locales/en.manual.json | 11 +++ website/src/i18n/locales/es.json | 11 +++ website/src/i18n/locales/fr.json | 11 +++ website/src/i18n/locales/hi.json | 11 +++ website/src/i18n/locales/it.json | 11 +++ website/src/i18n/locales/ja.json | 11 +++ website/src/i18n/locales/ko.json | 11 +++ website/src/i18n/locales/pt.json | 11 +++ website/src/i18n/locales/ru.json | 11 +++ website/src/i18n/locales/zh-CN.json | 11 +++ ...ConductorModeCrewPanel.discussion.test.tsx | 96 +++++++++++++++++++ .../ConductorModeCrewPanel.test.ts | 19 ++++ .../command-center/ConductorModeCrewPanel.tsx | 85 ++++++++++++++-- 20 files changed, 439 insertions(+), 7 deletions(-) create mode 100644 website/capture/conductor-mode-discussing.html create mode 100644 website/capture/conductor-mode-discussing.tsx create mode 100644 website/src/pages/chat/command-center/ConductorModeCrewPanel.discussion.test.tsx diff --git a/test/test_work_ledger_board.py b/test/test_work_ledger_board.py index c6a2ebdc0420..3f0acb701c53 100644 --- a/test/test_work_ledger_board.py +++ b/test/test_work_ledger_board.py @@ -495,6 +495,17 @@ async def test_a_report_the_harness_never_delivered_is_on_the_board_without_the_ assert WORKER not in response.body.decode() +@pytest.mark.asyncio +async def test_a_hosted_discussion_reaches_the_board_row(): + """The Board's "discussing" row reads `discussion` from this payload.""" + item_id = _item() + _bind(item_id) + _report(item_id, "progress", discussion={"phase": "talking", "round": 2, "agreed": ["ship A"]}) + body, _ = await _call(_state({WORKER: _slot(running=True)}), CONDUCTOR) + talk = body["items"][0]["discussion"] + assert (talk["phase"], talk["round"], talk["agreed"]) == ("talking", 2, ["ship A"]) + + @pytest.mark.asyncio async def test_a_board_shows_only_its_own_conductor_s_items(): mine = _item(CONDUCTOR, title="mine") diff --git a/website/capture/conductor-mode-discussing.html b/website/capture/conductor-mode-discussing.html new file mode 100644 index 000000000000..3ae125457f9a --- /dev/null +++ b/website/capture/conductor-mode-discussing.html @@ -0,0 +1,11 @@ + + + + + Conductor mode Board: discussing row + + +
+ + + diff --git a/website/capture/conductor-mode-discussing.tsx b/website/capture/conductor-mode-discussing.tsx new file mode 100644 index 000000000000..a9a5745de477 --- /dev/null +++ b/website/capture/conductor-mode-discussing.tsx @@ -0,0 +1,64 @@ +/** + * Capture page: the conductor mode Board with a milestone whose worker hosts a + * discussion. `?open=1` opens its panel, `?lang=zh-CN` (or any shipped locale) + * picks the language, `?theme=light` the light palette. The panel is the real + * component; only the reads are fixtures. + */ +import { createRoot } from 'react-dom/client' +import { Provider } from 'react-redux' +import { QueryClient, QueryClientProvider } from '@tanstack/react-query' +import { api } from '../src/api/client' +import { store } from '../src/store' +import { initI18n } from '../src/i18n/all' +import ConductorModeCrewPanel from '../src/pages/chat/command-center/ConductorModeCrewPanel' +import '../src/index.css' + +const params = new URLSearchParams(location.search) +document.documentElement.setAttribute('data-theme', params.get('theme') === 'light' ? 'light' : 'dark') + +const ago = (min: number) => new Date(Date.now() - min * 60_000).toISOString() +const item = (id: string, title: string, over: Record) => ({ + schema: 1, item_id: id, title, acceptance: { kind: 'human_approval' }, state: 'open', verdict: null, decision: '', round: 1, + fails: 0, status: 'progress', summary: 'Round 2 running.', artifacts: {}, pr: null, last_report_at: ago(3), created_at: ago(40), + closed_at: null, decided_at: null, orphaned: false, stale: false, acceptance_concrete: true, outstanding: false, terminal: false, + alive: 'running', events: [], reason: null, awaits_person: false, ...over, +}) +const discussion = { + phase: 'talking', round: 2, minutes: 12, direction: 'Multiline box in the card, attach button beside it', + agreed: ['One click sends text and files together', 'Offline state says so plainly'], + disputed: [{ point: 'Where the attach button goes', sides: 'A: inside the card · B: reuse the chat box' }], + checking: ['Paste size limit for images'], + recent: [{ who: 'A', text: 'The card already owns its own input.' }, { who: 'B', text: 'Two inputs confuse people.' }], + thread: '/chat/worker-grill', +} +const ITEMS = [ + item('a', 'Rename the chip', { state: 'accepted', verdict: 'pass', status: 'done', summary: 'Merged.', terminal: true, alive: 'closed', closed_at: ago(10) }), + item('d', 'Pick the card input', { discussion }), + item('b', 'Update the docs', { summary: 'Editing the guide.' }), +] +const conductor = { schema: 1, slot_key: 'root', goal: 'Let people send rich input from the discussion card.', round: 1, depth: 0, parent_item: null, created_at: ago(60) } +Object.assign(api, { + crewWorkers: async () => ({ root: 'root', workers: [] }), + crewBoard: async () => ({ conductor, conductor_alive: 'idle', items: ITEMS, take_over_available: false }), + sessionSummary: async () => ({ enabled: false, stale: false, intents: [], constraints: [], generated_at: null, user_turns: null, last_activity: null }), +}) + +const qc = new QueryClient({ defaultOptions: { queries: { retry: false } } }) +initI18n(params.get('lang') || 'en') +createRoot(document.getElementById('root')!).render( + + +
+ +
+
+
, +) +if (params.get('open') === '1') { + const click = () => { + const b = document.querySelector('[data-testid="conductor-mode-talk-toggle"]') + if (b) b.click() + else setTimeout(click, 100) + } + click() +} diff --git a/website/src/api/crewBoard.ts b/website/src/api/crewBoard.ts index 2c09b058aa49..b3f018074e07 100644 --- a/website/src/api/crewBoard.ts +++ b/website/src/api/crewBoard.ts @@ -91,6 +91,23 @@ export interface WorkBoardItem { terminal: boolean alive: AliveState events: WorkBoardEvent[] + /** Where a discussion this item's worker hosts stands, from its last report + * (`work_vocab.coerce_discussion`). Absent when the worker hosts none. */ + discussion?: WorkDiscussion | null +} + +/** A worker-hosted discussion, as its last `work_report` carried it. */ +export interface WorkDiscussion { + phase: 'talking' | 'checking' | 'asking' | 'done' + round?: number + minutes?: number + direction?: string + /** An http(s) link or an in-app path (`/chat/...`), checked server-side. */ + thread?: string + agreed?: string[] + checking?: string[] + disputed?: { point: string; sides?: string }[] + recent?: { who: string; text: string }[] } /** The conductor's own record. No `worker_session_key` anywhere in it. */ diff --git a/website/src/i18n/locales/bn.json b/website/src/i18n/locales/bn.json index 130e2fed11c7..031bbcf4013f 100644 --- a/website/src/i18n/locales/bn.json +++ b/website/src/i18n/locales/bn.json @@ -10858,6 +10858,17 @@ "conductor_mode_quiet": "চুপ", "conductor_mode_recap_title": "সংক্ষেপ", "conductor_mode_ms_running": "চলছে", + "conductor_mode_ms_discussing": "আলোচনা চলছে", + "conductor_mode_ms_discussing_round": "রাউন্ড {{round}}", + "conductor_mode_talk_counts": "একমত {{agreed}} · মতভেদ {{disputed}} · যাচাই চলছে {{checking}}", + "conductor_mode_talk_show": "আলোচনা দেখাও", + "conductor_mode_talk_hide": "আলোচনা লুকাও", + "conductor_mode_talk_direction": "দিক", + "conductor_mode_talk_agreed": "একমত", + "conductor_mode_talk_disputed": "মতভেদ", + "conductor_mode_talk_checking": "যাচাই চলছে", + "conductor_mode_talk_recent": "সাম্প্রতিক কথা", + "conductor_mode_talk_thread": "পুরো আলোচনা দেখো ↗", "conductor_mode_ms_not_started": "শুরু হয়নি", "conductor_mode_ms_next": "পরবর্তী", "conductor_mode_ms_waiting_approval": "উপরে তোমার অনুমোদনের অপেক্ষায়", diff --git a/website/src/i18n/locales/de.json b/website/src/i18n/locales/de.json index 1e0b2ef5a968..47b693e21ee8 100644 --- a/website/src/i18n/locales/de.json +++ b/website/src/i18n/locales/de.json @@ -10858,6 +10858,17 @@ "conductor_mode_quiet": "ruhig", "conductor_mode_recap_title": "Zusammenfassung", "conductor_mode_ms_running": "In Arbeit", + "conductor_mode_ms_discussing": "In Diskussion", + "conductor_mode_ms_discussing_round": "Runde {{round}}", + "conductor_mode_talk_counts": "Einig {{agreed}} · Strittig {{disputed}} · In Prüfung {{checking}}", + "conductor_mode_talk_show": "Diskussion anzeigen", + "conductor_mode_talk_hide": "Diskussion ausblenden", + "conductor_mode_talk_direction": "Richtung", + "conductor_mode_talk_agreed": "Einig", + "conductor_mode_talk_disputed": "Strittig", + "conductor_mode_talk_checking": "In Prüfung", + "conductor_mode_talk_recent": "Letzte Beiträge", + "conductor_mode_talk_thread": "Ganzen Verlauf ansehen ↗", "conductor_mode_ms_not_started": "Nicht begonnen", "conductor_mode_ms_next": "als Nächstes", "conductor_mode_ms_waiting_approval": "Wartet oben auf deine Freigabe", diff --git a/website/src/i18n/locales/en-XA.json b/website/src/i18n/locales/en-XA.json index 015613f1b66c..8e6e5868f808 100644 --- a/website/src/i18n/locales/en-XA.json +++ b/website/src/i18n/locales/en-XA.json @@ -10669,6 +10669,17 @@ "conductor_mode_quiet": "[ǫùìèţ ········]", "conductor_mode_recap_title": "[Ŕèçàþ ········]", "conductor_mode_ms_running": "[Ìñ þŕøğŕèşş ··········]", + "conductor_mode_ms_discussing": "[Ðìşçùşşìñğ ···············]", + "conductor_mode_ms_discussing_round": "[Ŕøùñð {{round}} ·········]", + "conductor_mode_talk_counts": "[Àğŕèèð {{agreed}} · Ðìşþùţèð {{disputed}} · Ɓèìñğ çĥèçķèð {{checking}} ··················]", + "conductor_mode_talk_show": "[Şĥøẁ ţĥè ðìşçùşşìøñ ·················]", + "conductor_mode_talk_hide": "[Ĥìðè ţĥè ðìşçùşşìøñ ·················]", + "conductor_mode_talk_direction": "[Ðìŕèçţìøñ ··············]", + "conductor_mode_talk_agreed": "[Àğŕèèð ·········]", + "conductor_mode_talk_disputed": "[Ðìşþùţèð ············]", + "conductor_mode_talk_checking": "[Ɓèìñğ çĥèçķèð ············]", + "conductor_mode_talk_recent": "[Ĺàţèşţ ĺìñèş ···········]", + "conductor_mode_talk_thread": "[Şèè ţĥè ƀàçķ-àñð-ƒøŕţĥ ↗ ·················]", "conductor_mode_ms_not_started": "[Ñøţ şţàŕţèð ··········]", "conductor_mode_ms_next": "[ñèẋţ ······]", "conductor_mode_ms_waiting_approval": "[Ẁàìţìñğ øñ ýøùŕ àþþŕøṽàĺ àƀøṽè ·····················]", diff --git a/website/src/i18n/locales/en.manual.json b/website/src/i18n/locales/en.manual.json index 08179edf8467..e608a89d2ce9 100644 --- a/website/src/i18n/locales/en.manual.json +++ b/website/src/i18n/locales/en.manual.json @@ -4563,6 +4563,17 @@ "conductor_mode_quiet": "quiet", "conductor_mode_recap_title": "Recap", "conductor_mode_ms_running": "In progress", + "conductor_mode_ms_discussing": "Discussing", + "conductor_mode_ms_discussing_round": "Round {{round}}", + "conductor_mode_talk_counts": "Agreed {{agreed}} · Disputed {{disputed}} · Being checked {{checking}}", + "conductor_mode_talk_show": "Show the discussion", + "conductor_mode_talk_hide": "Hide the discussion", + "conductor_mode_talk_direction": "Direction", + "conductor_mode_talk_agreed": "Agreed", + "conductor_mode_talk_disputed": "Disputed", + "conductor_mode_talk_checking": "Being checked", + "conductor_mode_talk_recent": "Latest lines", + "conductor_mode_talk_thread": "See the back-and-forth ↗", "conductor_mode_ms_not_started": "Not started", "conductor_mode_ms_next": "next", "conductor_mode_ms_waiting_approval": "Waiting on your approval above", diff --git a/website/src/i18n/locales/es.json b/website/src/i18n/locales/es.json index a4f6f7412ae6..6f1485a29e92 100644 --- a/website/src/i18n/locales/es.json +++ b/website/src/i18n/locales/es.json @@ -11106,6 +11106,17 @@ "conductor_mode_quiet": "inactivo", "conductor_mode_recap_title": "Resumen", "conductor_mode_ms_running": "En curso", + "conductor_mode_ms_discussing": "En debate", + "conductor_mode_ms_discussing_round": "Ronda {{round}}", + "conductor_mode_talk_counts": "Acordados {{agreed}} · En disputa {{disputed}} · En revisión {{checking}}", + "conductor_mode_talk_show": "Ver el debate", + "conductor_mode_talk_hide": "Ocultar el debate", + "conductor_mode_talk_direction": "Dirección", + "conductor_mode_talk_agreed": "Acordado", + "conductor_mode_talk_disputed": "En disputa", + "conductor_mode_talk_checking": "En revisión", + "conductor_mode_talk_recent": "Últimas frases", + "conductor_mode_talk_thread": "Ver el intercambio ↗", "conductor_mode_ms_not_started": "Sin empezar", "conductor_mode_ms_next": "siguiente", "conductor_mode_ms_waiting_approval": "Esperando tu aprobación arriba", diff --git a/website/src/i18n/locales/fr.json b/website/src/i18n/locales/fr.json index bbbecf052a57..3119f26a7756 100644 --- a/website/src/i18n/locales/fr.json +++ b/website/src/i18n/locales/fr.json @@ -11106,6 +11106,17 @@ "conductor_mode_quiet": "silencieux", "conductor_mode_recap_title": "Récapitulatif", "conductor_mode_ms_running": "En cours", + "conductor_mode_ms_discussing": "En discussion", + "conductor_mode_ms_discussing_round": "Tour {{round}}", + "conductor_mode_talk_counts": "D’accord {{agreed}} · En désaccord {{disputed}} · En vérification {{checking}}", + "conductor_mode_talk_show": "Afficher la discussion", + "conductor_mode_talk_hide": "Masquer la discussion", + "conductor_mode_talk_direction": "Direction", + "conductor_mode_talk_agreed": "Accords", + "conductor_mode_talk_disputed": "Désaccords", + "conductor_mode_talk_checking": "En vérification", + "conductor_mode_talk_recent": "Dernières répliques", + "conductor_mode_talk_thread": "Voir les échanges ↗", "conductor_mode_ms_not_started": "Pas commencé", "conductor_mode_ms_next": "suivant", "conductor_mode_ms_waiting_approval": "En attente de ton approbation ci-dessus", diff --git a/website/src/i18n/locales/hi.json b/website/src/i18n/locales/hi.json index 3be5bdd7aa62..d0d8e1fb6fc9 100644 --- a/website/src/i18n/locales/hi.json +++ b/website/src/i18n/locales/hi.json @@ -10858,6 +10858,17 @@ "conductor_mode_quiet": "शांत", "conductor_mode_recap_title": "सारांश", "conductor_mode_ms_running": "जारी", + "conductor_mode_ms_discussing": "चर्चा जारी", + "conductor_mode_ms_discussing_round": "दौर {{round}}", + "conductor_mode_talk_counts": "सहमत {{agreed}} · असहमत {{disputed}} · जाँच में {{checking}}", + "conductor_mode_talk_show": "चर्चा दिखाएँ", + "conductor_mode_talk_hide": "चर्चा छिपाएँ", + "conductor_mode_talk_direction": "दिशा", + "conductor_mode_talk_agreed": "सहमत", + "conductor_mode_talk_disputed": "असहमत", + "conductor_mode_talk_checking": "जाँच में", + "conductor_mode_talk_recent": "हाल की बातें", + "conductor_mode_talk_thread": "पूरी बातचीत देखो ↗", "conductor_mode_ms_not_started": "शुरू नहीं हुआ", "conductor_mode_ms_next": "अगला", "conductor_mode_ms_waiting_approval": "ऊपर तुम्हारी मंज़ूरी का इंतज़ार", diff --git a/website/src/i18n/locales/it.json b/website/src/i18n/locales/it.json index deaad73669d9..310945bffeeb 100644 --- a/website/src/i18n/locales/it.json +++ b/website/src/i18n/locales/it.json @@ -11106,6 +11106,17 @@ "conductor_mode_quiet": "inattivo", "conductor_mode_recap_title": "Riepilogo", "conductor_mode_ms_running": "In corso", + "conductor_mode_ms_discussing": "In discussione", + "conductor_mode_ms_discussing_round": "Round {{round}}", + "conductor_mode_talk_counts": "Concordati {{agreed}} · In disaccordo {{disputed}} · In verifica {{checking}}", + "conductor_mode_talk_show": "Mostra la discussione", + "conductor_mode_talk_hide": "Nascondi la discussione", + "conductor_mode_talk_direction": "Direzione", + "conductor_mode_talk_agreed": "Concordato", + "conductor_mode_talk_disputed": "In disaccordo", + "conductor_mode_talk_checking": "In verifica", + "conductor_mode_talk_recent": "Ultimi interventi", + "conductor_mode_talk_thread": "Vedi lo scambio ↗", "conductor_mode_ms_not_started": "Non iniziato", "conductor_mode_ms_next": "prossimo", "conductor_mode_ms_waiting_approval": "In attesa della tua approvazione qui sopra", diff --git a/website/src/i18n/locales/ja.json b/website/src/i18n/locales/ja.json index 51613b3c78c6..eaf7d845fb5a 100644 --- a/website/src/i18n/locales/ja.json +++ b/website/src/i18n/locales/ja.json @@ -10610,6 +10610,17 @@ "conductor_mode_quiet": "停止中", "conductor_mode_recap_title": "まとめ", "conductor_mode_ms_running": "進行中", + "conductor_mode_ms_discussing": "議論中", + "conductor_mode_ms_discussing_round": "第 {{round}} ラウンド", + "conductor_mode_talk_counts": "合意 {{agreed}} · 相違 {{disputed}} · 確認中 {{checking}}", + "conductor_mode_talk_show": "議論を開く", + "conductor_mode_talk_hide": "議論を閉じる", + "conductor_mode_talk_direction": "方向性", + "conductor_mode_talk_agreed": "合意", + "conductor_mode_talk_disputed": "相違", + "conductor_mode_talk_checking": "確認中", + "conductor_mode_talk_recent": "最近の発言", + "conductor_mode_talk_thread": "やり取りを見る ↗", "conductor_mode_ms_not_started": "未開始", "conductor_mode_ms_next": "次", "conductor_mode_ms_waiting_approval": "上で承認を待っています", diff --git a/website/src/i18n/locales/ko.json b/website/src/i18n/locales/ko.json index 6b0ba05ea5fb..2b0304cc613d 100644 --- a/website/src/i18n/locales/ko.json +++ b/website/src/i18n/locales/ko.json @@ -10610,6 +10610,17 @@ "conductor_mode_quiet": "조용함", "conductor_mode_recap_title": "요약", "conductor_mode_ms_running": "진행 중", + "conductor_mode_ms_discussing": "논의 중", + "conductor_mode_ms_discussing_round": "{{round}}라운드", + "conductor_mode_talk_counts": "합의 {{agreed}} · 이견 {{disputed}} · 확인 중 {{checking}}", + "conductor_mode_talk_show": "논의 펼치기", + "conductor_mode_talk_hide": "논의 접기", + "conductor_mode_talk_direction": "방향", + "conductor_mode_talk_agreed": "합의", + "conductor_mode_talk_disputed": "이견", + "conductor_mode_talk_checking": "확인 중", + "conductor_mode_talk_recent": "최근 발언", + "conductor_mode_talk_thread": "전체 대화 보기 ↗", "conductor_mode_ms_not_started": "시작 전", "conductor_mode_ms_next": "다음", "conductor_mode_ms_waiting_approval": "위에서 승인을 기다리는 중", diff --git a/website/src/i18n/locales/pt.json b/website/src/i18n/locales/pt.json index e28636a26443..619473f296c9 100644 --- a/website/src/i18n/locales/pt.json +++ b/website/src/i18n/locales/pt.json @@ -11106,6 +11106,17 @@ "conductor_mode_quiet": "inativo", "conductor_mode_recap_title": "Resumo", "conductor_mode_ms_running": "Em andamento", + "conductor_mode_ms_discussing": "Em discussão", + "conductor_mode_ms_discussing_round": "Rodada {{round}}", + "conductor_mode_talk_counts": "Acordados {{agreed}} · Em disputa {{disputed}} · Em verificação {{checking}}", + "conductor_mode_talk_show": "Mostrar a discussão", + "conductor_mode_talk_hide": "Ocultar a discussão", + "conductor_mode_talk_direction": "Direção", + "conductor_mode_talk_agreed": "Acordado", + "conductor_mode_talk_disputed": "Em disputa", + "conductor_mode_talk_checking": "Em verificação", + "conductor_mode_talk_recent": "Últimas falas", + "conductor_mode_talk_thread": "Ver a conversa ↗", "conductor_mode_ms_not_started": "Não iniciado", "conductor_mode_ms_next": "próximo", "conductor_mode_ms_waiting_approval": "Aguardando sua aprovação acima", diff --git a/website/src/i18n/locales/ru.json b/website/src/i18n/locales/ru.json index 7878691efce1..ef6cba56df2c 100644 --- a/website/src/i18n/locales/ru.json +++ b/website/src/i18n/locales/ru.json @@ -11329,6 +11329,17 @@ "conductor_mode_quiet": "затихло", "conductor_mode_recap_title": "Сводка", "conductor_mode_ms_running": "Выполняется", + "conductor_mode_ms_discussing": "Обсуждение", + "conductor_mode_ms_discussing_round": "Раунд {{round}}", + "conductor_mode_talk_counts": "Согласовано {{agreed}} · Спорно {{disputed}} · Проверяется {{checking}}", + "conductor_mode_talk_show": "Показать обсуждение", + "conductor_mode_talk_hide": "Скрыть обсуждение", + "conductor_mode_talk_direction": "Направление", + "conductor_mode_talk_agreed": "Согласовано", + "conductor_mode_talk_disputed": "Спорно", + "conductor_mode_talk_checking": "Проверяется", + "conductor_mode_talk_recent": "Последние реплики", + "conductor_mode_talk_thread": "Открыть всю переписку ↗", "conductor_mode_ms_not_started": "Не начато", "conductor_mode_ms_next": "далее", "conductor_mode_ms_waiting_approval": "Ждёт твоего одобрения выше", diff --git a/website/src/i18n/locales/zh-CN.json b/website/src/i18n/locales/zh-CN.json index a245a6b236b4..a8cd77e760d8 100644 --- a/website/src/i18n/locales/zh-CN.json +++ b/website/src/i18n/locales/zh-CN.json @@ -10610,6 +10610,17 @@ "conductor_mode_quiet": "无动静", "conductor_mode_recap_title": "回顾", "conductor_mode_ms_running": "进行中", + "conductor_mode_ms_discussing": "讨论中", + "conductor_mode_ms_discussing_round": "第 {{round}} 轮", + "conductor_mode_talk_counts": "已一致 {{agreed}} · 分歧 {{disputed}} · 正在查 {{checking}}", + "conductor_mode_talk_show": "展开讨论", + "conductor_mode_talk_hide": "收起讨论", + "conductor_mode_talk_direction": "方向", + "conductor_mode_talk_agreed": "已一致", + "conductor_mode_talk_disputed": "分歧", + "conductor_mode_talk_checking": "正在查", + "conductor_mode_talk_recent": "最近几句", + "conductor_mode_talk_thread": "看来回 ↗", "conductor_mode_ms_not_started": "未开始", "conductor_mode_ms_next": "下一个", "conductor_mode_ms_waiting_approval": "等你在上方批准", diff --git a/website/src/pages/chat/command-center/ConductorModeCrewPanel.discussion.test.tsx b/website/src/pages/chat/command-center/ConductorModeCrewPanel.discussion.test.tsx new file mode 100644 index 000000000000..64d8da9e4982 --- /dev/null +++ b/website/src/pages/chat/command-center/ConductorModeCrewPanel.discussion.test.tsx @@ -0,0 +1,96 @@ +/** + * Conductor mode Board > Milestones: an item whose worker hosts a discussion + * reads "Discussing" with its round and minutes, the agreed / disputed / + * checking counts under it, and behind a toggle what the discussion holds. + */ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { fireEvent, render, screen, within } from '@testing-library/react' +import { QueryClient, QueryClientProvider } from '@tanstack/react-query' +import { Provider } from 'react-redux' +import { createTestStore } from '../../../test/helpers' + +const api = vi.hoisted(() => ({ crewWorkers: vi.fn(), resumeChatSlot: vi.fn(), crewBoard: vi.fn(), crewBoardAction: vi.fn(), sessionSummary: vi.fn(), sendMessage: vi.fn() })) +vi.mock('../../../api/client', () => ({ api })) +vi.mock('../../../hooks/usePanelTabs', () => ({ openPanelView: vi.fn() })) + +import ConductorModeCrewPanel from './ConductorModeCrewPanel' +import type { WorkBoardItem } from '../../../api/crewBoard' + +const TALK = { + phase: 'talking' as const, round: 2, minutes: 15, direction: 'Card multiline first', + agreed: ['One send carries text and files', 'Offline says so'], checking: ['Paste size cap'], + disputed: [{ point: 'Attach button', sides: 'A: in the card · B: in the chat' }], + recent: [{ who: 'A', text: 'The card already has a box' }], thread: '/chat/abc', +} + +const ITEM = (over: Partial): WorkBoardItem => ({ + schema: 1, item_id: 'it_a', title: 'Pick the card input', acceptance: { kind: 'human_approval' }, state: 'open', verdict: null, + decision: '', round: 1, fails: 0, status: 'progress', summary: 'Round 2 running.', artifacts: {}, pr: null, + last_report_at: '2026-11-18T18:30:00Z', created_at: '2026-11-18T18:00:00Z', closed_at: null, decided_at: null, + orphaned: false, stale: false, acceptance_concrete: true, outstanding: false, terminal: false, alive: 'running', events: [], + reason: null, awaits_person: false, discussion: TALK, ...over, +} as WorkBoardItem) + +const BOARD = { conductor: { schema: 1, slot_key: 'root-1', goal: 'Pick the input.', round: 1, depth: 0, parent_item: null, created_at: '' }, conductor_alive: 'idle', items: [] as WorkBoardItem[], take_over_available: false } + +function renderPanel() { + const qc = new QueryClient({ defaultOptions: { queries: { retry: false } } }) + const store = createTestStore({ dashboard: { slots: [] } } as never) + render() +} + +async function row() { + return (await screen.findAllByTestId('conductor-mode-milestone'))[0] +} + +describe('Conductor mode Board: the discussing row', () => { + beforeEach(() => { + api.crewWorkers.mockResolvedValue({ root: 'root-1', workers: [] }) + api.sessionSummary.mockResolvedValue({ enabled: false, stale: false, intents: [], constraints: [], generated_at: null, user_turns: null, last_activity: null }) + }) + afterEach(() => vi.clearAllMocks()) + + it('shows Discussing with round, minutes and counts, and the panel behind a toggle', async () => { + api.crewBoard.mockResolvedValue({ ...BOARD, items: [ITEM({})] }) + renderPanel() + const r = await row() + expect(r).toHaveAttribute('data-state', 'discussing') + expect(within(r).getByTestId('conductor-mode-discussing')).toHaveTextContent('Discussing · Round 2 · 15') + expect(within(r).getByTestId('conductor-mode-talk-counts')).toHaveTextContent('Agreed 2 · Disputed 1 · Being checked 1') + const panel = within(r).getByTestId('conductor-mode-talk-panel') + expect(panel).not.toBeVisible() + const toggle = within(r).getByTestId('conductor-mode-talk-toggle') + expect(toggle).toHaveAttribute('aria-expanded', 'false') + fireEvent.click(toggle) + expect(toggle).toHaveAttribute('aria-expanded', 'true') + expect(toggle).toHaveTextContent('Hide the discussion') + expect(panel).toBeVisible() + for (const text of ['Direction', 'Card multiline first', 'Offline says so', 'Attach button', 'A: in the card · B: in the chat', 'Paste size cap', 'The card already has a box']) { + expect(panel).toHaveTextContent(text) + } + expect(within(panel).getByTestId('conductor-mode-talk-thread')).toHaveAttribute('href', '/chat/abc') + }) + + it('draws no thread link the board may not open', async () => { + api.crewBoard.mockResolvedValue({ ...BOARD, items: [ITEM({ discussion: { ...TALK, thread: 'javascript:alert(1)' } })] }) + renderPanel() + const r = await row() + expect(within(r).queryByTestId('conductor-mode-talk-thread')).toBeNull() + }) + + it('is gone once the item closes', async () => { + api.crewBoard.mockResolvedValue({ ...BOARD, items: [ITEM({ state: 'accepted', verdict: 'pass', terminal: true, alive: 'closed', status: 'done', closed_at: '2026-11-18T19:00:00Z' })] }) + renderPanel() + const r = await row() + expect(r).toHaveAttribute('data-state', 'done') + expect(within(r).queryByTestId('conductor-mode-talk')).toBeNull() + }) + + it('falls back to Quiet when its worker goes stale', async () => { + api.crewBoard.mockResolvedValue({ ...BOARD, items: [ITEM({ stale: true, alive: 'idle' })] }) + renderPanel() + const r = await row() + expect(r).toHaveAttribute('data-state', 'quiet') + expect(within(r).queryByTestId('conductor-mode-talk')).toBeNull() + }) +}) diff --git a/website/src/pages/chat/command-center/ConductorModeCrewPanel.test.ts b/website/src/pages/chat/command-center/ConductorModeCrewPanel.test.ts index 9c50711e49b7..73356f694661 100644 --- a/website/src/pages/chat/command-center/ConductorModeCrewPanel.test.ts +++ b/website/src/pages/chat/command-center/ConductorModeCrewPanel.test.ts @@ -206,6 +206,25 @@ describe('milestoneState', () => { expect(milestoneState(item({ status: 'question', outstanding: false, terminal: true, state: 'abandoned' }), false)).toBe('not_done') expect(milestoneState(item({ status: 'done', terminal: true, state: 'rejected' }), true)).toBe('not_done') }) + + it('discussing: an open item whose worker hosts a discussion and is still there', () => { + const talk = { status: 'progress' as const, discussion: { phase: 'talking' as const, round: 1 }, ...R } + expect(milestoneState(item({ ...talk, alive: 'running' }), false)).toBe('discussing') + expect(milestoneState(item({ ...talk, alive: 'idle' }), false)).toBe('discussing') + // The person comes first. + expect(milestoneState(item(talk), true)).toBe('needs_you') + }) + + it('discussing ends when the item closes, and a stalled host falls back to its plain state', () => { + const talk = { status: 'progress' as const, discussion: { phase: 'talking' as const, round: 3 }, ...R } + expect(milestoneState(item({ ...talk, state: 'accepted', terminal: true, alive: 'closed' }), false)).toBe('done') + expect(milestoneState(item({ ...talk, state: 'abandoned', terminal: true }), false)).toBe('not_done') + expect(milestoneState(item({ ...talk, stale: true }), false)).toBe('quiet') + expect(milestoneState(item({ ...talk, alive: 'closed' }), false)).toBe('stuck') + expect(milestoneState(item({ ...talk, orphaned: true }), false)).toBe('stuck') + // No phase is no discussion. + expect(milestoneState(item({ ...talk, discussion: { phase: '' } as never }), false)).toBe('waiting') + }) }) describe('personAsks', () => { diff --git a/website/src/pages/chat/command-center/ConductorModeCrewPanel.tsx b/website/src/pages/chat/command-center/ConductorModeCrewPanel.tsx index e1744bf6161a..c1d70c253ce7 100644 --- a/website/src/pages/chat/command-center/ConductorModeCrewPanel.tsx +++ b/website/src/pages/chat/command-center/ConductorModeCrewPanel.tsx @@ -16,7 +16,7 @@ import { api } from '../../../api/client' import type { CrewWorker, ConductorModeRun } from '../../../types' import type { SessionSummary } from '../../../types/sessionSummary' import { timedPoll, usePollRule } from '../../../lib/pollRule' -import { crewBoardQueryKey, CREW_BOARD_GC_MS, CREW_BOARD_POLL_MS, type WorkBoardItem, type WorkBoardResponse } from '../../../api/crewBoard' +import { crewBoardQueryKey, CREW_BOARD_GC_MS, CREW_BOARD_POLL_MS, type WorkBoardItem, type WorkBoardResponse, type WorkDiscussion } from '../../../api/crewBoard' import { artifactEntries } from '../../crewBoardRows' import { fmtList, fmtRelative } from '../../../i18n/format' import { fmtMinutes } from '../../../lib/crewWork' @@ -271,7 +271,7 @@ export function latestChange(text: string): { text: string; stamp: string; at: n return { text: entry, stamp: s ? s[0] : '', at: Number.isFinite(at) ? at : null } } -type MilestoneState = 'done' | 'not_done' | 'needs_you' | 'running' | 'waiting' | 'quiet' | 'stuck' | 'next' +type MilestoneState = 'done' | 'not_done' | 'needs_you' | 'discussing' | 'running' | 'waiting' | 'quiet' | 'stuck' | 'next' /** A report a worker said only a person can move (`reason` approval / needs_human). */ const PERSON_REASONS = new Set(['approval', 'needs_human']) @@ -314,6 +314,9 @@ export function milestoneState(item: WorkBoardItem, waiting: boolean): Milestone // `awaits_person`, and its `alive` running was the model turn. const asksPerson = item.awaits_person ?? ((item.status === 'blocked' || item.status === 'question') && PERSON_REASONS.has(item.reason || '') && !reportAnswered(item) && item.alive !== 'running') if (waiting || asksPerson) return 'needs_you' + // A discussion its worker hosts, while that worker is still there and not + // quiet (the goal-board template's rule); a stalled host falls through below. + if (discussionOf(item) && item.alive !== 'closed' && !item.orphaned && !item.stale) return 'discussing' if (item.alive === 'running') return 'running' // Stuck only when nothing is left to move it: its session closed on an open // report, or the board is orphaned (no main chat reads its reports). A done @@ -340,6 +343,16 @@ function onConductor(item: WorkBoardItem): boolean { return (item.status === 'blocked' || item.status === 'question') && !reportAnswered(item) } +/** The discussion an open item's worker hosts, or null: the one its last + * report carried, which the next report replaces. */ +export function discussionOf(item: WorkBoardItem): WorkDiscussion | null { + const d = item.discussion + return item.state === 'open' && d && typeof d === 'object' && typeof d.phase === 'string' && d.phase ? d : null +} + +/** A thread link the board may draw: the server's own LINKABLE rule. */ +const THREAD_LINK = /^(?:https?:\/\/|\/(?:artifacts|chat|schedule|capabilities|settings)\b)/ + function minutesBetween(a: string | null | undefined, b: string | number | null | undefined): number { const ta = a ? Date.parse(a) : NaN const tb = typeof b === 'number' ? b : b ? Date.parse(b) : NaN @@ -353,6 +366,7 @@ const STATE_ICON: Record = { not_done: , needs_you: , running: , + discussing: , waiting: , // Quiet and stuck are the conductor's to pick up, so they are muted: only // needs_you takes the warm colour. @@ -366,7 +380,16 @@ const WRAP = 'min-w-0 [overflow-wrap:anywhere]' function MilestoneRow({ item, state, waitingOn, now, onOpen }: { item: WorkBoardItem; state: MilestoneState; waitingOn: string; now: number; onOpen?: () => void }) { let sub: JSX.Element | string = '' - if (state === 'done') { + const talk = state === 'discussing' ? discussionOf(item) : null + if (talk) { + const mins = Number(talk.minutes) || 0 + const text = [ + i18nT('components.crewMode.conductor_mode_ms_discussing'), + i18nT('components.crewMode.conductor_mode_ms_discussing_round', { round: Number(talk.round) || 0 }), + ...(mins > 0 ? [fmtMinutes(mins)] : []), + ].join(' · ') + sub = {text} + } else if (state === 'done') { const link = artifactEntries(item).find(([, v]) => /^https?:\/\//.test(v)) sub = <> {firstSentence(item.summary)} @@ -421,18 +444,65 @@ function MilestoneRow({ item, state, waitingOn, now, onOpen }: { item: WorkBoard return (
  • {STATE_ICON[state]} - +
    {/* A milestone with a crew member opens it, so a blocked one is one click from where it is decided. */} {onOpen ? : {item.title}} {sub} - + {talk && } +
    {right}
  • ) } +/** One titled list in the discussion panel. A row is text, or [bold, rest]. */ +function TalkSection({ label, rows }: { label: string; rows: (string | [string, string])[] }) { + const shown = rows.filter(r => (Array.isArray(r) ? r[0] || r[1] : r)) + if (!shown.length) return null + return ( +
    +
    {label}
    +
      + {shown.map((r, n) =>
    • {Array.isArray(r) + ? <>{r[0] && {r[0]}}{r[0] && r[1] ? ': ' : ''}{r[1]} + : r}
    • )} +
    +
    + ) +} + +/** The discussing row's counts and, behind a toggle, what the discussion holds: + * direction, agreed, disputed with each side, being checked, the latest lines and + * the thread link. A question for the person is the Needs your input card's, not this. */ +function DiscussionDetail({ id, d }: { id: string; d: WorkDiscussion }) { + const [open, setOpen] = useState(false) + const list = (v: T[] | undefined): T[] => (Array.isArray(v) ? v : []) + const agreed = list(d.agreed).filter(x => typeof x === 'string') + const checking = list(d.checking).filter(x => typeof x === 'string') + const disputed = list(d.disputed).filter(x => x && typeof x === 'object') + const recent = list(d.recent).filter(x => x && typeof x === 'object') + const thread = typeof d.thread === 'string' && d.thread.length <= 2048 && THREAD_LINK.test(d.thread) ? d.thread : '' + const panelId = `conductor-mode-talk-${id.replace(/[^A-Za-z0-9_-]/g, '_')}` + return ( +
    +
    {i18nT('components.crewMode.conductor_mode_talk_counts', { agreed: agreed.length, disputed: disputed.length, checking: checking.length })}
    + + +
    + ) +} + const RUN_ICON: Record = { paused: