The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(bots): scope a freshly created bot chat to the bots workspace
Brooklyn Nicholsonebb20910fa6b
diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-chat-creation.test.ts b/apps/desktop/src/plugins/hermes-bots/canonical-chat-creation.test.tsindex 5cfff2ee095..7c3b8906588 100644--- a/apps/desktop/src/plugins/hermes-bots/canonical-chat-creation.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/canonical-chat-creation.test.ts@@ -184,6 +184,25 @@ describe('the lazy row is materialized before anything else touches it', () => {expect(events).toEqual(['session.list', 'session.create', 'session.title', 'open:stored-1', 'prompt.submit'])})+ it('scopes the open to the bots workspace even with no staleness probe', async () => {+ // The create path is the one caller that passes no probe. Gating the+ // workspace fields on the probe left ITS chat unscoped, so the composer+ // could not tell a bot chat from a working session and kept the branch+ // rail up until the next (probed) click reopened the same row.+ respondWith(method =>+ method === 'session.create' ? { session_id: 'runtime-1', stored_session_id: 'stored-1' } : {}+ )++ const { createCanonicalChat } = await loadModule()++ await createCanonicalChat('ops', { kickoff: true })++ expect(hostMock.openSession).toHaveBeenCalledWith(+ 'stored-1',+ expect.objectContaining({ tabTitle: 'Bot Chat', workspaceMode: 'bots', workspaceOwnerKey: 'bot:ops' })+ )+ })+it('speaks the intro in the active locale (#91827)', async () => {// The first line of the forever-chat, and the bot's reply follows its// language — so a hardcoded English intro biased the whole conversation.diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-chat.ts b/apps/desktop/src/plugins/hermes-bots/canonical-chat.tsindex 5ba225c5a3b..265b1fa14d9 100644--- a/apps/desktop/src/plugins/hermes-bots/canonical-chat.ts+++ b/apps/desktop/src/plugins/hermes-bots/canonical-chat.ts@@ -259,7 +259,15 @@ function kickoffText(): string {* `openingStillCurrent` (click-path opens): a staleness probe consulted* before every navigation — when the user has already moved on (opened a* group, clicked another bot), the create still completes registry-side- * but never steals the workspace (#89834 family). */+ * but never steals the workspace (#89834 family).+ *+ * It gates WHETHER to navigate, never WHAT the session is. The bots+ * workspace fields below ride every open unconditionally: they say this row+ * is a bot's chat, which is true of a freshly minted one no matter who asked+ * for it. Spreading them only when a probe was passed is how the create path+ * — the one caller with no probe — opened its chat unscoped, and the+ * composer, reading that scope to stand the branch rail down, showed the+ * rail in a bot chat until the next click re-opened it scoped. */export function createCanonicalChat(owner: RosterRow | string,{ kickoff = false, openingStillCurrent = null }: CreateCanonicalChatOptions = {}@@ -267,6 +275,24 @@ export function createCanonicalChat(const { bot, name, key, route } = botOwner(owner)const inflight = canonicalCreations.get(key)+ // Every open of a just-minted row is the same call — adopting a concurrent+ // flight's result, the retry after a failed eager title, the retry after the+ // compat kickoff. Only WHEN differs, so WHAT lives in one place.+ const openFreshCanonical = (sid: string) =>+ host.openSession!(sid, {+ ...(route+ ? {+ route+ }+ : {}),+ profile: name,+ intent: 'main',+ keepAllProfilesScope: route ? true : false,+ workspaceMode: 'bots',+ workspaceOwnerKey: botWorkspaceOwnerKey(bot),+ tabTitle: CANONICAL_CHAT_TITLE+ })+if (inflight) {if (!openingStillCurrent) {return inflight.run!@@ -274,19 +300,7 @@ export function createCanonicalChat(return inflight.run!.then(async sid => {if (sid && openingStillCurrent() && typeof host.openSession === 'function') {- await host.openSession(sid, {- ...(route- ? {- route- }- : {}),- profile: name,- intent: 'main',- keepAllProfilesScope: route ? true : false,- workspaceMode: 'bots',- workspaceOwnerKey: botWorkspaceOwnerKey(bot),- tabTitle: CANONICAL_CHAT_TITLE- })+ await openFreshCanonical(sid)}return sid@@ -385,23 +399,7 @@ export function createCanonicalChat(if (sid && typeof host.openSession === 'function' && canNavigate()) {try {- await host.openSession(sid, {- ...(route- ? {- route- }- : {}),- profile: name,- intent: 'main',- keepAllProfilesScope: route ? true : false,- ...(openingStillCurrent- ? {- workspaceMode: 'bots',- workspaceOwnerKey: botWorkspaceOwnerKey(bot),- tabTitle: CANONICAL_CHAT_TITLE- }- : {})- })+ await openFreshCanonical(sid)opened = true} catch {// The stored row may not exist until the kickoff persists it. Retry@@ -427,23 +425,7 @@ export function createCanonicalChat(})if (!opened && sid && typeof host.openSession === 'function' && canNavigate()) {- await host.openSession(sid, {- ...(route- ? {- route- }- : {}),- profile: name,- intent: 'main',- keepAllProfilesScope: route ? true : false,- ...(openingStillCurrent- ? {- workspaceMode: 'bots',- workspaceOwnerKey: botWorkspaceOwnerKey(bot),- tabTitle: CANONICAL_CHAT_TITLE- }- : {})- })+ await openFreshCanonical(sid)}} catch {// The chat already exists under the canonical title — the next click@@ -453,23 +435,7 @@ export function createCanonicalChat(// No intro turn: still finish mounting the chat when the first open// raced the (now titled) row.try {- await host.openSession(sid, {- ...(route- ? {- route- }- : {}),- profile: name,- intent: 'main',- keepAllProfilesScope: route ? true : false,- ...(openingStillCurrent- ? {- workspaceMode: 'bots',- workspaceOwnerKey: botWorkspaceOwnerKey(bot),- tabTitle: CANONICAL_CHAT_TITLE- }- : {})- })+ await openFreshCanonical(sid)} catch {/* row is titled and persistent — the next click opens it by name */}