mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-14 09:11:54 +00:00
* fix(desktop): unify dialog/overlay buttons on shared Button component
Replace raw <button> action/text controls across the modal layer (boot
failure, install, update, onboarding, clarify, model-visibility,
notifications, gateway menu) with the shared Button + its variants
(text / ghost / icon-xs). Drops the bespoke square-cornered styling so
every dialog matches the app's slightly-rounded button system, and
swaps clarify-tool's hardcoded "Skip" for the existing i18n string.
* feat(desktop): add dev-only dialog gallery for auditing overlays
A code-split, DEV-gated harness (toggle ⌘/Ctrl+Alt+Shift+D) that triggers
every dialog/overlay so their buttons can be eyeballed in one place:
store-driven overlays (boot failure, updates, notifications, sudo/secret)
plus in-place dialogs (confirm, profile create/rename, attach-url, model
picker/visibility, clarify, tool approval). Never ships to production.
* fix(desktop): use Ctrl+Shift+D for dialog gallery (mac-friendly)
The Cmd/Ctrl+Alt+Shift+D chord is impractical on macOS (Option mangles
the keypress). Ctrl+Shift+D is the same chord on every platform and uses
neither Cmd nor Option.
* fix(desktop): stop overriding button icon size to size-4
Action buttons hardcoded size-4 icons, overriding the Button component's
built-in size-3.5. That extra 2px is why boot-failure / onboarding / gateway
buttons looked chunkier than the settings "Apply" (size-3.5 spinner) despite
being the same component+size. Drop the overrides so icons inherit 3.5.
* feat(desktop): add BrandMark, use it in the updates overlay hero
New BrandMark renders the white logo.png on a hardcoded brand-blue tile
(#0000F2 light / #222 dark), replacing the generic Sparkles hero glyph in
the "update available" overlay. Trying it here first to iterate on the look.
NOTE: apps/desktop/public/logo.png is currently a 1x1 placeholder — the tile
renders now; the glyph appears once the real white logo art is dropped in.
* feat(desktop): add real logo.png asset, render it white in BrandMark
logo.png is blue line-art on transparent, so force it white via filter to
read on both the brand-blue (#0000F2) and near-black (#222) tiles. Bump the
glyph to 62% of the tile for the portrait aspect.
* fix(desktop): BrandMark renders logo as-is, no light bg/radius/padding
Drop the white filter, the hardcoded light-mode blue tile, the radius, and
the inner padding. Logo now fills the tile over a transparent surface in
light mode; dark keeps the #222 tile.
* fix(desktop): bump updates-overlay BrandMark to size-16
* feat(desktop): use downscaled karb.webp in BrandMark
Swap the BrandMark glyph to karb.webp, downscaled from 1129x1418/888KB to
254x320/81KB for the hero badge.
* feat(desktop): use nous-girl mark in BrandMark, invert in dark
Key the white background to transparent so only the black line-art remains
(384px/20KB webp). Light mode shows black art; dark mode flips it white via
dark:invert on the #222 tile. Drop the now-unused karb.webp and logo.png.
* fix(desktop): BrandMark uses nous-girl as-is (no transparent/invert)
The dark-mode invert read as a creepy negative. Use the opaque black-on-white
mark unchanged in both themes; drop the white-key, dark:invert, and #222 tile.
* fix(desktop): give BrandMark an explicit white bg tile
* fix(desktop): use nous-girl.jpg directly in BrandMark
* perf(desktop): downscale nous-girl.jpg to 256x256 (466KB -> 19KB)
* style(desktop): bump nous light --theme-secondary to 14% blue
* fix(desktop): outline button is transparent, not chrome-filled
The outline variant used bg-background (the chrome color), so on cards/overlays
with a different surface it rendered as an odd gray-blue fill (visible on the
boot overlay's Repair install / Use local gateway). Make it bg-transparent so
it inherits the surface like a real outline. Reverts the unrelated
--theme-secondary tweak.
* fix(desktop): clean outline button — thin border, no shadow/fill
Drop shadow-xs and the resting fills (light chrome bg, dark bg-input/30) so
outline is just a thin clean border with a subtle hover, in both themes.
* fix(desktop): stop forcing tertiary bg on outline buttons
A global [data-variant='outline'] rule set background: var(--ui-bg-tertiary),
which (attribute-selector specificity) overrode the cva bg-transparent — so
outline buttons always showed the pale tertiary fill on cards/overlays
regardless of the variant classes. Scope that fill to secondary only; outline
is now a true transparent border.
* style(desktop): unified overlay design system + restore #38631 flat-UI
Overlays/dialogs/toasts share a custom shadow-nous (downward-weighted) and
--stroke-nous hairline instead of hard borders: boot-failure, install,
notifications, model-picker, onboarding, prompt-overlays, updates, Dialog.
- button: outline is a 1px inset ring (no fill/shadow); chrome lives in Button
- BrandMark: 256px nous-girl mark replaces sparkle glyphs (updates/onboarding/about)
- onboarding: conditional header, lemniscate-bloom loaders, OTP device-code boxes,
NOUS CONNECTED hero (ascii decode) + cuneiform easter egg, "Begin" matrix exit
- shared LogView + ErrorState; math/ascii loaders over "Loading..." text
- appearance-settings flattened to SegmentedControl/ListRow; keybind-panel on
shadow-nous + text-variant reset
- restore flat-UI clobbered by #38631's stale-squash (4a1907bd1): command-center,
profiles, skills, messaging, cron de-boxed; shared SearchField + PAGE_INSET_X;
profiles back on OverlaySplitLayout; skills tabs+search one row, no row dividers
* refactor(desktop): clean pass — drop dead code, dedupe, fix stale docs
- log-view: drop unused `bare` prop + forwardRef (no caller uses ref)
- install-overlay: drop `stateOverride` (only the removed dev gallery used it)
- profiles: ProfilesViewProps down to { onClose } (drop vestigial section/titlebar)
- onboarding: hoist shared PROVIDER_ROW_CLASS (was duplicated 2x)
- brand-mark / error-state: tighten comments, fix stale AlertCircle reference
340 lines
12 KiB
TypeScript
340 lines
12 KiB
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
import { useState } from 'react'
|
|
|
|
import { useI18n } from '@/i18n'
|
|
import type { ModelOptionProvider, ModelOptionsResponse, ModelPricing } from '@/types/hermes'
|
|
|
|
import type { HermesGateway } from '../hermes'
|
|
import { getGlobalModelOptions } from '../hermes'
|
|
import { cn } from '../lib/utils'
|
|
import { startManualOnboarding } from '../store/onboarding'
|
|
|
|
import { InlineNotice } from './notifications'
|
|
import { Button } from './ui/button'
|
|
import { Checkbox } from './ui/checkbox'
|
|
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from './ui/command'
|
|
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from './ui/dialog'
|
|
import { Skeleton } from './ui/skeleton'
|
|
|
|
interface ModelPickerDialogProps {
|
|
open: boolean
|
|
onOpenChange: (open: boolean) => void
|
|
gw?: HermesGateway
|
|
sessionId?: string | null
|
|
currentModel: string
|
|
currentProvider: string
|
|
onSelect: (selection: { provider: string; model: string; persistGlobal: boolean }) => void
|
|
/**
|
|
* Optional class to apply to DialogContent. Use to override z-index when
|
|
* stacking the picker on top of another fixed overlay (e.g. the desktop
|
|
* onboarding overlay, which sits at z-1300; the default Dialog z-130 ends
|
|
* up rendering underneath and blocks pointer events).
|
|
*/
|
|
contentClassName?: string
|
|
}
|
|
|
|
export function ModelPickerDialog({
|
|
open,
|
|
onOpenChange,
|
|
gw,
|
|
sessionId,
|
|
currentModel,
|
|
currentProvider,
|
|
onSelect,
|
|
contentClassName
|
|
}: ModelPickerDialogProps) {
|
|
const { t } = useI18n()
|
|
const copy = t.modelPicker
|
|
const [persistGlobal, setPersistGlobal] = useState(!sessionId)
|
|
// Own the search term so we can filter manually. cmdk's built-in
|
|
// shouldFilter reorders items by its fuzzy-match score (≈alphabetical with
|
|
// an empty query), which destroys the backend's curated order. We disable
|
|
// it and do a plain substring filter that preserves array order — matching
|
|
// the `hermes model` CLI picker, which shows the curated list verbatim.
|
|
const [search, setSearch] = useState('')
|
|
|
|
const modelOptions = useQuery({
|
|
queryKey: ['model-options', sessionId || 'global'],
|
|
queryFn: () => {
|
|
if (gw && sessionId) {
|
|
return gw.request<ModelOptionsResponse>('model.options', {
|
|
session_id: sessionId
|
|
})
|
|
}
|
|
|
|
return getGlobalModelOptions()
|
|
},
|
|
enabled: open
|
|
})
|
|
|
|
const providers = modelOptions.data?.providers ?? []
|
|
const optionsModel = String(modelOptions.data?.model ?? currentModel ?? '')
|
|
const optionsProvider = String(modelOptions.data?.provider ?? currentProvider ?? '')
|
|
const loading = modelOptions.isPending && !modelOptions.data
|
|
|
|
const error = modelOptions.error
|
|
? modelOptions.error instanceof Error
|
|
? modelOptions.error.message
|
|
: String(modelOptions.error)
|
|
: null
|
|
|
|
const selectModel = (provider: ModelOptionProvider, model: string) => {
|
|
onSelect({
|
|
provider: provider.slug,
|
|
model,
|
|
persistGlobal: persistGlobal || !sessionId
|
|
})
|
|
onOpenChange(false)
|
|
}
|
|
|
|
// Open the full onboarding provider selector to add/switch a provider.
|
|
// Reuses the entire onboarding flow (OAuth rows, API-key form, device-code,
|
|
// model-confirm) instead of duplicating provider UI here. Closes the picker
|
|
// so the onboarding overlay (z-1300) isn't rendered underneath it.
|
|
const addProvider = () => {
|
|
startManualOnboarding()
|
|
onOpenChange(false)
|
|
}
|
|
|
|
return (
|
|
<Dialog onOpenChange={onOpenChange} open={open}>
|
|
<DialogContent className={cn('max-h-[85vh] max-w-2xl gap-0 overflow-hidden p-0', contentClassName)}>
|
|
<DialogHeader className="border-b border-border px-4 py-3">
|
|
<DialogTitle>{copy.title}</DialogTitle>
|
|
<DialogDescription className="font-mono text-xs leading-relaxed">
|
|
{copy.current} {optionsModel || currentModel || copy.unknown}
|
|
{optionsProvider || currentProvider ? ` · ${optionsProvider || currentProvider}` : ''}
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
|
|
<Command className="rounded-none bg-card" shouldFilter={false}>
|
|
<CommandInput
|
|
autoFocus
|
|
onValueChange={setSearch}
|
|
placeholder={copy.search}
|
|
value={search}
|
|
/>
|
|
<CommandList className="max-h-96">
|
|
{!loading && !error && <CommandEmpty>{copy.noModels}</CommandEmpty>}
|
|
<ModelResults
|
|
currentModel={optionsModel || currentModel}
|
|
currentProvider={optionsProvider || currentProvider}
|
|
error={error}
|
|
loading={loading}
|
|
onSelectModel={selectModel}
|
|
providers={providers}
|
|
search={search}
|
|
/>
|
|
</CommandList>
|
|
</Command>
|
|
|
|
<DialogFooter className="flex-row items-center justify-between gap-3 bg-card p-3 sm:justify-between">
|
|
<label className="flex cursor-pointer select-none items-center gap-2 text-xs text-muted-foreground">
|
|
<Checkbox
|
|
checked={persistGlobal || !sessionId}
|
|
disabled={!sessionId}
|
|
onCheckedChange={checked => setPersistGlobal(checked === true)}
|
|
/>
|
|
{sessionId ? copy.persistGlobalSession : copy.persistGlobal}
|
|
</label>
|
|
|
|
<div className="flex items-center gap-2">
|
|
<Button onClick={addProvider} variant="ghost">
|
|
{copy.addProvider}
|
|
</Button>
|
|
<Button onClick={() => onOpenChange(false)} variant="outline">
|
|
{t.common.cancel}
|
|
</Button>
|
|
</div>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
)
|
|
}
|
|
|
|
function ModelResults({
|
|
loading,
|
|
error,
|
|
providers,
|
|
currentModel,
|
|
currentProvider,
|
|
onSelectModel,
|
|
search
|
|
}: {
|
|
loading: boolean
|
|
error: string | null
|
|
providers: ModelOptionProvider[]
|
|
currentModel: string
|
|
currentProvider: string
|
|
onSelectModel: (provider: ModelOptionProvider, model: string) => void
|
|
search: string
|
|
}) {
|
|
const { t } = useI18n()
|
|
const copy = t.modelPicker
|
|
|
|
if (loading) {
|
|
return <LoadingResults />
|
|
}
|
|
|
|
if (error) {
|
|
return (
|
|
<div className="px-3 py-3">
|
|
<InlineNotice kind="error" title={copy.loadFailed}>
|
|
{error}
|
|
</InlineNotice>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (providers.length === 0) {
|
|
return <div className="px-4 py-6 text-sm text-muted-foreground">{copy.noAuthenticatedProviders}</div>
|
|
}
|
|
|
|
const q = search.trim().toLowerCase()
|
|
|
|
const matches = (provider: ModelOptionProvider, model: string) =>
|
|
!q ||
|
|
model.toLowerCase().includes(q) ||
|
|
provider.name.toLowerCase().includes(q) ||
|
|
provider.slug.toLowerCase().includes(q)
|
|
|
|
// Only configured providers (those with curated models) are selectable
|
|
// here. Switching to a NOT-yet-configured provider goes through the
|
|
// "Add provider" footer button, which opens the full onboarding selector.
|
|
const configured = providers.filter(p => (p.models ?? []).length > 0)
|
|
|
|
return (
|
|
<>
|
|
{configured.map(provider => {
|
|
// Preserve the backend's curated order — filter in place, no re-sort.
|
|
const models = (provider.models ?? []).filter(m => matches(provider, m))
|
|
|
|
if (models.length === 0) {
|
|
return null
|
|
}
|
|
|
|
const unavailable = new Set(provider.unavailable_models ?? [])
|
|
|
|
return (
|
|
<CommandGroup heading={<ProviderHeading provider={provider} />} key={provider.slug}>
|
|
{provider.warning && (
|
|
<div className="px-2 pb-2">
|
|
<InlineNotice className="px-2.5 py-1.5 text-xs" kind="warning">
|
|
{provider.warning}
|
|
</InlineNotice>
|
|
</div>
|
|
)}
|
|
{models.map(model => {
|
|
const isCurrent = model === currentModel && provider.slug === currentProvider
|
|
const price = provider.pricing?.[model]
|
|
const locked = unavailable.has(model)
|
|
|
|
return (
|
|
<CommandItem
|
|
className={cn(
|
|
'flex items-center gap-2 pl-6 font-mono',
|
|
isCurrent &&
|
|
'bg-primary text-primary-foreground data-[selected=true]:bg-primary data-[selected=true]:text-primary-foreground',
|
|
locked && 'cursor-not-allowed opacity-45'
|
|
)}
|
|
disabled={locked}
|
|
key={`${provider.slug}:${model}`}
|
|
onSelect={() => {
|
|
if (!locked) {
|
|
onSelectModel(provider, model)
|
|
}
|
|
}}
|
|
value={`${provider.slug}:${model}`}
|
|
>
|
|
<span className="min-w-0 flex-1 truncate">{model}</span>
|
|
{locked && <span className="shrink-0 text-[0.62rem] uppercase tracking-wide opacity-80">{copy.pro}</span>}
|
|
<ModelPrice isCurrent={isCurrent} price={price} />
|
|
</CommandItem>
|
|
)
|
|
})}
|
|
{unavailable.size > 0 && (
|
|
<div className="px-6 pb-2 pt-1 text-[0.62rem] leading-relaxed text-muted-foreground">
|
|
{copy.proNeedsSubscription}
|
|
</div>
|
|
)}
|
|
</CommandGroup>
|
|
)
|
|
})}
|
|
</>
|
|
)
|
|
}
|
|
|
|
// Compact In/Out $/Mtok price tag, mirroring the CLI picker's price columns.
|
|
// Renders nothing when pricing is unavailable for the model.
|
|
function ModelPrice({ price, isCurrent }: { price?: ModelPricing; isCurrent: boolean }) {
|
|
const { t } = useI18n()
|
|
const copy = t.modelPicker
|
|
|
|
if (!price || (!price.input && !price.output)) {
|
|
return null
|
|
}
|
|
|
|
if (price.free) {
|
|
return (
|
|
<span
|
|
className={cn(
|
|
'shrink-0 rounded-sm px-1 py-0.5 text-[0.62rem] font-semibold uppercase tracking-wide',
|
|
isCurrent ? 'bg-primary-foreground/20' : 'bg-emerald-500/15 text-emerald-600 dark:text-emerald-400'
|
|
)}
|
|
>
|
|
{copy.free}
|
|
</span>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<span
|
|
className={cn(
|
|
'shrink-0 text-[0.66rem] tabular-nums',
|
|
isCurrent ? 'text-primary-foreground/80' : 'text-muted-foreground'
|
|
)}
|
|
title={copy.priceTitle}
|
|
>
|
|
{price.input || '?'} / {price.output || '?'}
|
|
</span>
|
|
)
|
|
}
|
|
|
|
function LoadingResults() {
|
|
return (
|
|
<CommandGroup heading={<Skeleton className="h-3 w-32" />}>
|
|
{Array.from({ length: 4 }, (_, rowIndex) => (
|
|
<div className="rounded-sm py-1.5 pl-6 pr-2" key={rowIndex}>
|
|
<Skeleton className={cn('h-5', rowIndex % 3 === 0 ? 'w-3/5' : rowIndex % 3 === 1 ? 'w-4/5' : 'w-1/2')} />
|
|
</div>
|
|
))}
|
|
</CommandGroup>
|
|
)
|
|
}
|
|
|
|
function ProviderHeading({ provider }: { provider: ModelOptionProvider }) {
|
|
const { t } = useI18n()
|
|
const copy = t.modelPicker
|
|
|
|
// free_tier is only set for Nous. true → "Free tier", false → "Pro".
|
|
const tierBadge =
|
|
provider.free_tier === true ? (
|
|
<span className="rounded-sm bg-emerald-500/15 px-1 py-0.5 text-[0.6rem] font-semibold uppercase tracking-wide text-emerald-600 dark:text-emerald-400">
|
|
{copy.freeTier}
|
|
</span>
|
|
) : provider.free_tier === false ? (
|
|
<span className="rounded-sm bg-primary/15 px-1 py-0.5 text-[0.6rem] font-semibold uppercase tracking-wide text-primary">
|
|
{copy.pro}
|
|
</span>
|
|
) : null
|
|
|
|
return (
|
|
<span className="flex min-w-0 items-center gap-2">
|
|
<span className="truncate">{provider.name}</span>
|
|
<span className="font-mono text-xs font-normal normal-case tracking-normal text-muted-foreground">
|
|
{provider.slug} · {provider.total_models ?? provider.models?.length ?? 0}
|
|
</span>
|
|
{tierBadge}
|
|
</span>
|
|
)
|
|
}
|