Skip to content

The agent that grows with you

Merge remote-tracking branch 'origin/main' into merge/main-into-local-models

emozillaf6bfcb973ce5
diff --cc apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts
index e15f9e2f022,0af663741b8..071a093085f
--- a/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts
+++ b/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts
@@@ -24,10 -28,15 +28,16 @@@ import
setPrimaryGateway,
touchSecondaryGateways
} from '@/store/gateway'
+ import { registerGatewayReconnect } from '@/store/gateway-reconnect'
import { $gatewaySwitching, wipeSessionListsForGatewaySwitch } from '@/store/gateway-switch'
+import { checkLocalRuntimeUpdate, watchLocalRuntimeJobs } from '@/store/local-runtime-jobs'
import { notify, notifyError } from '@/store/notifications'
- import { $activeGatewayProfile, normalizeProfileKey, touchActiveGatewayBackend } from '@/store/profile'
+ import {
+ $activeGatewayProfile,
+ normalizeProfileKey,
+ refreshActiveProfile,
+ touchActiveGatewayBackend
+ } from '@/store/profile'
import {
$activeSessionId,
$connection,
diff --cc apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx
index c1b1a37c4a4,98fd2dce5e8..a673027cdb0
--- a/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx
+++ b/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx
@@@ -5,7 -5,7 +5,8 @@@ import type { CommandCenterSection } fr
import { useApprovalModeStatusbarItem } from '@/app/shell/approval-mode-menu'
import { ContextUsagePanel } from '@/app/shell/context-usage-panel'
import { GatewayMenuPanel } from '@/app/shell/gateway-menu-panel'
+ import { useContextBreakdown } from '@/app/shell/hooks/use-context-breakdown'
+import { useSystemResourcesStatusbarItem } from '@/app/shell/system-resources-statusbar'
import { $paneVisible, togglePaneVisible } from '@/components/pane-shell/tree/store'
import { Codicon } from '@/components/ui/codicon'
import { GlyphSpinner } from '@/components/ui/glyph-spinner'
@@@ -224,18 -224,46 +225,47 @@@ export function useStatusbarItems(
? focusedRowStartedAt * 1000
: null
- const contextUsage = useMemo(() => usageContextLabel(currentUsage), [currentUsage])
- const contextBar = useMemo(() => contextBarLabel(currentUsage), [currentUsage])
+ // The backend only knows a session's MEASURED occupancy once a turn has run
+ // in this process, so a resumed conversation reports none and the gauge had
+ // nothing to paint — turning it on looked like it did nothing until you sent
+ // a message. Estimate from the live prompt + transcript instead, on the same
+ // read-only RPC the popover uses, so the readout is right the moment it's on
+ // screen. Gated on the gauge being shown — the bar itself is unmounted while
+ // toggled off, so this covers the rest.
+ const contextItemHidden = useStore($statusbarHiddenIds).includes('context-usage')
+
+ const { breakdown: contextBreakdown, loading: contextBreakdownLoading } = useContextBreakdown({
+ busy,
+ enabled: !contextItemHidden,
+ requestGateway,
+ sessionId: activeSessionId
+ })
- const publishContextUsage = useCallback(
- (snapshot: Pick<UsageStats, 'context_max' | 'context_percent' | 'context_used'>) => {
- setCurrentUsage(current => ({ ...current, ...snapshot }))
- },
- []
+ // The breakdown wins whenever we have one, for two reasons: it reports the
+ // MEASURED occupancy once the backend has it (falling back to the estimate
+ // only before that), and it is keyed to the session it describes. The global
+ // `$currentUsage` is neither — a resumed session reports no context fields,
+ // and the store merges rather than replaces, so the PREVIOUS session's gauge
+ // numbers survive the switch. Mid-turn there's no breakdown by design and
+ // the streamed usage carries the gauge.
+ const gaugeUsage = useMemo<UsageStats>(
+ () =>
+ contextBreakdown
+ ? {
+ ...currentUsage,
+ context_max: contextBreakdown.context_max,
+ context_percent: contextBreakdown.context_percent,
+ context_used: contextBreakdown.context_used
+ }
+ : currentUsage,
+ [contextBreakdown, currentUsage]
)
+ const contextUsage = useMemo(() => usageContextLabel(gaugeUsage), [gaugeUsage])
+ const contextBar = useMemo(() => contextBarLabel(gaugeUsage), [gaugeUsage])
+
const approvalModeItem = useApprovalModeStatusbarItem(activeGatewayProfile, requestGateway)
+ const systemResourcesItem = useSystemResourcesStatusbarItem()
const gatewayMenuContent = useMemo(
() => (close: () => void) => (
@@@ -583,14 -603,13 +609,14 @@@
chatOpen,
clientVersionItem,
contextBar,
+ contextBreakdown,
+ contextBreakdownLoading,
contextUsage,
copy,
- currentUsage,
- publishContextUsage,
- requestGateway,
+ gaugeUsage,
sessionStartedAt,
gatewayState,
+ systemResourcesItem,
terminalShowing,
turnStartedAt
]
diff --cc apps/desktop/src/i18n/en.ts
index eb135c19e48,5b9c56a8c19..df44f96c47c
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@@ -343,8 -355,7 +355,8 @@@ export const en: Translations =
providerAccounts: 'Accounts',
providerApiKeys: 'API keys',
providerCustomEndpoints: 'Custom Endpoints',
+ providerLocalModels: 'Local Models',
- gateway: 'Gateway',
+ gateway: 'Gateways',
apiKeys: 'Tools & Keys',
keybinds: 'Keyboard Shortcuts',
keysTools: 'Tools',
diff --cc contributors/emails/[email protected]
index 850e0a4eb07,850e0a4eb07..73bf022af1b
--- a/contributors/emails/[email protected]
+++ b/contributors/emails/[email protected]
@@@ -1,1 -1,1 +1,1 @@@
--momomojo
++skip-agent
diff --cc hermes_cli/config_defaults.py
index 94581abf7fa,29ae25d7f70..da6dba669fb
--- a/hermes_cli/config_defaults.py
+++ b/hermes_cli/config_defaults.py
@@@ -3356,31 -3556,8 +3556,31 @@@ DEFAULT_CONFIG =
"region": "global",
},
+ # Managed llama.cpp local runtime (see docs: user-guide/local-models).
+ # Hermes downloads official llama.cpp release binaries, then spawns and
+ # supervises one llama-server in router mode. Context sizing is policy,
+ # not preference: there are deliberately no context/VRAM knobs here.
+ "local_runtime": {
+ # Master switch for the managed runtime. Off = detection-only
+ # (Hermes still finds an external llama-server you run yourself).
+ "enabled": False,
+ # Pinned llama.cpp release tag (rolling bNNNN). Bumped by Hermes
+ # releases after the validation suite re-runs, not tracked live.
+ "tag": "b10362",
+ # Inference backend: auto = CUDA on NVIDIA, Metal on macOS, Vulkan on
+ # other GPUs, else CPU. Explicit values: cuda|metal|vulkan|hip|cpu.
+ "backend": "auto",
+ # Router process: how many models may be resident at once.
+ "models_max": 4,
+ # Port for the managed server. 0 = pick a free port at spawn.
+ "port": 0,
+ # Extra ports detection probes for an external llama-server, in
+ # addition to the default 8080.
+ "detect_ports": [],
+ },
+
# Config schema version - bump this when adding new required fields
- "_config_version": 34,
+ "_config_version": 37,
}
# Optional environment variables that enhance functionality
diff --cc hermes_cli/web_server.py
index 7b775602b28,edc62c8c52e..b515a8c3c87
--- a/hermes_cli/web_server.py
+++ b/hermes_cli/web_server.py
@@@ -303,16 -433,6 +455,14 @@@ async def _lifespan(app: "FastAPI")
selftest_task.cancel()
auto_archive_task.cancel()
await PTY_REGISTRY.close_all()
- if cron_stop is not None:
- cron_stop.set()
+ # Stop the managed llama-server with its parent — a supervisor-less
+ # orphan would keep VRAM pinned after the app closes.
+ try:
+ from hermes_cli.local_runtime.bootstrap import shutdown_local_runtime
+
+ shutdown_local_runtime()
+ except Exception: # noqa: BLE001
+ pass
if os.getenv("HERMES_DESKTOP") == "1":
_terminate_desktop_managed_gateway()