The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): make new Bot tabs owner-aware
David Dudok de Wit9b36c2d43ce9
diff --git a/apps/desktop/src/app/contrib/wiring.tsx b/apps/desktop/src/app/contrib/wiring.tsxindex 67eb63c8223..7a6e557f7ce 100644--- a/apps/desktop/src/app/contrib/wiring.tsx+++ b/apps/desktop/src/app/contrib/wiring.tsx@@ -23,6 +23,12 @@ import { GatewayConnectingOverlay } from '@/components/gateway-connecting-overlaimport { NotificationStack } from '@/components/notifications'import { DesktopOnboardingOverlay } from '@/components/onboarding'import { $newSessionTabAction, registerPaneCloser } from '@/components/pane-shell/tree/store'+import {+ $workspaceMode,+ $workspaceNewSessionTarget,+ $workspaceOwnerKey,+ setWorkspaceScope+} from '@/components/pane-shell/workspace-scope'import { FloatingPet } from '@/components/pet/floating-pet'import { RemoteDisplayBanner } from '@/components/remote-display-banner'import { SendDiagnosticsHost } from '@/components/send-diagnostics-dialog'@@ -39,6 +45,7 @@ import { requestVoiceConversationStart } from '@/store/composer'import { $activeConnectionId } from '@/store/connections'import { $cronReviewRequest, setCronFocusJobId } from '@/store/cron'import { $pinnedSessionIds, pinSession, restoreWorktree, unpinSession } from '@/store/layout'+import { notify } from '@/store/notifications'import { $previewTarget } from '@/store/preview'import {$activeGatewayProfile,@@ -545,6 +552,8 @@ export function ContribWiring({ children }: { children: ReactNode }) {// prefills the MAIN composer right after, so it has to own that surface.const startSessionInWorkspace = useCallback((path: null | string, options?: { openTab?: boolean }) => {+ setWorkspaceScope('sessions')+if (options?.openTab && mainChatOccupied(activeSessionIdRef.current, $selectedStoredSessionId.get())) {void openNewSessionTile('center', { cwd: path, listed: false })@@ -861,6 +870,32 @@ export function ContribWiring({ children }: { children: ReactNode }) {// it — Cursor-style. Every click opens a fresh "New session" tab (multiple// empty tabs are fine since none touch the session list).const openNewSessionTab = useCallback(() => {+ const workspaceMode = $workspaceMode.get()+ const workspaceOwnerKey = $workspaceOwnerKey.get()+ const workspaceNewSessionTarget = $workspaceNewSessionTarget.get()++ if (workspaceMode === 'bots') {+ if (workspaceNewSessionTarget?.kind !== 'route' || !workspaceOwnerKey) {+ notify({+ kind: 'info',+ message:+ workspaceNewSessionTarget?.kind === 'blocked'+ ? workspaceNewSessionTarget.message+ : 'Select a Bot or group first.'+ })++ return+ }++ void openNewSessionTile('center', {+ listed: false,+ route: workspaceNewSessionTarget.route,+ workspaceScope: { workspaceMode: 'bots', workspaceOwnerKey }+ })++ return+ }+void openNewSessionTile('center', { listed: false })}, [openNewSessionTile])diff --git a/apps/desktop/src/app/hooks/use-keybinds.ts b/apps/desktop/src/app/hooks/use-keybinds.tsindex b4a525acf48..e8292ad3d50 100644--- a/apps/desktop/src/app/hooks/use-keybinds.ts+++ b/apps/desktop/src/app/hooks/use-keybinds.ts@@ -14,6 +14,7 @@ import {togglePaneVisible,toggleTargetZoneTabStrip} from '@/components/pane-shell/tree/store'+import { setWorkspaceScope } from '@/components/pane-shell/workspace-scope'import { onReleaseTypingFocus } from '@/components/ui/keyboard-first'import { findBarClaimsCombo } from '@/lib/find-in-page'import { contributedKeybindHandler, PROFILE_SLOT_COUNT, SESSION_SLOT_COUNT } from '@/lib/keybinds/actions'@@ -216,6 +217,7 @@ export function useKeybinds(deps: KeybindRuntimeDeps): void {// Match the sidebar New Session button. A plain keyboard new chat should// target the current live profile, not a stale per-profile quick-create// selection from a prior action.+ setWorkspaceScope('sessions')$newChatProfile.set(null)deps.startFreshSession()window.dispatchEvent(new CustomEvent('hermes:new-session-shortcut'))diff --git a/apps/desktop/src/app/session/hooks/use-session-actions/index.ts b/apps/desktop/src/app/session/hooks/use-session-actions/index.tsindex 75733e38ff4..287f3500bf5 100644--- a/apps/desktop/src/app/session/hooks/use-session-actions/index.ts+++ b/apps/desktop/src/app/session/hooks/use-session-actions/index.ts@@ -4,6 +4,7 @@ import type { NavigateFunction } from 'react-router'import { graftRefreshedTailOntoBackfill } from '@/app/chat/transcript-backfill'import { revealTreePane } from '@/components/pane-shell/tree/store'+import { setWorkspaceScope } from '@/components/pane-shell/workspace-scope'import { deleteSession, getAllSessionMessages, getLatestSessionMessages, setSessionArchived } from '@/hermes'import { useI18n } from '@/i18n'import { type ChatMessage, preserveLocalAssistantErrors, toChatMessages } from '@/lib/chat-messages'@@ -23,6 +24,7 @@ import {$newChatProfile,$newChatRoute,$showAllProfiles,+ type AgentProfileRoute,ensureGatewayAgent,ensureGatewayProfile,normalizeProfileKey@@ -84,6 +86,7 @@ import {openSessionTile,patchSessionTile,publishSessionState,+ type SessionTileWorkspaceScope,type TileDock} from '@/store/session-states'import { broadcastSessionsChanged } from '@/store/session-sync'@@ -571,6 +574,7 @@ export function useSessionActions({const selectSidebarItem = useCallback((item: SidebarNavItem) => {if (item.action === 'new-session') {+ setWorkspaceScope('sessions')startFreshSessionDraft()return@@ -594,15 +598,28 @@ export function useSessionActions({* list (Cursor-style draft tab); it surfaces on the next refresh once the* first message persists a turn. "Open in split" keeps the listed behavior. */const openNewSessionTile = useCallback(- async (dir: TileDock = 'right', options?: { cwd?: null | string; listed?: boolean }) => {+ async (+ dir: TileDock = 'right',+ options?: {+ cwd?: null | string+ listed?: boolean+ route?: AgentProfileRoute | null+ workspaceScope?: SessionTileWorkspaceScope+ }+ ) => {const listed = options?.listed ?? truetry {// Fresh tile → the caller's workspace when one was named (the sidebar// "+" on a project/worktree lane), else the resolved new-session cwd// (project scope → configured default).- const capturedRoute = $newChatRoute.get()- const params = await desktopSessionCreateParams((options?.cwd || resolveNewSessionCwd()).trim(), capturedRoute)+ const capturedRoute = options?.route === undefined ? $newChatRoute.get() : options.route+ const workspaceScope = options?.workspaceScope ?? { workspaceMode: 'sessions' }++ const params = {+ ...(await desktopSessionCreateParams((options?.cwd || resolveNewSessionCwd()).trim(), capturedRoute)),+ ...(workspaceScope.workspaceMode === 'bots' ? { hidden: true } : {})+ }const created = capturedRoute? await requestGatewayForAgent<SessionCreateResponse>(@@ -616,7 +633,16 @@ export function useSessionActions({const stored = created.stored_session_idif (!stored) {- await requestGateway('session.close', { session_id: created.session_id }).catch(() => undefined)+ const closeCreated = capturedRoute+ ? requestGatewayForAgent(+ capturedRoute.connectionId,+ capturedRoute.profile,+ 'session.close',+ { session_id: created.session_id }+ )+ : requestGateway('session.close', { session_id: created.session_id })++ await closeCreated.catch(() => undefined)notify({ kind: 'error', title: copy.sessionUnavailable, message: copy.createSessionFailed })return@@ -641,7 +667,7 @@ export function useSessionActions({const runtimeInfo = applyRuntimeInfo(created.info, { foreground: false })updateSessionState(created.session_id, state => (runtimeInfo ? { ...state, ...runtimeInfo } : state), stored)- openSessionTile(stored, dir)+ openSessionTile(stored, dir, undefined, undefined, workspaceScope)patchSessionTile(stored, { runtimeId: created.session_id })if (dir === 'center' && runtimeInfo?.cwd) {diff --git a/apps/desktop/src/components/pane-shell/workspace-scope.test.ts b/apps/desktop/src/components/pane-shell/workspace-scope.test.tsindex 7aae790a372..241a4da966d 100644--- a/apps/desktop/src/components/pane-shell/workspace-scope.test.ts+++ b/apps/desktop/src/components/pane-shell/workspace-scope.test.ts@@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest'import {$workspaceMode,+ $workspaceNewSessionTarget,$workspaceOwnerKey,contributesToWorkspace,filterContributionsForWorkspace,@@ -38,6 +39,7 @@ describe('workspace scope', () => {it('defaults to the un-switched sessions window state', () => {expect($workspaceMode.get()).toBe('sessions')expect($workspaceOwnerKey.get()).toBeNull()+ expect($workspaceNewSessionTarget.get()).toBeNull()})it('publishes a coherent mode and owner in one batch', () => {@@ -56,6 +58,35 @@ describe('workspace scope', () => {unbindOwner()})+ it('publishes the exact new-session route with its Bot owner', () => {+ const route = {+ connectionId: 'connection-a',+ mode: 'remote' as const,+ profile: 'writer',+ targetProfile: 'writer'+ }++ expect(setWorkspaceScope('bots', 'bot:connection-a::writer', { kind: 'route', route })).toBe(true)+ expect($workspaceNewSessionTarget.get()).toEqual({ kind: 'route', route })++ // Equivalent route objects are a semantic no-op, not a new render signal.+ expect(+ setWorkspaceScope('bots', 'bot:connection-a::writer', { kind: 'route', route: { ...route } })+ ).toBe(false)++ setWorkspaceScope('sessions')+ expect($workspaceNewSessionTarget.get()).toBeNull()+ })++ it('keeps a group owner explicit while blocking generic session creation', () => {+ const target = { kind: 'blocked' as const, message: 'New group conversations start in the group composer.' }++ setWorkspaceScope('bots', 'group:room-1', target)++ expect($workspaceOwnerKey.get()).toBe('group:room-1')+ expect($workspaceNewSessionTarget.get()).toEqual(target)+ })+it('keeps global contributions visible in both modes', () => {expect(contributesToWorkspace(undefined, 'sessions', null)).toBe(true)expect(contributesToWorkspace(undefined, 'bots', 'bot-a')).toBe(true)diff --git a/apps/desktop/src/components/pane-shell/workspace-scope.ts b/apps/desktop/src/components/pane-shell/workspace-scope.tsindex 3980fc3f155..a034477b04a 100644--- a/apps/desktop/src/components/pane-shell/workspace-scope.ts+++ b/apps/desktop/src/components/pane-shell/workspace-scope.ts@@ -24,22 +24,77 @@ export const $workspaceMode = atom<WorkspaceMode>('sessions')/** Default workspace owner key: none (unscoped / global ownership). */export const $workspaceOwnerKey = atom<string | null>(null)+/** Exact route for a fresh session in the current workspace. Kept structural+ * here so the generic pane shell does not depend on profile/gateway stores. */+export interface WorkspaceSessionRoute {+ connectionId: string+ mode?: 'local' | 'remote'+ profile: string+ targetProfile?: string+}++/** What the shared `+` / session.newTab command means in this workspace. */+export type WorkspaceNewSessionTarget =+ | { kind: 'blocked'; message: string }+ | { kind: 'route'; route: WorkspaceSessionRoute }++/** Sessions uses its established ambient behavior (`null`). Bots publishes an+ * exact route or a concise reason that a generic session is unavailable. */+export const $workspaceNewSessionTarget = atom<WorkspaceNewSessionTarget | null>(null)+/** One key for window-local active-pane memory. Owner keys stay opaque. */export function workspaceScopeKey(mode: WorkspaceMode, ownerKey: string | null): string {return mode === 'sessions' ? 'sessions' : `bots:${ownerKey ?? ''}`}-/** Publish one coherent presentation scope without an intermediate mixed frame. */-export function setWorkspaceScope(mode: WorkspaceMode, ownerKey: string | null = null): boolean {+function sameNewSessionTarget(a: WorkspaceNewSessionTarget | null, b: WorkspaceNewSessionTarget | null): boolean {+ if (a === b) {+ return true+ }++ if (!a || !b || a.kind !== b.kind) {+ return false+ }++ if (a.kind === 'blocked' && b.kind === 'blocked') {+ return a.message === b.message+ }++ if (a.kind === 'route' && b.kind === 'route') {+ return (+ a.route.connectionId === b.route.connectionId &&+ a.route.mode === b.route.mode &&+ a.route.profile === b.route.profile &&+ a.route.targetProfile === b.route.targetProfile+ )+ }++ return false+}++/** Publish one coherent presentation and creation scope without an+ * intermediate mixed frame. Sessions always retains its existing ambient+ * new-session behavior; alternate workspaces must state their intent. */+export function setWorkspaceScope(+ mode: WorkspaceMode,+ ownerKey: string | null = null,+ newSessionTarget: WorkspaceNewSessionTarget | null = null+): boolean {const nextOwnerKey = mode === 'bots' ? ownerKey : null+ const nextNewSessionTarget = mode === 'bots' ? newSessionTarget : null- if ($workspaceMode.get() === mode && $workspaceOwnerKey.get() === nextOwnerKey) {+ if (+ $workspaceMode.get() === mode &&+ $workspaceOwnerKey.get() === nextOwnerKey &&+ sameNewSessionTarget($workspaceNewSessionTarget.get(), nextNewSessionTarget)+ ) {return false}batch(() => {$workspaceMode.set(mode)$workspaceOwnerKey.set(nextOwnerKey)+ $workspaceNewSessionTarget.set(nextNewSessionTarget)})return truediff --git a/apps/desktop/src/plugins/hermes-bots/plugin.js b/apps/desktop/src/plugins/hermes-bots/plugin.jsindex 3573f0f3f98..8f4b6d65ba2 100644--- a/apps/desktop/src/plugins/hermes-bots/plugin.js+++ b/apps/desktop/src/plugins/hermes-bots/plugin.js@@ -4568,12 +4568,22 @@ function isDefaultBot(bot) {function newBotChat(bot) {if (typeof host.newChat !== 'function') {- host.navigate?.('/')+ host.notify?.({ kind: 'error', message: 'Update Hermes Desktop to open another Bot chat.' })return}- host.newChat(bot?.sourceScoped || bot?.remoteSource ? botConnectionRoute(bot) : bot?.name)+ const route = botConnectionRoute(bot)++ if (!route) {+ host.notify?.({ kind: 'error', message: 'Update Hermes Desktop to open another Bot chat.' })++ return+ }++ const ownerKey = botWorkspaceOwnerKey(bot)+ setBotsWorkspaceOwner(ownerKey, bot)+ host.newChat(route, { workspaceMode: 'bots', workspaceOwnerKey: ownerKey })}/** Resolve @handles in prose against the Bot Mode roster (local + Connections).@@ -4773,6 +4783,24 @@ function botConnectionRoute(bot) {})}+const BOTS_HOME_OWNER_KEY = 'bots:home'++function botWorkspaceOwnerKey(bot) {+ const route = botConnectionRoute(bot)++ return `bot:${route ? botRouteKey(route) : String(bot?.name || 'default')}`+}++function groupWorkspaceOwnerKey(group) {+ return `group:${groupChatRoomKey(group, $groupChats.get()[group])}`+}++function setBotsWorkspaceOwner(ownerKey, bot = null, blockedMessage = 'Select a Bot or group first.') {+ const route = bot ? botConnectionRoute(bot) : null+ const target = route ? { kind: 'route', route } : { kind: 'blocked', message: blockedMessage }++ host.setWorkspaceScope?.('bots', ownerKey || BOTS_HOME_OWNER_KEY, target)+}function backendTargetProfile(route, fallbackProfile = 'default') {if (!route) {return fallbackProfile@@ -5288,7 +5316,7 @@ async function ensureBotMetadata(bot) {* resolves a canonical-chat id. */async function openRosterBot(bot) {const generation = ++botOpenGeneration- const key = botRosterKey(bot)+ const key = botSelectionKey(bot)const meta = botRosterMeta(bot, $botMeta.get())// Keep the currently visible group as a fallback until this explicit action// has actually fronted a new owner; a failed home open must not steal the@@ -5297,35 +5325,7 @@ async function openRosterBot(bot) {haptic('tap')saveSelectedRosterBot(bot)-- if (bot.remoteSource) {- // Selection only. A remote bot must never be opened through whichever- // gateway happens to be live; remote mention delivery remains backend-owned.- $openBotChat.set(null)- $groupChatWorkspace.set(null)-- if (botsHomeEnabled()) {- // Explicitly front the selected owner but keep the existing group tab- // intact. If the workspace door refuses, restore the group selection so- // a failed roster action cannot leave the center ownerless.- if (!openBotsHomeWorkspace(true) && previousGroup) {- $groupChatWorkspace.set(previousGroup)- }- } else {- // Old shells have no home surface; keep the existing visible group as- // owner and offer only guidance, never renderer-owned remote delivery.- if (previousGroup) {- $groupChatWorkspace.set(previousGroup)- }- host.notify?.({- kind: 'info',- title: displayName(bot, meta),- message: `Stay in this chat and message @${botHandle(bot.name, bot)} from a Bot Chat.`- })- }-- return false- }+ setBotsWorkspaceOwner(botWorkspaceOwnerKey(bot), bot)$groupChatWorkspace.set(null)@@ -5357,7 +5357,7 @@ async function openRosterBot(bot) {}try {- const registryId = await openBotCanonicalChat(bot.name)+ const registryId = await openBotCanonicalChat(bot)if (generation !== botOpenGeneration) {return false@@ -5397,7 +5397,7 @@ async function openRosterBot(bot) {$openBotChat.set({ key, openedRegistryId: '' })closeBotsHomeWorkspace()- host.newChat(bot.name)+ newBotChat(bot)return true}@@ -7585,11 +7585,9 @@ function BotRow({ bot, onDelete, onEdit, onGroup, showHandle }) {jsx(ContextMenuSeparator, {}),jsx(ContextMenuItem, {onSelect: () => {- $selectedBot.set(botSelectionKey(bot))-- if (typeof host.newChat === 'function') {- newBotChat(bot)- }+ saveSelectedRosterBot(bot)+ setBotsWorkspaceOwner(botWorkspaceOwnerKey(bot), bot)+ newBotChat(bot)},children: 'New chat with this agent'}),@@ -12425,6 +12423,9 @@ function openBotsHomeWorkspace(explicit = false) {return false}+ const selected = selectedRosterBot($lastRoster.get(), $selectedRosterKey.get())+ const ownerKey = selected ? botWorkspaceOwnerKey(selected) : BOTS_HOME_OWNER_KEY+ setBotsWorkspaceOwner(ownerKey, selected)// Already open and fronted: nothing to do. Already open but backgrounded// (a persisted layout can restore the tab behind the draft): re-open to// re-front it. Never stack a second registration — a stale disposer would@@ -12537,6 +12538,8 @@ function openGroupChat(group) {// but it may not later close or visually steal the room the user chose.botOpenGeneration += 1$groupNeedsYou.set({ ...$groupNeedsYou.get(), [group]: false })+ const ownerKey = groupWorkspaceOwnerKey(group)+ setBotsWorkspaceOwner(ownerKey, null, 'New group conversations start in the group composer.')if (typeof host.openWorkspace === 'function') {try {@@ -13795,6 +13798,17 @@ export default {const stopSidebarSync = $sidebarVisible.listen(visible => {$botsPaneVisible.set(Boolean(visible))+ if (visible) {+ const group = $groupChatWorkspace.get()+ const selected = selectedRosterBot($lastRoster.get(), $selectedRosterKey.get())+ setBotsWorkspaceOwner(+ group ? groupWorkspaceOwnerKey(group) : selected ? botWorkspaceOwnerKey(selected) : BOTS_HOME_OWNER_KEY,+ group ? null : selected,+ group ? 'New group conversations start in the group composer.' : 'Select a Bot or group first.'+ )+ } else {+ host.setWorkspaceScope?.('sessions')+ }// A generic composer has no stored-session owner, so passive sync// replaces it with the Bot home. A real restored chat keeps the// center until the user explicitly selects a Bot owner.diff --git a/apps/desktop/src/plugins/hermes-bots/tests/remote-routing-races.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/remote-routing-races.test.mjsindex 4f6da3d2c0d..8c3794cebda 100644--- a/apps/desktop/src/plugins/hermes-bots/tests/remote-routing-races.test.mjs+++ b/apps/desktop/src/plugins/hermes-bots/tests/remote-routing-races.test.mjs@@ -37,7 +37,7 @@ function load({ requestProfile, agents, profileRoutes } = {}) {activeConnectionId = connectionIdcalls.push(['ensureAgent', connectionId, profile])},- newChat: route => calls.push(['newChat', route]),+ newChat: (route, options) => calls.push(['newChat', route, options]),notify: () => undefined,notifyError: () => undefined,profileRoutes: profileRoutes || (async () => []),@@ -50,6 +50,7 @@ function load({ requestProfile, agents, profileRoutes } = {}) {calls.push(['profile', route, method, params])return {}}),+ setWorkspaceScope: (mode, ownerKey, target) => calls.push(['workspaceScope', mode, ownerKey, target]),state: {connectionId: { get: () => activeConnectionId, listen: () => undefined },gateway: { get: () => 'open', listen: () => undefined },@@ -351,6 +352,17 @@ test('delayed duplicate, delete, and new chat keep source ownership', async () =.filter(value => value && typeof value === 'object')assert.ok(routes.length >= 3)assert.ok(routes.every(route => route.connectionId === 'remote-a'))++ const newChat = runtime.calls.find(call => call[0] === 'newChat')+ assert.equal(newChat[2].workspaceMode, 'bots')+ assert.equal(newChat[2].workspaceOwnerKey, 'bot:remote-a::worker')+ assert.equal(newChat[1].targetProfile, 'backend-worker')++ const scope = runtime.calls.find(call => call[0] === 'workspaceScope')+ assert.equal(scope[1], 'bots')+ assert.equal(scope[2], 'bot:remote-a::worker')+ assert.equal(scope[3].kind, 'route')+ assert.equal(scope[3].route.connectionId, 'remote-a')})diff --git a/apps/desktop/src/sdk/index.test.ts b/apps/desktop/src/sdk/index.test.tsindex 0817188888f..a279f3cd00e 100644--- a/apps/desktop/src/sdk/index.test.ts+++ b/apps/desktop/src/sdk/index.test.ts@@ -178,6 +178,7 @@ describe('host workspace scope', () => {afterEach(async () => {host.setWorkspaceScope('sessions')const tree = await import('@/components/pane-shell/tree/store')+ tree.$newSessionTabAction.set(null)tree.removeTreePane('plugin-workspace:scope-test')})@@ -214,4 +215,23 @@ describe('host workspace scope', () => {expect($workspaceMode.get()).toBe('bots')expect($workspaceOwnerKey.get()).toBe('connection-b::default')})++ it('uses the shared tab action for an exact Bot owner without moving Sessions', async () => {+ const tree = await import('@/components/pane-shell/tree/store')+ const { $workspaceNewSessionTarget } = await import('@/components/pane-shell/workspace-scope')+ const opened: string[] = []++ const route = {+ connectionId: 'connection-b',+ mode: 'remote' as const,+ profile: 'writer',+ targetProfile: 'writer'+ }++ tree.$newSessionTabAction.set(() => opened.push('tab'))+ host.newChat(route, { workspaceMode: 'bots', workspaceOwnerKey: 'bot:connection-b::writer' })++ expect(opened).toEqual(['tab'])+ expect($workspaceNewSessionTarget.get()).toEqual({ kind: 'route', route })+ })})diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.tsindex 210448cef92..f6cf8082cae 100644--- a/apps/desktop/src/sdk/index.ts+++ b/apps/desktop/src/sdk/index.ts@@ -26,12 +26,16 @@ import { openSession, type OpenSessionIntent } from '@/app/open-session'import type { ClientSessionState } from '@/app/types'import {$narrowViewport,+ $newSessionTabAction,$paneVisible,registerPaneCloser,removeTreePane,revealTreePane} from '@/components/pane-shell/tree/store'-import { setWorkspaceScope as publishWorkspaceScope } from '@/components/pane-shell/workspace-scope'+import {+ setWorkspaceScope as publishWorkspaceScope,+ type WorkspaceNewSessionTarget+} from '@/components/pane-shell/workspace-scope'import { onGatewayEvent } from '@/contrib/events'import { registry } from '@/contrib/registry'import type { WorkspaceMode } from '@/contrib/types'@@ -297,6 +301,11 @@ export interface PluginOpenSessionOptions {retryHydrationTimeoutOnce?: boolean}+export interface PluginNewChatOptions {+ workspaceMode?: WorkspaceMode+ workspaceOwnerKey?: string+}+function waitForFocusedSessionHydration({connectionId,expectHistory,@@ -747,6 +756,11 @@ export const host = {const intent = options.intent ?? 'in-place'if (options.workspaceMode === 'bots') {+ publishWorkspaceScope(+ 'bots',+ options.workspaceOwnerKey ?? null,+ ownerRoute ? { kind: 'route', route: ownerRoute } : null+ )openSession(storedSessionId, navigate, intent, {workspaceMode: 'bots',workspaceOwnerKey: options.workspaceOwnerKey@@ -912,13 +926,38 @@ export const host = {},/** Switch the visible main-pane workspace without unregistering retained panes. */- setWorkspaceScope: (mode: WorkspaceMode, ownerKey: null | string = null): boolean =>- publishWorkspaceScope(mode, ownerKey),+ setWorkspaceScope: (+ mode: WorkspaceMode,+ ownerKey: null | string = null,+ newSessionTarget: WorkspaceNewSessionTarget | null = null+ ): boolean => publishWorkspaceScope(mode, ownerKey, newSessionTarget),/** Start a fresh chat draft, optionally pointed at another profile (its* backend spins up in the background — same door the sidebar's per-profile* "+" uses). */- newChat: (profile?: null | string | PluginProfileRoute): void => {+ newChat: (profile?: null | string | PluginProfileRoute, options: PluginNewChatOptions = {}): void => {+ if (options.workspaceMode === 'bots') {+ if (!profile || typeof profile === 'string' || !options.workspaceOwnerKey) {+ notify({ kind: 'error', message: 'Select a Bot before starting another chat.' })++ return+ }++ publishWorkspaceScope('bots', options.workspaceOwnerKey, { kind: 'route', route: { ...profile } })++ const openTab = $newSessionTabAction.get()++ if (!openTab) {+ notify({ kind: 'error', message: 'Update Hermes Desktop to open another Bot chat.' })++ return+ }++ openTab()++ return+ }+if (profile && typeof profile !== 'string') {newSessionInAgent({ ...profile })} else {