The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui,desktop): send session_id on commands.catalog, complete.slash and skills.reload
teknium19b0ca895b3a3
diff --git a/apps/desktop/src/app/chat/composer/hooks/use-slash-completions.ts b/apps/desktop/src/app/chat/composer/hooks/use-slash-completions.tsindex a22dbe68130..e8ef02110b5 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-slash-completions.ts+++ b/apps/desktop/src/app/chat/composer/hooks/use-slash-completions.ts@@ -1,6 +1,6 @@import type { Unstable_TriggerAdapter, Unstable_TriggerItem } from '@assistant-ui/core'import { useStore } from '@nanostores/react'-import { useCallback, useEffect } from 'react'+import { useCallback, useEffect, useMemo } from 'react'import type { HermesGateway } from '@/hermes'import { sessionTitle } from '@/lib/chat-runtime'@@ -57,6 +57,10 @@ const SESSION_INLINE_LIMIT = 7/** Live `/` completions backed by the gateway's `complete.slash` RPC. */export function useSlashCompletions(options: {gateway: HermesGateway | null+ /** Skill completions are per session: project-local skills follow the+ * session's repo, so the catalog and each query are fetched and cached per+ * session. */+ sessionId?: string | null/** Desktop theme list — `/skin` is owned client-side, so its arg completions* come from here, not the backend (whose skin list is CLI/TUI-only). */skinThemes?: DesktopThemeCommandOption[]@@ -65,9 +69,11 @@ export function useSlashCompletions(options: {adapter: Unstable_TriggerAdapterloading: boolean} {- const { gateway, skinThemes, activeSkin } = options+ const { gateway, sessionId, skinThemes, activeSkin } = optionsconst enabled = Boolean(gateway)const epoch = useStore($slashCompletionsEpoch)+ const sessionParams = useMemo(() => (sessionId ? { session_id: sessionId } : {}), [sessionId])+ const catalogKey = sessionId ? `catalog:${sessionId}` : 'catalog'// Warm argument_mode before the first `/` so Space treats /review as text.useEffect(() => {@@ -75,14 +81,16 @@ export function useSlashCompletions(options: {return}- void cachedSlashCompletion('catalog', () => gateway.request<CommandsCatalogLike>('commands.catalog'))+ void cachedSlashCompletion(catalogKey, () =>+ gateway.request<CommandsCatalogLike>('commands.catalog', sessionParams)+ ).then(catalog => {filterDesktopCommandsCatalog(catalog)}).catch(() => {// Next keystroke retries; don't block the composer on a warm-up miss.})- }, [gateway, epoch])+ }, [gateway, epoch, catalogKey, sessionParams])const fetcher = useCallback(async (query: string): Promise<CompletionPayload> => {@@ -154,7 +162,9 @@ export function useSlashCompletions(options: {try {if (!query) {const catalog = filterDesktopCommandsCatalog(- await cachedSlashCompletion('catalog', () => gateway.request<CommandsCatalogLike>('commands.catalog'))+ await cachedSlashCompletion(catalogKey, () =>+ gateway.request<CommandsCatalogLike>('commands.catalog', sessionParams)+ ))// Prefer the categorized layout so the popover renders section headers@@ -194,8 +204,11 @@ export function useSlashCompletions(options: {return { items, query }}- const result = await cachedSlashCompletion(`slash:${text.toLowerCase()}`, () =>- gateway.request<{ items?: CompletionEntry[]; replace_from?: number }>('complete.slash', { text })+ const result = await cachedSlashCompletion(`slash:${sessionId ?? ''}:${text.toLowerCase()}`, () =>+ gateway.request<{ items?: CompletionEntry[]; replace_from?: number }>('complete.slash', {+ text,+ ...sessionParams+ }))// Arg-completion items (replace_from > 1) carry just the arg stub —@@ -251,7 +264,7 @@ export function useSlashCompletions(options: {return { items: [], query }}},- [gateway, skinThemes, activeSkin]+ [gateway, skinThemes, activeSkin, sessionId, catalogKey, sessionParams])const toItem = useCallback((entry: CompletionEntry, index: number): Unstable_TriggerItem => {@@ -293,9 +306,9 @@ export function useSlashCompletions(options: {return true}- return hasCachedSlashCompletion(query ? `slash:${text.toLowerCase()}` : 'catalog')+ return hasCachedSlashCompletion(query ? `slash:${sessionId ?? ''}:${text.toLowerCase()}` : catalogKey)},- [skinThemes]+ [skinThemes, sessionId, catalogKey])return useLiveCompletionAdapter({ enabled, epoch, fetcher, isCached, toItem })diff --git a/apps/desktop/src/app/chat/composer/index.tsx b/apps/desktop/src/app/chat/composer/index.tsxindex eab6b7b2c23..957aba3f69b 100644--- a/apps/desktop/src/app/chat/composer/index.tsx+++ b/apps/desktop/src/app/chat/composer/index.tsx@@ -254,7 +254,14 @@ export function ChatBar({const { availableThemes, themeName } = useTheme()const at = useAtCompletions({ gateway: gateway ?? null, sessionId: sessionId ?? null, cwd: cwd ?? null })- const slash = useSlashCompletions({ activeSkin: themeName, gateway: gateway ?? null, skinThemes: availableThemes })++ const slash = useSlashCompletions({+ activeSkin: themeName,+ gateway: gateway ?? null,+ sessionId: sessionId ?? null,+ skinThemes: availableThemes+ })+const emoji = useEmojiCompletions()const { t } = useI18n()diff --git a/ui-tui/src/app/createGatewayEventHandler.ts b/ui-tui/src/app/createGatewayEventHandler.tsindex 25519ada703..223dc5315c3 100644--- a/ui-tui/src/app/createGatewayEventHandler.ts+++ b/ui-tui/src/app/createGatewayEventHandler.ts@@ -695,7 +695,12 @@ export function createGatewayEventHandler(ctx: GatewayEventHandlerContext): (ev:void rpc('wake.start', { surface: 'tui' }).catch(() => undefined)}- rpc<CommandsCatalogResponse>('commands.catalog', {})+ // Bound to the live session when one exists (reconnect): project-local+ // skills follow the session's repo. Before the first session the gateway+ // uses the same workspace it seeds a new session with.+ const catalogSid = getUiState().sid++ rpc<CommandsCatalogResponse>('commands.catalog', catalogSid ? { session_id: catalogSid } : {}).then(r => {if (!r?.pairs) {returndiff --git a/ui-tui/src/app/slash/commands/ops.ts b/ui-tui/src/app/slash/commands/ops.tsindex 28aeb59b675..01515c29c38 100644--- a/ui-tui/src/app/slash/commands/ops.ts+++ b/ui-tui/src/app/slash/commands/ops.ts@@ -462,13 +462,17 @@ export const opsCommands: SlashCommand[] = [help: 're-scan installed skills in the live TUI gateway',name: 'reload-skills',run: (_arg, ctx) => {+ // Bound to the session so the rescan and the refreshed catalog see its+ // repo's project-local skills, not the launch environment's.+ const params = ctx.sid ? { session_id: ctx.sid } : {}+ctx.gateway- .rpc<SkillsReloadResponse>('skills.reload', {})+ .rpc<SkillsReloadResponse>('skills.reload', params).then(ctx.guarded<SkillsReloadResponse>(r => {ctx.transcript.page(r.output || 'skills reloaded', 'Reload Skills')ctx.gateway- .rpc<CommandsCatalogResponse>('commands.catalog', {})+ .rpc<CommandsCatalogResponse>('commands.catalog', params).then(ctx.guarded<CommandsCatalogResponse>(catalog => {if (!catalog?.pairs) {diff --git a/ui-tui/src/hooks/useCompletion.ts b/ui-tui/src/hooks/useCompletion.tsindex a0ed0a52266..ddf71ada44c 100644--- a/ui-tui/src/hooks/useCompletion.ts+++ b/ui-tui/src/hooks/useCompletion.ts@@ -3,6 +3,7 @@ import { useEffect, useRef, useState } from 'react'import type { CompletionItem } from '../app/interfaces.js'import { rankSlashItems } from '../app/slash/fuzzyScore.js'+import { getUiState } from '../app/uiStore.js'import { inlineSlashTrigger } from '../domain/slash.js'import type { GatewayClient } from '../gatewayClient.js'import type { CompletionResponse } from '../gatewayTypes.js'@@ -116,7 +117,12 @@ export function useCompletion(input: string, blocked: boolean, gw: GatewayClientreturn}- gw.request<CompletionResponse>(request.method, request.params)+ // Skill completions are per session: project-local skills follow the+ // session's repo, so the gateway must know which session is asking.+ const sid = getUiState().sid+ const params = request.method === 'complete.slash' && sid ? { ...request.params, session_id: sid } : request.params++ gw.request<CompletionResponse>(request.method, params).then(raw => {if (ref.current !== input) {return