From cfd747d8bf13e251637cb1184886c3e0a918a40a Mon Sep 17 00:00:00 2001 From: Roman Sirokov Date: Tue, 1 Dec 2026 22:59:27 +0100 Subject: [PATCH 1/2] feat: adopt Huggler title generation and bounded conversation reads --- docs/desktop-coding.md | 2 + scripts/check-desktop-history.py | 9 ++- scripts/check-desktop-settings.py | 23 ++++++ src/conversation.rs | 66 +++++++++++++--- src/conversation/backlog.rs | 3 + src/conversation/launch_workspace.rs | 46 +++++++++++ src/conversation/queue.rs | 110 ++++++++++++--------------- tests/fixtures/context-provider.py | 12 ++- 8 files changed, 194 insertions(+), 77 deletions(-) diff --git a/docs/desktop-coding.md b/docs/desktop-coding.md index 8fdb763..5e28a87 100644 --- a/docs/desktop-coding.md +++ b/docs/desktop-coding.md @@ -30,6 +30,8 @@ Use unique instance IDs. A JSON entry with the same ID as one of the eight prese **New worktree** starts a linked worktree from the repository's default branch. Bear uses the cached remote default when available, then looks for `main`, `master`, the checked-out commit, or another available branch. Open **From …** to search local and remote-tracking branches for a different base. Choose **Current checkout** to use the selected folder. Pick a local branch to switch to it when the conversation opens. If Git detects a conflict with local files, the draft stays open so you can change your selection. Repositories without a starting commit use the current checkout. Type your task and use the send shortcut or click the up arrow. Bear derives a short title from the first message. For example, “Please fix the parser.” becomes **Fix the parser**. A single-repository worktree uses a branch such as `huggler/fix-the-parser` and a checkout folder beginning with `fix-the-parser-`. If the branch name is taken, Bear tries a numbered suffix. The setup view shows the base selection, checkout creation, and conversation opening. Use the model picker at the lower left of the composer to choose a provider and model. **Bear → Create with Setup…** (⌘⇧N) lets you set the conversation title and, for a single-repository worktree, the exact branch name. + + Set `BEAR_GENERATE_TITLES=1` before starting Bear to enable generated titles for new local Codex conversations with a first message and an automatic title. Bear opens the conversation immediately using the short title it derived locally. In the background, a separate Codex turn uses the first message, project name, and any attachment names to suggest a title. If Codex cannot suggest one, Bear keeps the local title. A title you enter yourself takes precedence. The branch name is set during checkout, before the suggestion arrives. 2. **Send a message.** Press **Enter** to send by default. Use **Shift+Enter** to add a line and **⌘L** to focus the message field. Change the send shortcut under **Settings → General**. In either composer, click **+** or drop files into the composer to attach up to eight files totaling 50 MiB, including up to 20 MiB of images. Click a draft filename to remove it before sending. In history, expand a filename to preview text, images, or extracted PDF text when available. Use **Save as…** to save the original file. You can send files on their own or queue them with a follow-up. The provider receives the filenames and the contents or local file paths supported by that provider. The built-in Codex instance can edit the checkout during implementation. You can change **Model** beside **Message** before sending or queuing your next turn. Bear remembers the selection for this conversation. Read the streaming reply, open command output and respond to questions or permission requests in **Conversation**. 3. **Manage ongoing work.** While the agent works, the send shortcut queues your follow-up by default. Select **Steer** under **Settings → General** to send a text follow-up into a Codex turn that can accept it. **Stop thread** interrupts the current work and pauses queued messages. Use **Resume queue** to deliver them. Choose **Show conversations** in the header to switch to another task. A partially typed answer stays with its question while the app is open. Reopening the app restores the selected conversation and its history. 4. **Review changed files.** The **Changes** tab in the right sidebar defaults to **All changes**, which compares the selected checkout with the branch’s merge base. For a multi-repo workspace, rows include the repository folder and each diff uses its own Git checkout. **All changes** compares each worktree with its starting commit. Choose **Uncommitted files** for staged, unstaged, and untracked files. The line totals follow the selection. Hover over the file name to see its full path. Use the row’s chevron to open **Open in**. Finder reveals the file, Terminal opens its folder, and VS Code opens the file. For deleted files the menu opens the nearest existing folder. Hover over a row with eligible uncommitted edits to show **Revert file**. Confirming a revert restores the path to its state at the current commit and removes files added since then. Resolve conflicts and submodule changes in Git. The list refreshes when you open the sidebar, select a conversation, finish a turn, or revert a file. diff --git a/scripts/check-desktop-history.py b/scripts/check-desktop-history.py index 1570128..591a8e0 100644 --- a/scripts/check-desktop-history.py +++ b/scripts/check-desktop-history.py @@ -110,12 +110,17 @@ def main(): (str(i), thread, i + 1)) db.execute("INSERT INTO message(id,run_id,role,text) VALUES(?,?,'assistant',?)", (str(i), str(i), long_message if i == 998 else f"Answer {i}")) - db.execute("UPDATE run SET status='failed', error=? WHERE id='999'", + db.execute("UPDATE run SET status='failed', error=?, ordinal=1002 WHERE id='999'", ("Provider could not finish this turn.",)) + db.execute("INSERT INTO run(id,thread_id,status,ordinal) VALUES('canceled',?,'interrupted',1001)", + (thread,)) + db.execute("INSERT INTO message(id,run_id,role,text) VALUES('canceled','canceled','user',?)", + ("Canceled before delivery",)) error_response = "error/Provider could not finish this turn." steps = [ {"see": error_response}, - {"see": "Codex/Answer 999"}, {"absent": "Codex/Answer 967"}, {"see": "active-turn/32"}, + {"see": "Codex/Answer 999"}, {"absent": "You/Canceled before delivery"}, + {"see": "Codex/Answer 968"}, {"absent": "Codex/Answer 967"}, {"see": "active-turn/32"}, {"click": "Older"}, {"see": "Codex/Answer 967"}, {"absent": "Codex/Answer 999"}, {"absent": error_response}, {"see": "active-turn/1"}, {"see": "Newest"}, {"click": "Scroll to end"}, diff --git a/scripts/check-desktop-settings.py b/scripts/check-desktop-settings.py index 330fd0d..caa02cc 100644 --- a/scripts/check-desktop-settings.py +++ b/scripts/check-desktop-settings.py @@ -76,6 +76,28 @@ def check_general(executable, state, env): ], env) +def check_generated_titles(executable, state, env): + env = dict(env, BEAR_GENERATE_TITLES="1", + HUGGLER_CODEX=str(ROOT / "tests/fixtures/context-provider.py")) + run_window(executable, state, [ + {"resize": [1120, 740]}, + {"click": "First message"}, {"type": "Please investigate why the upload stalls."}, + {"click": "Send first message"}, {"see": "thread/Upload stall investigation"}, + {"contains": "Codex/reply"}, + {"key": "cmd-n"}, {"click": "First message"}, {"type": "Keep my chosen conversation title."}, + {"key": "cmd-shift-n"}, {"click": "Conversation name"}, {"type": "My title"}, + {"click": "Send first message"}, {"see": "thread/My title"}, {"contains": "Codex/reply"}, + ], env) + with sqlite3.connect(state / "huggler.sqlite3") as db: + assert db.execute("SELECT name FROM thread ORDER BY rowid").fetchall() == [ + ("Upload stall investigation",), ("My title",), + ] + frames = (json.loads(line) for log in state.rglob("frames.ndjson") + for line in log.read_text().splitlines()) + assert sum((frame.get("params", {}).get("outputSchema") or {}).get("required") == ["title"] + for frame in frames) == 1 + + def check_worktrees(executable, state, env): run_window(executable, state, [ {"resize": [640, 440]}, {"key": "cmd-,"}, {"center_x": ["Appearance", 320]}, @@ -478,6 +500,7 @@ def check(executable): exclude.write("\n/frames.ndjson\n") env = dict(isolated_env(root), HUGGLER_CLAUDE_ACP=str(root / "missing-claude-agent")) check_general(executable, root / "general", env) + check_generated_titles(executable, root / "generated-titles", env) check_worktrees(executable, root / "worktrees", env) check_projects(executable, root / "projects", env) check_provider_setup(executable, root, env) diff --git a/src/conversation.rs b/src/conversation.rs index 7d837f4..55313aa 100644 --- a/src/conversation.rs +++ b/src/conversation.rs @@ -63,7 +63,7 @@ use huggler::{ use std::{ collections::{HashMap, HashSet}, fs, - path::PathBuf, + path::{Path, PathBuf}, sync::Arc, }; use uuid::Uuid; @@ -1012,7 +1012,8 @@ impl Desktop { let message = self.starter.read(cx).value().to_string(); let name = self.name.read(cx).value(); let name = name.trim(); - let name = if name.is_empty() { + let derive_title = name.is_empty(); + let name = if derive_title { self.starter_attachments.title(&message) } else { name.to_owned() @@ -1033,6 +1034,7 @@ impl Desktop { let (model, options) = self.launch_model_selection(cx); LaunchDraft { name, + derive_title, message, project_name: self.launch_project_name(cx), checkout, @@ -1079,6 +1081,8 @@ impl Desktop { ) { let LaunchDraft { name, + derive_title, + project_name, message, checkout, checkout_root, @@ -1089,7 +1093,6 @@ impl Desktop { model, model_options, instance, - .. } = draft; let saved_roots: HashSet<_> = self .settings @@ -1130,22 +1133,64 @@ impl Desktop { } let launch_name = name.clone(); let (report_stage, mut stages) = tokio::sync::mpsc::unbounded_channel(); + let title_provider = (derive_title + && std::env::var("BEAR_GENERATE_TITLES").as_deref() == Ok("1")) + .then(|| { + runtime + .provider_instances() + .find(|provider| provider.id == instance && provider.driver == Provider::Codex) + .cloned() + }) + .flatten(); + let executor = self.executor.clone(); let launch = cx.background_spawn(async move { - let send = || match first_message { - Some(action) => runtime.dispatch(Command { + let generate_title = title_provider.is_some(); + let send = |checkout: Option<&Path>| -> huggler::Result<()> { + let Some(action) = first_message else { + return Ok(()); + }; + let title_job = title_provider.zip(checkout).and_then(|(provider, checkout)| { + let expected = runtime.thread_title(&thread).ok()?; + if expected.as_str() != name { + return None; + } + let context = launch_workspace::title_context(&action)?; + Some((provider, checkout.to_owned(), expected, context)) + }); + runtime.dispatch(Command { id: CommandId(saved_draft.map_or_else( || Uuid::new_v4().to_string(), |id| format!("backlog-send-{id}"), )), thread_id: thread.clone(), action, - }).map(|_| ()), - None => Ok(()), + })?; + if let Some((provider, checkout, expected, context)) = title_job { + let runtime = runtime.clone(); + executor.spawn(async move { + launch_workspace::generate_title( + &runtime, provider, checkout, expected, context, project_name, + ) + .await; + }); + } + Ok(()) }; // Launch and enqueue commit separately. A retry uses the existing // conversation and the same enqueue ID, even after an app restart. if saved_draft.is_some() && backlog::has_draft_conversation(&runtime, &thread)? { - return Ok((send(), None, None)); + // A previously accepted enqueue can replay its receipt. Only + // generate here if the first enqueue never created a run. + let checkout = if generate_title + && runtime + .detail(&thread, None, "", 1) + .is_ok_and(|detail| detail.latest_run.is_none()) + { + runtime.thread_checkout(&thread).ok() + } else { + None + }; + return Ok((send(checkout.as_deref()), None, None)); } if saved_draft.is_some() && workspace_mode == WorkspaceMode::Worktree { let _ = report_stage.send(Some(WorktreeStage::ResolveBase)); @@ -1183,7 +1228,7 @@ impl Desktop { return Err(workspace.cleanup(error.into())); } return Ok(( - send(), + send(Some(&workspace.project.root)), Some((workspace.project.root, primary.clone())), None, )); @@ -1239,6 +1284,7 @@ impl Desktop { error }); } + let sent = send(Some(&project.root)); // A saved linked checkout can define its own actions. Git only reports // the repository's main checkout from the newly allocated worktree. let worktree_project = (allocated @@ -1246,7 +1292,7 @@ impl Desktop { && git::main_worktree(&project.root).is_ok_and(|main| main != source_root)) .then_some((project.root, source_root)); let history_error = setup_record.and_then(Result::err); - anyhow::Ok((send(), worktree_project, history_error)) + anyhow::Ok((sent, worktree_project, history_error)) }); cx.spawn_in(window, async move |view, cx| { while let Some(stage) = stages.recv().await { diff --git a/src/conversation/backlog.rs b/src/conversation/backlog.rs index d716e09..3d25cfa 100644 --- a/src/conversation/backlog.rs +++ b/src/conversation/backlog.rs @@ -12,6 +12,8 @@ use std::{ #[derive(Serialize, Deserialize)] pub(super) struct LaunchDraft { pub name: String, + #[serde(default)] + pub derive_title: bool, pub message: String, pub checkout: PathBuf, #[serde(default)] @@ -397,6 +399,7 @@ impl Desktop { !message.trim().is_empty() || !attachments.is_empty(&message), "Add a message or keep an attachment" ); + launch.derive_title = name.is_empty() || (launch.derive_title && name == launch.name); launch.name = if name.is_empty() { attachments.title(&message) } else { diff --git a/src/conversation/launch_workspace.rs b/src/conversation/launch_workspace.rs index 45bcbfe..b325e09 100644 --- a/src/conversation/launch_workspace.rs +++ b/src/conversation/launch_workspace.rs @@ -151,6 +151,52 @@ pub(super) fn worktree_setup(current: WorktreeStage, title: Option<&str>, cx: &A })) } +pub(super) fn title_context(action: &Action) -> Option { + match action { + Action::Enqueue { text } => Some(text.clone()), + Action::EnqueueFiles { text, files } => { + let names = files + .iter() + .map(|file| file.name.as_str()) + .collect::>(); + Some(format!("{text}\n\nAttachments: {}", names.join(", "))) + } + _ => None, + } +} + +pub(super) async fn generate_title( + runtime: &Huggler, + provider: huggler::ProviderInstance, + checkout: PathBuf, + expected: huggler::ThreadTitle, + context: String, + project_name: Option, +) { + let request = huggler::ConversationTitleRequest { + context: &context, + project_title: project_name.as_deref(), + ..Default::default() + }; + let result = huggler::providers::codex::generate_conversation_title( + &provider, + runtime.output(), + &checkout, + None, + request, + ) + .await + .and_then(|title| { + if let Some(title) = title { + runtime.set_thread_title_if_current(&expected, &title)?; + } + Ok(()) + }); + if let Err(error) = result { + eprintln!("Could not generate conversation title: {error}"); + } +} + pub(super) fn conversation_title(message: &str, attachment: Option<&str>) -> String { fn append_inline_text(node: &Node, text: &mut String) { match node { diff --git a/src/conversation/queue.rs b/src/conversation/queue.rs index 8351949..7abd03d 100644 --- a/src/conversation/queue.rs +++ b/src/conversation/queue.rs @@ -1,5 +1,5 @@ use super::*; -use huggler::{MessageId, Role, RunStatus}; +use huggler::{MessageId, RunActivity, RunStatus}; #[derive(Default)] pub(super) struct MessageQueue { @@ -31,15 +31,16 @@ struct QueueDrag { impl MessageQueue { pub(super) fn hides_run(&self, detail: &ConversationDetail, run: &RunId) -> bool { - Self::hidden(&self.messages, detail, run) + Self::hidden(&self.messages, &detail.activity, run) } - fn hidden(queued: &[QueuedMessage], detail: &ConversationDetail, run: &RunId) -> bool { + fn hidden(queued: &[QueuedMessage], activity: &[RunActivity], run: &RunId) -> bool { queued.iter().any(|message| &message.run == run) - || detail.activity.iter().any(|activity| { + || activity.iter().any(|activity| { &activity.run_id == run - && activity.status == RunStatus::Interrupted - && activity.turn_duration_ms.is_none() + && (activity.status == RunStatus::Queued + || (activity.status == RunStatus::Interrupted + && activity.turn_duration_ms.is_none())) }) } @@ -83,25 +84,40 @@ impl MessageQueue { const PAGE_SIZE: usize = 32; let mut detail = runtime.detail(thread, before, "", PAGE_SIZE)?; let messages = Self::read_messages(runtime, &detail)?; - let mut history = Self::visible_history(&mut detail, &messages); + detail + .history + .messages + .retain(|item| !Self::hidden(&messages, &detail.activity, &item.message.run_id)); // Queued and canceled messages still occupy slots in Huggler's raw history. // Read enough older messages to fill the visible page and advance its cursor. - while history.len() < PAGE_SIZE { + while detail.history.messages.len() < PAGE_SIZE { let Some(older) = detail.history.older.as_ref() else { break; }; - let mut page = match runtime.detail(thread, Some(older), "", PAGE_SIZE - history.len()) - { + let mut page = match runtime.history_with_activity( + thread, + Some(older), + "", + PAGE_SIZE - detail.history.messages.len(), + ) { Err(huggler::Error::HistoryChanged) => break, result => result?, }; - let mut visible = Self::visible_history(&mut page, &messages); - visible.append(&mut history); - history = visible; - detail.history.older = page.history.older; - detail.activity.extend(page.activity); + page.history + .messages + .retain(|item| !Self::hidden(&messages, &page.activity, &item.message.run_id)); + page.history.messages.append(&mut detail.history.messages); + detail.history = page.history; + for activity in page.activity { + if !detail + .activity + .iter() + .any(|existing| existing.run_id == activity.run_id) + { + detail.activity.push(activity); + } + } } - detail.history.messages = history; self.messages = messages; if let Some(text) = self.take_expired_draft(cx) { self.expired_draft = Some(text); @@ -119,68 +135,36 @@ impl MessageQueue { (text.as_str() != edit.original).then(|| text.to_string()) } - fn visible_history( - detail: &mut ConversationDetail, - queued: &[QueuedMessage], - ) -> Vec { - let mut history = std::mem::take(&mut detail.history.messages); - history.retain(|item| !Self::hidden(queued, detail, &item.message.run_id)); - history - } - fn read_messages( runtime: &Huggler, detail: &ConversationDetail, ) -> huggler::Result> { - let mut messages = Vec::new(); - if detail.queued_count > 0 { - // The transcript is paginated independently of the delivery queue. - let snapshot = runtime.read(&detail.id)?; - let queued: HashSet<_> = snapshot - .runs - .iter() - .filter(|run| run.status == RunStatus::Queued) - .map(|run| &run.id) - .collect(); - for message in snapshot.messages { - if message.role != Role::User || !queued.contains(&message.run_id) { - continue; - } - let (body, has_files) = if let Some(item) = - detail.history.messages.iter().find(|item| { - item.message.id == message.id && snapshot.cursor == detail.history.sequence - }) { - ( - item.files - .as_ref() - .map_or(item.message.text.as_str(), |files| files.caption.as_str()) - .to_owned(), - item.files.is_some(), - ) - } else { - let body = runtime.read_message_body(&detail.id, &message.id)?; - let has_files = body != message.text; - (body, has_files) - }; - let mut preview: String = body.chars().take(240).collect(); - if preview.len() < body.len() { + if detail.queued_count == 0 { + return Ok(Vec::new()); + } + Ok(runtime + .queued_messages(&detail.id)? + .into_iter() + .map(|message| { + let mut preview: String = message.preview.chars().take(240).collect(); + if message.truncated || preview.len() < message.preview.len() { preview.push('…'); } + let has_files = !message.attachment_names.is_empty(); if has_files { if !preview.trim().is_empty() { preview.push_str(" · "); } preview.push_str("Attachments"); } - messages.push(QueuedMessage { + QueuedMessage { run: message.run_id, - id: message.id, + id: message.message_id, preview, has_files, - }); - } - } - Ok(messages) + } + }) + .collect()) } } diff --git a/tests/fixtures/context-provider.py b/tests/fixtures/context-provider.py index 406b59c..0f392b8 100755 --- a/tests/fixtures/context-provider.py +++ b/tests/fixtures/context-provider.py @@ -31,7 +31,8 @@ def config_revision(config): def completed(): text = "reply " + prompt[-30:] if prompt in ("First question", "Explain the result and point out how to verify it."): - assert "very likely" in developer_instructions and "omit the entire block" in developer_instructions + assert "Ground each suggestion in the current task" in developer_instructions + assert "Omit the block when no action fits." in developer_instructions deltas = [ text + "\n\n\n" @@ -222,7 +223,7 @@ def completed(): emit(method="session/update", params={"sessionId": session, "update": call}) reply = "portable reply" if prompt == "First Claude question": - assert "omit the entire block" in developer_instructions + assert "Omit the block when no action fits." in developer_instructions reply += ("\n\n\n" "Explain the Claude result in detail.\n") emit(method="session/update", params={"sessionId": session, "update": {"sessionUpdate": "agent_message_chunk", @@ -261,6 +262,13 @@ def completed(): "threadId": session, "turnId": target, "itemId": item, "delta": delta}) emit(id=frame["id"], result=result) if method == "turn/start": + if (params.get("outputSchema") or {}).get("required") == ["title"]: + assert ephemeral + assert json.loads(prompt)["conversation"] == "Please investigate why the upload stalls." + emit(method="item/completed", params={"threadId": session, "turnId": turn, + "item": {"type": "agentMessage", "text": json.dumps({"title": "Upload stall investigation"})}}) + emit(method="turn/completed", params={"threadId": session, "turn": {"id": turn, "status": "completed"}}) + continue if prompt == "callbacks": emit(id="approve", method="item/commandExecution/requestApproval", params={ "threadId": session, "turnId": turn, "command": "make check", From 0ad935af095b10aab3905bbb3dfd66214fefda32 Mon Sep 17 00:00:00 2001 From: Roman Sirokov Date: Tue, 1 Dec 2026 23:01:42 +0100 Subject: [PATCH 2/2] feat: add conversation title generation setting --- docs/desktop-coding.md | 2 +- scripts/check-desktop-settings.py | 20 ++++++++++++++++++-- src/conversation.rs | 6 +++++- src/settings.rs | 8 ++++++++ src/settings/general.rs | 18 ++++++++++++++++++ 5 files changed, 50 insertions(+), 4 deletions(-) diff --git a/docs/desktop-coding.md b/docs/desktop-coding.md index 5e28a87..2ae7ce0 100644 --- a/docs/desktop-coding.md +++ b/docs/desktop-coding.md @@ -31,7 +31,7 @@ Use unique instance IDs. A JSON entry with the same ID as one of the eight prese Type your task and use the send shortcut or click the up arrow. Bear derives a short title from the first message. For example, “Please fix the parser.” becomes **Fix the parser**. A single-repository worktree uses a branch such as `huggler/fix-the-parser` and a checkout folder beginning with `fix-the-parser-`. If the branch name is taken, Bear tries a numbered suffix. The setup view shows the base selection, checkout creation, and conversation opening. Use the model picker at the lower left of the composer to choose a provider and model. **Bear → Create with Setup…** (⌘⇧N) lets you set the conversation title and, for a single-repository worktree, the exact branch name. - Set `BEAR_GENERATE_TITLES=1` before starting Bear to enable generated titles for new local Codex conversations with a first message and an automatic title. Bear opens the conversation immediately using the short title it derived locally. In the background, a separate Codex turn uses the first message, project name, and any attachment names to suggest a title. If Codex cannot suggest one, Bear keeps the local title. A title you enter yourself takes precedence. The branch name is set during checkout, before the suggestion arrives. + Turn on **Generate conversation titles** in **Settings → General** to enable generated titles for new local Codex conversations. The setting applies to new conversations immediately. If you previously set `BEAR_GENERATE_TITLES=1`, Bear uses that value until you change the setting. Bear opens the conversation immediately using the short title it derived locally. In the background, a separate Codex turn uses the first message, project name, and any attachment names to suggest a title. If Codex cannot suggest one, Bear keeps the local title. A title you enter yourself takes precedence. The branch name is set during checkout, before the suggestion arrives. 2. **Send a message.** Press **Enter** to send by default. Use **Shift+Enter** to add a line and **⌘L** to focus the message field. Change the send shortcut under **Settings → General**. In either composer, click **+** or drop files into the composer to attach up to eight files totaling 50 MiB, including up to 20 MiB of images. Click a draft filename to remove it before sending. In history, expand a filename to preview text, images, or extracted PDF text when available. Use **Save as…** to save the original file. You can send files on their own or queue them with a follow-up. The provider receives the filenames and the contents or local file paths supported by that provider. The built-in Codex instance can edit the checkout during implementation. You can change **Model** beside **Message** before sending or queuing your next turn. Bear remembers the selection for this conversation. Read the streaming reply, open command output and respond to questions or permission requests in **Conversation**. 3. **Manage ongoing work.** While the agent works, the send shortcut queues your follow-up by default. Select **Steer** under **Settings → General** to send a text follow-up into a Codex turn that can accept it. **Stop thread** interrupts the current work and pauses queued messages. Use **Resume queue** to deliver them. Choose **Show conversations** in the header to switch to another task. A partially typed answer stays with its question while the app is open. Reopening the app restores the selected conversation and its history. 4. **Review changed files.** The **Changes** tab in the right sidebar defaults to **All changes**, which compares the selected checkout with the branch’s merge base. For a multi-repo workspace, rows include the repository folder and each diff uses its own Git checkout. **All changes** compares each worktree with its starting commit. Choose **Uncommitted files** for staged, unstaged, and untracked files. The line totals follow the selection. Hover over the file name to see its full path. Use the row’s chevron to open **Open in**. Finder reveals the file, Terminal opens its folder, and VS Code opens the file. For deleted files the menu opens the nearest existing folder. Hover over a row with eligible uncommitted edits to show **Revert file**. Confirming a revert restores the path to its state at the current commit and removes files added since then. Resolve conflicts and submodule changes in Git. The list refreshes when you open the sidebar, select a conversation, finish a turn, or revert a file. diff --git a/scripts/check-desktop-settings.py b/scripts/check-desktop-settings.py index caa02cc..5d2366c 100644 --- a/scripts/check-desktop-settings.py +++ b/scripts/check-desktop-settings.py @@ -77,8 +77,17 @@ def check_general(executable, state, env): def check_generated_titles(executable, state, env): - env = dict(env, BEAR_GENERATE_TITLES="1", + env = dict(env, BEAR_GENERATE_TITLES="0", HUGGLER_CODEX=str(ROOT / "tests/fixtures/context-provider.py")) + toggle_titles = [ + {"key": "cmd-,"}, {"click": "General"}, {"click": "Generate conversation titles"}, + {"click": "Back to Settings"}, {"click": "Back to workspace"}, + ] + prefs = state / "preferences.json" + run_window(executable, state, [ + {"resize": [640, 440]}, *toggle_titles, + ], env) + assert json.loads(prefs.read_text())["generateConversationTitles"] is True run_window(executable, state, [ {"resize": [1120, 740]}, {"click": "First message"}, {"type": "Please investigate why the upload stalls."}, @@ -88,9 +97,16 @@ def check_generated_titles(executable, state, env): {"key": "cmd-shift-n"}, {"click": "Conversation name"}, {"type": "My title"}, {"click": "Send first message"}, {"see": "thread/My title"}, {"contains": "Codex/reply"}, ], env) + run_window(executable, state, [ + *toggle_titles, + {"key": "cmd-n"}, {"click": "First message"}, {"type": "Please investigate why the upload stalls."}, + {"click": "Send first message"}, {"see": "thread/Investigate why the upload stalls"}, + {"contains": "Codex/reply"}, + ], dict(env, BEAR_GENERATE_TITLES="1")) + assert json.loads(prefs.read_text())["generateConversationTitles"] is False with sqlite3.connect(state / "huggler.sqlite3") as db: assert db.execute("SELECT name FROM thread ORDER BY rowid").fetchall() == [ - ("Upload stall investigation",), ("My title",), + ("Upload stall investigation",), ("My title",), ("Investigate why the upload stalls",), ] frames = (json.loads(line) for log in state.rglob("frames.ndjson") for line in log.read_text().splitlines()) diff --git a/src/conversation.rs b/src/conversation.rs index 55313aa..e0d850c 100644 --- a/src/conversation.rs +++ b/src/conversation.rs @@ -1134,7 +1134,11 @@ impl Desktop { let launch_name = name.clone(); let (report_stage, mut stages) = tokio::sync::mpsc::unbounded_channel(); let title_provider = (derive_title - && std::env::var("BEAR_GENERATE_TITLES").as_deref() == Ok("1")) + && self + .settings + .read(cx) + .preferences() + .generates_conversation_titles()) .then(|| { runtime .provider_instances() diff --git a/src/settings.rs b/src/settings.rs index 94a3785..98c97f4 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -72,6 +72,8 @@ pub struct Preferences { pub(crate) follow_up: FollowUp, #[serde(skip_serializing_if = "std::ops::Not::not")] ask_for_agent_approval: bool, + #[serde(skip_serializing_if = "Option::is_none")] + generate_conversation_titles: Option, #[serde(skip_serializing_if = "std::ops::Not::not")] pub(crate) agent_notifications: bool, #[serde(skip_serializing_if = "std::ops::Not::not")] @@ -112,6 +114,7 @@ impl Default for Preferences { send_shortcut: SendShortcut::default(), follow_up: FollowUp::default(), ask_for_agent_approval: false, + generate_conversation_titles: None, agent_notifications: false, keep_awake: false, codex_executable: None, @@ -134,6 +137,11 @@ impl Default for Preferences { } impl Preferences { + pub(crate) fn generates_conversation_titles(&self) -> bool { + self.generate_conversation_titles + .unwrap_or_else(|| std::env::var("BEAR_GENERATE_TITLES").as_deref() == Ok("1")) + } + pub(crate) fn configure_providers( &mut self, options: &mut HugglerOptions, diff --git a/src/settings/general.rs b/src/settings/general.rs index 9bbd776..e35c643 100644 --- a/src/settings/general.rs +++ b/src/settings/general.rs @@ -117,6 +117,24 @@ impl Settings { h_flex().gap_1().children(shortcuts), cx, )) + .child(setting( + "Generate conversation titles", + "Let Codex suggest a title in the background for new local conversations without a custom title.", + control!( + "Generate conversation titles", + toggle( + "generate-conversation-titles", + "Generate conversation titles", + self.prefs.generates_conversation_titles(), + ) + .on_click(cx.listener(|view, _, _, cx| { + let mut prefs = view.prefs.clone(); + prefs.generate_conversation_titles = Some(!prefs.generates_conversation_titles()); + view.persist(prefs, cx); + })) + ), + cx, + )) .child(setting( "Follow-up behavior", "Steer sends text into a running Codex turn. Other follow-ups queue.",