Python
feat(#611): option to hide the live reasoning stream while a task runs
cyurekli99ce7ac0021a
diff --git a/coworker/server/app.py b/coworker/server/app.pyindex f1ed9348..67bc1765 100644--- a/coworker/server/app.py+++ b/coworker/server/app.py@@ -2490,6 +2490,11 @@ def create_app(manager: SessionManager) -> FastAPI:# Composer: show the context-window fill bar, or just the popover (owner ask).return manager.set_context_bar((body or {}).get("context_bar", True))+ @app.post("/v1/settings/hide-reasoning")+ def settings_set_hide_reasoning(body: dict) -> dict[str, Any]:+ # #611: collapse the live reasoning stream to a quiet indicator while a turn runs.+ return manager.set_hide_reasoning_running((body or {}).get("hide_reasoning_running", False))+@app.post("/v1/settings/auto-approve")def settings_set_auto_approve(body: dict) -> dict[str, Any]:# Auto-Approve feature flag (spec §1.5): when on, Mode.AUTO_APPROVE gets an LLMdiff --git a/coworker/server/manager.py b/coworker/server/manager.pyindex dff56a1c..6f1bd1cc 100644--- a/coworker/server/manager.py+++ b/coworker/server/manager.py@@ -4772,6 +4772,9 @@ class SessionManager:"nav_layout": self._nav_layout(),"sessions_peek": self.sessions_peek(),"context_bar": self.context_bar(),+ # #611: collapse/hide the live thinking stream while a turn runs (OFF by default so+ # existing users keep seeing it; the finalized reasoning still shows after the turn).+ "hide_reasoning_running": self.hide_reasoning_running(),# Auto-Approve feature flag + its shadow-eval sibling (spec §1.5). Drive the# Settings toggles and gate the composer's Auto-Approve mode entry."auto_approve": self.auto_approve(),@@ -4849,6 +4852,19 @@ class SessionManager:self._save_prefs()return {"ok": True, "context_bar": self.context_bar()}+ # -- Hide live reasoning while running (#611) ---------------------------------------+ # The GUI streams the model's reasoning live during a turn; at full write speed it's a+ # wall of fast-moving text. This pref collapses that live stream to a quiet one-line+ # indicator (the finalized reasoning still appears after the turn). OFF by default.++ def hide_reasoning_running(self) -> bool:+ return bool(self._prefs.get("hide_reasoning_running", False))++ def set_hide_reasoning_running(self, hidden: Any) -> dict[str, Any]:+ self._prefs["hide_reasoning_running"] = bool(hidden)+ self._save_prefs()+ return {"ok": True, "hide_reasoning_running": self.hide_reasoning_running()}+# -- Auto-Approve (spec §1.5, Part 6 step 3) --------------------------------# The feature flag and its shadow-eval sibling live in prefs (GUI-writable), falling# back to the config.toml value a power user may have hand-set. Prefs is user-global,diff --git a/surfaces/gui/e2e/fixtures.ts b/surfaces/gui/e2e/fixtures.tsindex e7fb1b1f..75218c97 100644--- a/surfaces/gui/e2e/fixtures.ts+++ b/surfaces/gui/e2e/fixtures.ts@@ -49,6 +49,8 @@ const SETTINGS = {scratch_base: "~/OpenWorker",secrets_path: "/Users/test/.config/coworker/secrets.json",sessions_peek: 5,+ // #611: live reasoning is collapsed to a quiet "Thinking…" line while a turn runs.+ hide_reasoning_running: false,// Token savings (PDF attachments): 2-page limit keeps the composer threshold test's// fixture PDF small; the real default is 20.pdf_fallback: "text",@@ -1464,6 +1466,10 @@ export async function mockApi(page: import("@playwright/test").Page) {Object.assign(SETTINGS, req.postDataJSON());return json({ ok: true, context_bar: SETTINGS.context_bar });}+ if (p.endsWith("/v1/settings/hide-reasoning") && m === "POST") {+ Object.assign(SETTINGS, req.postDataJSON());+ return json({ ok: true, hide_reasoning_running: SETTINGS.hide_reasoning_running });+ }if (p.endsWith("/v1/settings/pdf") && m === "POST") {Object.assign(SETTINGS, req.postDataJSON());return json({diff --git a/surfaces/gui/e2e/hide-reasoning.spec.ts b/surfaces/gui/e2e/hide-reasoning.spec.tsnew file mode 100644index 00000000..33506e18--- /dev/null+++ b/surfaces/gui/e2e/hide-reasoning.spec.ts@@ -0,0 +1,56 @@+// #611 — "Hide thinking while running": a persisted Composer setting that collapses the+// fast-scrolling live reasoning trace to a quiet one-line "Thinking…" indicator while a+// turn runs, WITHOUT hiding the fact that work is ongoing. The finalized reasoning still+// appears in the assistant item's "Thought process" disclosure after the turn.+import { expect } from "@playwright/test";+import { test } from "./fixtures";++async function startThinkingTurn(page: import("@playwright/test").Page) {+ await page.goto("/");+ await page.getByText("Draft the launch note").first().click();+ const box = page.getByPlaceholder(/Ask the coworker/);+ await box.fill("think hard about this");+ await box.press("Enter");+}++test("hide-reasoning: default shows the live thinking block", async ({ page }) => {+ await startThinkingTurn(page);++ // OFF by default: the live ThinkingBlock streams the trace (existing behavior).+ await expect(page.getByText("Thinking…").first()).toBeVisible({ timeout: 10_000 });+ await expect(page.getByTestId("thinking-toggle")).toBeVisible();+ await page.getByTestId("thinking-toggle").click();+ await expect(page.getByTestId("thinking-body")).toContainText("Weighing options.");+});++test("hide-reasoning: collapses live thinking but keeps an ongoing-work indicator", async ({+ page,+}) => {+ // Enable the setting in Settings → Composer (General tab is the default open tab).+ await page.goto("/");+ await page.getByTestId("account-row").click();+ await page.getByRole("button", { name: "Settings", exact: true }).click();+ const togg = page.getByTestId("hide-reasoning-toggle");+ await expect(togg).toBeVisible();+ await togg.check();+ await expect(togg).toBeChecked();++ // Run a reasoning turn: the live ThinkingBlock must be suppressed…+ await startThinkingTurn(page);+ await expect(page.getByText("Thinking…").first()).toBeVisible({ timeout: 10_000 });+ await expect(page.getByTestId("thinking-toggle")).toHaveCount(0);++ // …but the user still sees that work is ongoing (the quiet indicator, not raw text).+ // No streaming trace is shown while hidden.+ await expect(page.getByTestId("thinking-body")).toHaveCount(0);++ // The finalized reasoning still lands after the turn — nothing was lost.+ await expect(page.getByText("Decision made.").first()).toBeVisible({ timeout: 10_000 });+ await expect(page.getByText("Thinking…")).toHaveCount(0);+ const disc = page.getByTestId("thinking-toggle");+ await expect(disc).toHaveText(/Thought process/);+ await disc.click();+ await expect(page.getByTestId("thinking-body")).toContainText(+ "Weighing options. Comparing tradeoffs. Settling it.",+ );+});diff --git a/surfaces/gui/src/App.tsx b/surfaces/gui/src/App.tsxindex 004f0559..2fe6980f 100644--- a/surfaces/gui/src/App.tsx+++ b/surfaces/gui/src/App.tsx@@ -248,6 +248,9 @@ export function App() {// Settings: show the composer's context-window fill bar. OFF by default (owner ask),// so an older backend without the field also shows the session total.const [contextBar, setContextBar] = useState(false);+ // #611: when on, the live reasoning stream is collapsed to a quiet indicator while a+ // turn runs; the finalized reasoning still appears after. Loaded from Settings.+ const [hideReasoningRunning, setHideReasoningRunning] = useState(false);// Per-session token usage (OPE-42): rebuilt from the transcript on session load,// accumulated live from assistant_message events, reset with the transcript.const [usage, setUsage] = useState<SessionUsage>(emptyUsage());@@ -792,6 +795,7 @@ export function App() {setModelConfig(s.model_config || {});setModelContextWindows(s.model_context_windows || {});setContextBar(s.context_bar === true);+ setHideReasoningRunning(s.hide_reasoning_running === true);setModelReady(s.model_ready);if (s.surfaces) setSurfaces(s.surfaces);})@@ -2320,10 +2324,19 @@ export function App() {{/* Live thinking (reasoning models): a quiet collapsed block that streams thetrace for anyone who expands it; folds into the answer's disclosure whenthe message finalizes. */}- {running && reasoningStream && !streaming && (- <div className="transcript">- <ThinkingBlock text={reasoningStream} live />- </div>+ {running &&+ reasoningStream &&+ !streaming &&+ !hideReasoningRunning && (+ <div className="transcript">+ <ThinkingBlock text={reasoningStream} live />+ </div>+ )}+ {/* #611: "Hide thinking while running" collapses the fast-scrolling live trace+ to a quiet one-line indicator — the finalized reasoning still appears in the+ assistant item after the turn, so no signal is lost. */}+ {running && reasoningStream && !streaming && hideReasoningRunning && (+ <WaitingForAgent label={t("app.thinking_hidden")} />)}{/* OPE-206: the sandbox for this session is being built (a container, itsrunner, its mounts). Not a turn, so `running` is false; the row says so. */}diff --git a/surfaces/gui/src/api.ts b/surfaces/gui/src/api.tsindex 730d1ca5..115c2a87 100644--- a/surfaces/gui/src/api.ts+++ b/surfaces/gui/src/api.ts@@ -1193,6 +1193,9 @@ export interface ModelSettings {// Composer: show the context-window fill bar (default FALSE; absent → the chip shows// the session total). The usage popover keeps both numbers regardless.context_bar?: boolean;+ // #611: collapse the live reasoning stream while a turn runs (default FALSE). When on,+ // the reasoning is hidden during the run, but its finalized form still appears after.+ hide_reasoning_running?: boolean;// Auto-Approve mode (spec §1.5): the feature flag that offers the reviewer mode, and its// shadow-eval sibling. Both default FALSE and are absent on older backends — the composer// hides the Auto-Approve mode entry unless auto_approve is explicitly true.@@ -1280,6 +1283,18 @@ export async function setContextBar(return res.json();}+/** #611: persist whether the composer suppresses the live reasoning stream while a turn runs. */+export async function setHideReasoningRunning(+ hidden: boolean,+): Promise<{ ok: boolean; hide_reasoning_running?: boolean; error?: string }> {+ const res = await fetch(`${httpBase()}/v1/settings/hide-reasoning`, {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ hide_reasoning_running: hidden }),+ });+ return res.json();+}+type AutoApproveResult = {ok: boolean;auto_approve?: boolean;diff --git a/surfaces/gui/src/components/SettingsView.tsx b/surfaces/gui/src/components/SettingsView.tsxindex 8df66736..b79e077f 100644--- a/surfaces/gui/src/components/SettingsView.tsx+++ b/surfaces/gui/src/components/SettingsView.tsx@@ -25,6 +25,7 @@ import {setAutoApproveShadow,setCompactionSettings,setContextBar,+ setHideReasoningRunning,setOnboarded,setPdfSettings,setScratchBase,@@ -949,6 +950,8 @@ function AppearanceSection() {<ContextBarCard />+ <HideReasoningCard />+<AutoApproveCard /><FilesCard />@@ -1350,6 +1353,45 @@ function ContextBarCard() {);}+// #611: collapse the live reasoning stream to a quiet "Thinking…" indicator while a+// turn runs. Mirror of ContextBarCard: a persisted, user-global checkbox in Composer+// settings. The finalized reasoning still appears after the turn, so nothing is lost.+function HideReasoningCard() {+ const { t } = useTranslation();+ const [hidden, setHidden] = useState<boolean | null>(null);++ useEffect(() => {+ getSettings()+ .then((s) => setHidden(s.hide_reasoning_running === true))+ .catch(() => setHidden(false));+ }, []);++ const save = async (next: boolean) => {+ setHidden(next);+ await setHideReasoningRunning(next);+ };++ if (hidden === null) return null;+ return (+ <div className={CARD + " p-4 mb-4"} data-testid="hide-reasoning-card">+ <div className={FIELD_LABEL}>{t("settings.composer_section")}</div>+ <label className="flex items-start gap-3 py-2">+ <input+ type="checkbox"+ className="mt-0.5"+ data-testid="hide-reasoning-toggle"+ checked={hidden}+ onChange={(e) => save(e.target.checked)}+ />+ <span>+ <span className="block text-[13px] text-ink">{t("settings.hide_reasoning_title")}</span>+ <span className="block text-[12px] text-muted">{t("settings.hide_reasoning_desc")}</span>+ </span>+ </label>+ </div>+ );+}+// Auto-Approve (spec §1.5): the experimental feature flag that adds the "Auto-Approve" mode// to the composer's mode picker, plus its shadow-evaluation sibling. Both default off and are// user-global (a cloned repo can't turn either on). Shadow is nested under the main flag — itdiff --git a/surfaces/gui/src/locales/en.json b/surfaces/gui/src/locales/en.jsonindex 56a2caa4..a8aadc8c 100644--- a/surfaces/gui/src/locales/en.json+++ b/surfaces/gui/src/locales/en.json@@ -462,7 +462,9 @@"personas_desc": "Coworkers are agents specialized for a particular role or task. They come equipped with the tools and skills to be successful in that role. Enabling a coworker lets you pick it when starting a conversation.","composer_section": "Composer","context_bar_title": "Show the context ring on the model pill",- "context_bar_desc": "A small ring showing how full the model’s context window is. The pill’s tooltip states the figures either way."+ "context_bar_desc": "A small ring showing how full the model’s context window is. The pill’s tooltip states the figures either way.",+ "hide_reasoning_title": "Hide thinking while I work",+ "hide_reasoning_desc": "Collapse the fast-scrolling reasoning trace to a quiet “Thinking…” line while a turn runs. The full reasoning still appears after the turn finishes."},"cloud": {"check_browser": "Check your browser…",@@ -521,7 +523,8 @@"talk_anytime": "Talk to it anytime.","ask_status": "Ask for a status","status_prompt": "Quick status check, please — what's moving, what's blocked, and does anything need me?"- }+ },+ "thinking_hidden": "Thinking…"},"run_banner": {"scheduled_run": "Scheduled run",diff --git a/surfaces/gui/src/locales/zh.json b/surfaces/gui/src/locales/zh.jsonindex 4c932360..fd759352 100644--- a/surfaces/gui/src/locales/zh.json+++ b/surfaces/gui/src/locales/zh.json@@ -454,7 +454,9 @@"personas_desc": "同事是专精于特定角色或任务的 agent,自带胜任该角色所需的工具与技能。启用同事后,即可在开始会话时选择它。","composer_section": "输入框","context_bar_title": "在模型标签上显示上下文占用环",- "context_bar_desc": "一个小圆环,显示模型上下文窗口的占用程度。无论开关,标签的悬停提示都会给出具体数字。"+ "context_bar_desc": "一个小圆环,显示模型上下文窗口的占用程度。无论开关,标签的悬停提示都会给出具体数字。",+ "hide_reasoning_title": "工作时隐藏思考过程",+ "hide_reasoning_desc": "任务运行期间,将快速滚动的思考文本折叠成一行安静的“思考中…”提示。完整思考内容仍会在任务结束后显示。"},"cloud": {"check_browser": "请查看你的浏览器…",@@ -513,7 +515,8 @@"talk_anytime": "随时可以和它对话。","ask_status": "询问状态","status_prompt": "请快速汇报一下状态 —— 哪些在推进、哪些被卡住、有没有需要我处理的?"- }+ },+ "thinking_hidden": "思考中…"},"run_banner": {"scheduled_run": "定时任务",