Skip to content

The agent that grows with you

fix(catalog): installs use the approved commit and settled retries show their own result (review)

alt-glitch8ce4d4bf95e0
diff --git a/apps/desktop/src/components/assistant-ui/catalog-install-tool.tsx b/apps/desktop/src/components/assistant-ui/catalog-install-tool.tsx
index 2f6c8822810..26a4a4ae0e2 100644
--- a/apps/desktop/src/components/assistant-ui/catalog-install-tool.tsx
+++ b/apps/desktop/src/components/assistant-ui/catalog-install-tool.tsx
@@ -12,7 +12,7 @@ import { Progress } from '@/components/ui/progress'
import { useI18n } from '@/i18n'
import { Book, Loader2, Plug } from '@/lib/icons'
import { cn } from '@/lib/utils'
-import { installAgentPlugin } from '@/store/agent-plugins'
+import { type AgentPluginInstallResult, installAgentPlugin } from '@/store/agent-plugins'
import {
type CatalogEntry,
connectionOpOf,
@@ -56,6 +56,27 @@ function platformName(platform: string): string {
const isCatalogTarget = (target: ConnectionTarget): target is CatalogTarget => Boolean(target.catalog)
+/** The row a successful settled Try again draws: the backend's install result for that retry, in the
+ * fields the runner's installed row carries (`tools/connectors/catalog.py::_installed_row`). */
+function retriedRow(target: CatalogTarget, result: AgentPluginInstallResult): CatalogTarget {
+ const servers = result.live.mcpServers
+
+ return {
+ ...target,
+ catalog: {
+ ...target.catalog,
+ alreadyInstalled: false,
+ enabled: result.enabled ?? null,
+ missingEnv: result.missingEnv ?? [],
+ serverErrors: servers.filter(server => !server.connected).map(({ error, name }) => ({ error: error ?? '', name })),
+ skill: result.skillIds?.[0] ?? null
+ },
+ detail: '',
+ state: 'connected',
+ tools: servers.filter(server => server.connected).flatMap(server => server.tools)
+ }
+}
+
/** `manage_catalog`: the host's catalog-install card. The model named ids; every word on a row is the
* host's resolution of that id. The card lives on the tool row that opened the operation only. */
export function CatalogInstallTool(props: ToolCallMessagePartProps) {
@@ -64,6 +85,8 @@ export function CatalogInstallTool(props: ToolCallMessagePartProps) {
const runtimeId = useStore(view.$runtimeId)
const opId = connectionOpOf(props.args)
const running = props.result === undefined
+ // Only an install opens an operation; a search row that reuses an install's call id draws no card.
+ const opens = opId !== null || props.args.action === 'install'
const $request = useMemo(
() => toolConnectionRequest(runtimeId, props.toolCallId, opId, running),
@@ -72,7 +95,7 @@ export function CatalogInstallTool(props: ToolCallMessagePartProps) {
const request = useStore($request)
- if (request && connectionRequestOwnsPart(props, request)) {
+ if (opens && request && connectionRequestOwnsPart(props, request)) {
return <CatalogInstallCard request={request} />
}
@@ -135,8 +158,8 @@ export function CatalogRow({ request, target }: CatalogRowProps) {
// another operation can never hold this row.
const [sentAt, setSentAt] = useState<null | { opId: string; seq: number }>(null)
// Try again on a failed plugin row after the operation settled: a fresh host install (which enables a
- // plugin already on disk). The settled operation is frozen, so the row shows this outcome over it.
- const [retry, setRetry] = useState<null | { detail: string; status: 'failed' | 'installed' | 'running' }>(null)
+ // plugin already on disk). The settled operation is frozen, so the row draws that install's result.
+ const [retry, setRetry] = useState<null | { row: CatalogTarget; status: 'done' } | { status: 'running' }>(null)
const sending = (sentAt?.opId === request.opId && request.seq <= sentAt.seq) || retry?.status === 'running'
const Glyph = KIND_GLYPH[target.kind]
@@ -156,11 +179,11 @@ export function CatalogRow({ request, target }: CatalogRowProps) {
}
const retrySettled = async () => {
- setRetry({ detail: '', status: 'running' })
+ setRetry({ status: 'running' })
const owner = request.sessionId ? await connectionOwnerFor(request.sessionId, 'plugins.manage') : null
if (!owner) {
- setRetry({ detail: copy.sendFailed, status: 'failed' })
+ setRetry({ row: { ...target, detail: copy.sendFailed }, status: 'done' })
return
}
@@ -180,15 +203,11 @@ export function CatalogRow({ request, target }: CatalogRowProps) {
}
)
- setRetry(result.ok ? { detail: '', status: 'installed' } : { detail: result.error ?? '', status: 'failed' })
+ const row = result.ok ? retriedRow(target, result) : { ...target, detail: result.error || target.detail }
+ setRetry({ row, status: 'done' })
}
- const shown: CatalogTarget =
- retry?.status === 'installed'
- ? { ...target, detail: '', state: 'connected' }
- : retry?.status === 'failed'
- ? { ...target, detail: retry.detail || target.detail }
- : target
+ const shown = retry?.status === 'done' ? retry.row : target
const onRetry = !request.settled
? () => void answer('approved')
diff --git a/apps/desktop/src/lib/chat-messages/index.ts b/apps/desktop/src/lib/chat-messages/index.ts
index 73f646c1b07..404956b6f01 100644
--- a/apps/desktop/src/lib/chat-messages/index.ts
+++ b/apps/desktop/src/lib/chat-messages/index.ts
@@ -15,7 +15,8 @@ export {
reasoningPart,
reasoningTextFromDetails,
renderMediaTags,
- textPart
+ textPart,
+ turnHasReply
} from './parts'
export type { UnspokenTurnSpeech } from './parts'
export {
diff --git a/apps/desktop/src/lib/chat-messages/parts.ts b/apps/desktop/src/lib/chat-messages/parts.ts
index dd468f9b1fa..c05f943735b 100644
--- a/apps/desktop/src/lib/chat-messages/parts.ts
+++ b/apps/desktop/src/lib/chat-messages/parts.ts
@@ -317,6 +317,27 @@ export function chatMessageText(message: ChatMessage): string {
return partsText(message.parts)
}
+/** Whether the newest turn has a visible assistant reply (text or an error) after its user message. */
+export function turnHasReply(messages: ChatMessage[]): boolean {
+ for (let index = messages.length - 1; index >= 0; index -= 1) {
+ const message = messages[index]
+
+ if (message.hidden) {
+ continue
+ }
+
+ if (message.role === 'user') {
+ return false
+ }
+
+ if (message.role === 'assistant' && (message.error || chatMessageText(message).trim())) {
+ return true
+ }
+ }
+
+ return false
+}
+
export interface UnspokenTurnSpeech {
/** First unspoken assistant bubble — stable for the turn, the live speech session binds to it. */
id: string
diff --git a/apps/desktop/src/store/agent-plugins.ts b/apps/desktop/src/store/agent-plugins.ts
index d043a5dd516..3dd96e0365e 100644
--- a/apps/desktop/src/store/agent-plugins.ts
+++ b/apps/desktop/src/store/agent-plugins.ts
@@ -251,6 +251,10 @@ export interface AgentPluginInstallResult {
pluginName?: string
warnings?: string[]
missingEnv?: string[]
+ /** Whether the install turned the plugin on (`enabled` in the backend result). */
+ enabled?: boolean
+ /** The `<namespace>:<skill>` names the model can now load (`activation.live_now.skills`). */
+ skillIds?: string[]
error?: string
/** What became usable in open chats of the profile (`activation.live_now`). */
live: AgentPluginLiveNow
@@ -299,6 +303,7 @@ export async function installAgentPlugin(
plugin_name?: string
warnings?: string[]
missing_env?: string[]
+ enabled?: boolean
activation?: {
live_now?: {
mcp_servers?: AgentPluginLiveServer[]
@@ -327,15 +332,19 @@ export async function installAgentPlugin(
return { ok: false, error: result?.error || 'Install failed', live: NO_LIVE, nextChat: false }
}
+ const liveSkills = result.activation?.live_now?.skills ?? []
+
return {
ok: true,
pluginName: result.plugin_name,
warnings: result.warnings,
missingEnv: result.missing_env,
+ enabled: result.enabled,
+ skillIds: liveSkills.map(skill => skill.name),
live: {
mcpServers: result.activation?.live_now?.mcp_servers ?? [],
// `<namespace>:<skill>` is what the model loads; the toast shows the skill's own name.
- skills: (result.activation?.live_now?.skills ?? []).map(skill => skill.name.split(':').pop() ?? skill.name)
+ skills: liveSkills.map(skill => skill.name.split(':').pop() ?? skill.name)
},
nextChat: Object.keys(result.activation?.deferred ?? {}).length > 0
}
diff --git a/apps/desktop/src/store/connection-request.ts b/apps/desktop/src/store/connection-request.ts
index b67b7ad9339..48f0621bbb7 100644
--- a/apps/desktop/src/store/connection-request.ts
+++ b/apps/desktop/src/store/connection-request.ts
@@ -131,7 +131,7 @@ export const $connectionRequests = atom<Record<string, ConnectionRequest>>({})
/** Settled operations the session's current one replaced, oldest first. Their cards stay drawn on the
* rows that opened them: every settled install card, and the last settled connect card when the current
* operation is an install one. A later connect operation still replaces the connect card, so consecutive
- * connect calls show one card. */
+ * connect calls show one card. `dropSessionState` clears a session's entries when its runtime ends. */
const $keptConnectionRequests = atom<Record<string, ConnectionRequest[]>>({})
/** The key a tool row's args carry its operation id under, written when `connection.request` arrives.
diff --git a/apps/desktop/src/store/session-states.ts b/apps/desktop/src/store/session-states.ts
index 1c5b76d3525..290275b37a6 100644
--- a/apps/desktop/src/store/session-states.ts
+++ b/apps/desktop/src/store/session-states.ts
@@ -33,7 +33,7 @@ import {
} from '@/components/pane-shell/tree/store'
import { resolveRememberedActivePane, workspaceScopeKey } from '@/components/pane-shell/workspace-scope'
import type { WorkspaceMode } from '@/contrib/types'
-import { type ChatMessage, chatMessageText, finalizeInterruptedMessages, sealOpenToolParts } from '@/lib/chat-messages'
+import { type ChatMessage, finalizeInterruptedMessages, sealOpenToolParts, turnHasReply } from '@/lib/chat-messages'
import type { ErrorSurface } from '@/lib/error-surface'
import { tileFocusStampOnFocusChange } from '@/lib/session-timer-since'
import { stableArray } from '@/lib/stable-array'
@@ -42,6 +42,7 @@ import type { SessionInfo } from '@/types/hermes'
import { dropStatusDrawersForProfile, migrateStatusDrawersForProfile } from './composer-status-drawer'
import { registryConnectionKind } from './connection-registry-state'
+import { clearConnectionRequest } from './connection-request'
import { recordDislike } from './desktop-metrics'
import { dialedGatewayModeFor } from './gateway'
import {
@@ -570,26 +571,6 @@ function settleEndedLiveTurn(runtimeId: string) {
const NO_REPLY_SURFACE: ErrorSurface = { code: 'no_reply', layer: 'runtime', retryable: true }
const NO_REPLY_ERROR = 'Hermes ended this turn without a reply.'
-function turnHasReply(messages: ChatMessage[]): boolean {
- for (let index = messages.length - 1; index >= 0; index -= 1) {
- const message = messages[index]
-
- if (message.hidden) {
- continue
- }
-
- if (message.role === 'user') {
- return false
- }
-
- if (message.role === 'assistant' && (message.error || chatMessageText(message).trim())) {
- return true
- }
- }
-
- return false
-}
-
function withNoReplyNotice(messages: ChatMessage[]): ChatMessage[] {
const last = messages.findLast(message => !message.hidden)
@@ -1046,6 +1027,8 @@ export function dropSessionState(runtimeId: string) {
clearWatchdog(runtimeId)
clearEventSilence(runtimeId)
clearSessionProviderWait(runtimeId)
+ // Connection cards (the open one and every settled install card) are keyed by the runtime id.
+ clearConnectionRequest(undefined, runtimeId)
sessionScopeByRuntimeId.delete(runtimeId)
sessionOwnerByRuntimeId.delete(runtimeId)
// A runtime that never bound a stored id never will now (#73890).
@@ -1083,6 +1066,7 @@ export function clearAllSessionStates() {
settledExpiry.clear()
unconfirmedReconnectSettles.clear()
clearAllProviderWaits()
+ clearConnectionRequest()
sessionScopeByRuntimeId.clear()
sessionOwnerByRuntimeId.clear()
forgetPendingRuntimeTabs()
diff --git a/hermes_cli/plugins_cmd_install.py b/hermes_cli/plugins_cmd_install.py
index 8ed89e320e3..b3b529b32d9 100644
--- a/hermes_cli/plugins_cmd_install.py
+++ b/hermes_cli/plugins_cmd_install.py
@@ -719,17 +719,21 @@ class InstallPhase(StrEnum):
loading_tools = "loading_tools"
-def _catalog_install_on_disk(catalog_name: str) -> Optional[tuple]:
+def _catalog_install_on_disk(catalog_name: str, ref: Optional[str]) -> Optional[tuple]:
"""``(target, manifest, installed_name)`` of the installed, not enabled tree whose install record
names catalog entry *catalog_name*, else None. A refused enable leaves the published clone in
place (there is no rollback), so the card's Try again, or the model asking again, stopped at
- "already exists" on a second clone and the plugin could never be turned on from the card."""
+ "already exists" on a second clone and the plugin could never be turned on from the card.
+ Like ``hermes plugins enable``, the tree is used at the commit it has; an explicit *ref* only
+ matches a tree checked out at that commit."""
enabled = _pc()._get_enabled_set()
for key, record in _pc()._read_install_metadata().items():
block = record.get("catalog") if isinstance(record, dict) else None
target = _pc()._plugins_dir() / key
if not (isinstance(block, dict) and block.get("name") == catalog_name and target.is_dir()):
continue
+ if ref and str(block.get("sha") or "").lower() != ref.lower():
+ return None
manifest = _pc()._read_manifest(target)
installed_name = manifest.get("name") or target.name
return None if {installed_name, target.name} & enabled else (target, manifest, installed_name)
@@ -765,18 +769,19 @@ def _resolve_source(identifier: str, catalog_name: Optional[str]) -> tuple:
def _place_tree(entry, identifier: str, *, force: bool, ref: Optional[str], assume_deps_consent: bool,
step: Callable[[InstallPhase], None]) -> tuple | dict:
"""``(target, manifest, installed_name)`` of the tree to enable, or the error result. A catalog
- entry already on disk and not enabled (an earlier enable was refused) is used as it is."""
+ entry already on disk and not enabled (an earlier enable was refused) is used as it is, unless
+ an approved *ref* names another commit; a fresh install clones at *ref* when set, else the pin."""
from hermes_cli import plugins_cmd_catalog as catalog
- on_disk = _catalog_install_on_disk(entry.name) if entry is not None and not force else None
+ ref = (ref or "").strip() or None
+ on_disk = _catalog_install_on_disk(entry.name, ref) if entry is not None and not force else None
if on_disk is not None:
return on_disk
def _install() -> tuple:
if entry is not None:
- return catalog.install_catalog_entry(entry, force=force, allow_removed=False,
+ return catalog.install_catalog_entry(entry, force=force, ref=ref, allow_removed=False,
assume_deps_consent=assume_deps_consent)
- return _pc()._install_plugin_core(identifier, force=force, ref=(ref or "").strip() or None,
- assume_deps_consent=assume_deps_consent)
+ return _pc()._install_plugin_core(identifier, force=force, ref=ref, assume_deps_consent=assume_deps_consent)
step(InstallPhase.downloading)
try:
@@ -816,7 +821,7 @@ def dashboard_install_plugin(
on_step: Optional[Callable[[InstallPhase], None]] = None,
) -> dict[str, Any]:
"""Non-interactive install for the dashboard/TUI. *catalog_name* installs a curated entry at its
- pinned SHA (identifier may be empty); *ref* pins a custom source to one full commit SHA (same
+ pinned SHA (identifier may be empty); *ref* pins either source to one full commit SHA (same
contract as ``--ref``); every path enforces the kill list (no GUI bypass). *assume_deps_consent*
is consent the caller holds for the Python deps, so no terminal is needed to answer the gate.
None (a user's Install click) is the consent the fresh-install enable already acts on: a plugin