feat(ui): display names for VMs and a side-by-side summary on wide windows

- The VM note now acts as its display name: shown as the page title and in
  the sidebar, renamed in place by clicking the title (or More → Change
  Display Name…). The VM name stays the identifier for folders, CLI and
  reims-ctl; it shows in the title's tooltip and in Technical details.
  Clearing the field or typing the VM name removes the display name.
- When the content column is at least 760 px wide (container query), the
  screen and actions sit on the left and the summary becomes one labelled
  column on the right, so long GPU names are no longer cut off. Narrower
  windows keep the stacked layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NwflowerandClaude Opus 5.5 committed 2026-11-29 04:34:53 -07:00
1 parent ab49d79a71
commit 704f68cdce
5 files changed
+148 -70

No files matched your search

+4 -2
View File
@@ -18,6 +18,8 @@ interface Props {
selected: string
hostReady: boolean
onSelect: (id: string) => void
/** VM name → display name (its note); empty or missing shows the name. */
displayNames?: Record<string, string>
/** Double-click on a VM: its main action (start, or show its window). */
onActivate?: (name: string) => void
onNew: () => void
@@ -47,7 +49,7 @@ function useVMIcons(vms: VMListItem[], transitions: Record<string, string>) {
}
export const Sidebar: React.FC<Props> = ({
locale, vms, transitions, selected, hostReady, onSelect, onActivate, onNew, onVMContextAction, downloading,
locale, vms, transitions, selected, hostReady, onSelect, displayNames = {}, onActivate, onNew, onVMContextAction, downloading,
}) => {
const tr = (k: I18nKey) => t(locale, k)
const listRef = useRef<HTMLDivElement>(null)
@@ -116,7 +118,7 @@ export const Sidebar: React.FC<Props> = ({
const src = icons[vm.name]
const trigger = navBtn(
vm.name,
vm.name,
displayNames[vm.name] || vm.name,
src ? <img src={src} alt="" draggable={false} /> : <Monitor size={13} />,
src ? 'nav-icon-thumb' : 'nav-icon-vm',
t(locale, `state_${st}` as I18nKey),
+78 -52
View File
@@ -79,7 +79,11 @@ export const PRIMARY_SHORTCUT = 'Ctrl+Enter'
interface Props {
locale: Locale
/** The VM's identifier (folder, CLI, reims-ctl). */
name: string
/** What the user calls it (its note); empty shows `name`. */
displayName: string
onDisplayNameSaved: (displayName: string) => void
state: string
detail: VMDetail | null
stats: VMStats | null
@@ -107,6 +111,8 @@ const clampPct = (v: number) => Math.min(100, Math.max(0, v))
interface Spec {
key: string
/** Shown only in the wide, single-column layout. */
label: string
icon: React.ReactNode
value: string
tip: string
@@ -115,7 +121,7 @@ interface Spec {
}
export const VMPage: React.FC<Props> = ({
locale, name, state, detail, stats, host, pending, busyAction, onAction, onSettings, onOpenAffinity, onDelete, onViewLogs, onCopy, onTypeText, onTogglePreventSleep, onDeliverFile, onToast, onError, dropping,
locale, name, displayName, onDisplayNameSaved, state, detail, stats, host, pending, busyAction, onAction, onSettings, onOpenAffinity, onDelete, onViewLogs, onCopy, onTypeText, onTogglePreventSleep, onDeliverFile, onToast, onError, dropping,
}) => {
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
const busy = busyAction !== undefined
@@ -138,23 +144,25 @@ export const VMPage: React.FC<Props> = ({
return () => { live = false; if (timer) window.clearInterval(timer) }
}, [name, running])
// Optional single-line VM note (.reims-go-note)
const [note, setNote] = useState('')
const [editingNote, setEditingNote] = useState(false)
const [noteDraft, setNoteDraft] = useState('')
useEffect(() => {
let live = true
setEditingNote(false)
api.GetVMNote(name).then((n) => { if (live) setNote(n ?? '') }).catch(() => { if (live) setNote('') })
return () => { live = false }
}, [name])
const saveNote = async () => {
const cleaned = noteDraft.trim()
setEditingNote(false)
if (cleaned === note) return
// Display name, stored as the VM's note (.reims-go-note). Clicking the title
// edits it in place; clearing it (or typing the name) falls back to the name.
const shownName = displayName || name
const [editingName, setEditingName] = useState(false)
const [nameDraft, setNameDraft] = useState('')
useEffect(() => { setEditingName(false) }, [name])
const startRename = () => { setNameDraft(shownName); setEditingName(true) }
// From the More menu: keep the menu from pulling focus back to its button,
// which would blur (and so save) the name field the moment it appears.
const renameFromMenu = useRef(false)
const nameInputRef = useRef<HTMLInputElement>(null)
const saveName = async () => {
setEditingName(false)
let next = nameDraft.trim()
if (next === name) next = ''
if (next === displayName) return
try {
await api.SetVMNote(name, cleaned)
setNote(cleaned)
await api.SetVMNote(name, next)
onDisplayNameSaved(next)
} catch (e) {
onError(tr('failGeneric'), e)
}
@@ -326,7 +334,18 @@ export const VMPage: React.FC<Props> = ({
</Menu.Trigger>
</Tip>
<Menu.Portal>
<Menu.Content className="menu" align="end" sideOffset={4} collisionPadding={8}>
<Menu.Content
className="menu"
align="end"
sideOffset={4}
collisionPadding={8}
onCloseAutoFocus={(e) => {
if (!renameFromMenu.current) return
renameFromMenu.current = false
e.preventDefault()
nameInputRef.current?.focus()
}}
>
{running && (
<>
<Menu.Item className="menu-item" disabled={busy} onSelect={() => onAction('restart')}>
@@ -363,6 +382,9 @@ export const VMPage: React.FC<Props> = ({
<Menu.Item className="menu-item" onSelect={onOpenAffinity}>
<Cpu size={14} /> {tr('affinityMenu')}
</Menu.Item>
<Menu.Item className="menu-item" onSelect={() => { renameFromMenu.current = true; startRename() }}>
<Pencil size={14} /> {tr('displayNameEditEllipsis')}
</Menu.Item>
<Menu.Separator className="menu-sep" />
</>
)}
@@ -404,17 +426,17 @@ export const VMPage: React.FC<Props> = ({
specs.push(
{
key: 'cpu', icon: <Cpu size={15} aria-hidden="true" />, value: tr('cores', { n: detail.cpus }),
key: 'cpu', label: tr('factCPU'), icon: <Cpu size={15} aria-hidden="true" />, value: tr('cores', { n: detail.cpus }),
tip: live ? tr('specCPULiveTip', { n: detail.cpus, pct: Math.round(cpuPct) }) : tr('specCPUTip', { n: detail.cpus }),
meter: { pct: cpuPct, tone: meterTone(cpuPct), idle: !live },
},
{
key: 'mem', icon: <MemoryStick size={15} aria-hidden="true" />, value: mem,
key: 'mem', label: tr('factMemory'), icon: <MemoryStick size={15} aria-hidden="true" />, value: mem,
tip: live && rss > 0 ? tr('specMemLiveTip', { mem, used: formatBytes(rss) }) : tr('specMemTip', { mem }),
meter: { pct: memPct, tone: '', idle: !live },
},
{
key: 'disk', icon: <HardDrive size={15} aria-hidden="true" />,
key: 'disk', label: tr('factDisk'), icon: <HardDrive size={15} aria-hidden="true" />,
value: diskKnown ? formatDiskUsage(stats!.disk_actual_bytes, stats!.disk_virtual_bytes) : controllerLabel(detail.disk_controller),
tip: diskKnown
? tr('specDiskUsage', { ctl: controllerLabel(detail.disk_controller), used: formatBytes(stats!.disk_actual_bytes), max: formatBytes(stats!.disk_virtual_bytes) })
@@ -422,12 +444,12 @@ export const VMPage: React.FC<Props> = ({
meter: { pct: diskPct, tone: meterTone(diskPct, 85, 95), idle: !diskKnown },
},
{
key: 'gfx', icon: <Monitor size={15} aria-hidden="true" />,
key: 'gfx', label: tr('factGraphics'), icon: <Monitor size={15} aria-hidden="true" />,
value: graphicsLabel(locale, detail, host),
tip: `${tr('factGraphics')}:${graphicsLabel(locale, detail, host)}`,
},
{
key: 'net', icon: <Network size={15} aria-hidden="true" />,
key: 'net', label: tr('fieldNetwork'), icon: <Network size={15} aria-hidden="true" />,
value: detail.network ? tr('netShared') : tr('netOff'),
tip: !detail.network ? tr('specNetOffTip') : detail.ssh_port > 0 ? tr('specNetSSHTip', { port: detail.ssh_port }) : tr('specNetTip'),
},
@@ -435,7 +457,7 @@ export const VMPage: React.FC<Props> = ({
if (detail.guest_lang) {
const lang = splitLangLabel('', guestLangLabel(locale, detail.guest_lang))
specs.push({
key: 'lang', icon: <Globe size={15} aria-hidden="true" />, value: lang.label,
key: 'lang', label: tr('specLang'), icon: <Globe size={15} aria-hidden="true" />, value: lang.label,
tip: `${tr('guestLang')}:${lang.detail ? `${lang.label}(${lang.detail})` : lang.label}`,
})
}
@@ -472,6 +494,8 @@ export const VMPage: React.FC<Props> = ({
<span>{tr('dropFilesHint')}</span>
</div>
)}
{/* Screen + summary: stacked, or side by side when the column is wide (container query in app.css). */}
<div className="vm-top">
<section className="vm-hero" aria-labelledby="vm-name">
<VMScreen
thumb={thumb}
@@ -483,34 +507,33 @@ export const VMPage: React.FC<Props> = ({
onShow={running && !busy ? () => onAction('focus') : undefined}
onScreenshot={running && !busy ? () => onAction('screenshot') : undefined}
/>
<h1 className="vm-hero-name" id="vm-name">{name}</h1>
<div className="vm-note-row">
{editingNote ? (
<input
className="vm-note-input"
value={noteDraft}
maxLength={120}
placeholder={tr('vmNotePlaceholder')}
aria-label={tr('vmNoteEdit')}
autoFocus
onChange={(e) => setNoteDraft(e.target.value)}
onBlur={() => void saveNote()}
onKeyDown={(e) => {
if (e.key === 'Enter') { e.preventDefault(); void saveNote() }
if (e.key === 'Escape') { e.preventDefault(); setEditingNote(false) }
}}
/>
) : (
<button
type="button"
className="vm-note-btn"
onClick={() => { setNoteDraft(note); setEditingNote(true) }}
>
<Pencil size={11} aria-hidden="true" />
<span>{note || tr('vmNotePlaceholder')}</span>
</button>
)}
</div>
{editingName ? (
<input
ref={nameInputRef}
className="vm-name-input"
value={nameDraft}
maxLength={60}
placeholder={name}
aria-label={tr('displayNameLabel')}
autoFocus
onFocus={(e) => e.currentTarget.select()}
onChange={(e) => setNameDraft(e.target.value)}
onBlur={() => void saveName()}
onKeyDown={(e) => {
if (e.key === 'Enter') { e.preventDefault(); void saveName() }
if (e.key === 'Escape') { e.preventDefault(); setEditingName(false) }
}}
/>
) : (
<h1 className="vm-hero-name" id="vm-name">
<Tip label={displayName ? tr('displayNameTip', { name }) : tr('displayNameEdit')}>
<button type="button" className="vm-name-btn" onClick={startRename}>
<span>{shownName}</span>
<Pencil size={15} className="vm-name-pencil" aria-hidden="true" />
</button>
</Tip>
</h1>
)}
<div className={`vm-hero-pill${pillClass}`} role="status">
<StatusShape kind={statusKind(state)} />
<span>{tr(`state_${state}` as I18nKey)}</span>
@@ -532,6 +555,7 @@ export const VMPage: React.FC<Props> = ({
<Tip key={s.key} label={s.tip}>
<div className="vm-spec-cell" role="listitem" tabIndex={-1}>
<span className="vm-spec-icon">{s.icon}</span>
<span className="vm-spec-label">{s.label}</span>
<span className="vm-spec-val">{s.value}</span>
{s.meter && (
<span className="vm-spec-meter" data-idle={s.meter.idle || undefined} aria-hidden="true">
@@ -543,6 +567,7 @@ export const VMPage: React.FC<Props> = ({
))}
</div>
)}
</div>
{state === 'broken' && (
<div className="notice notice-error" role="alert">
@@ -925,6 +950,7 @@ export const VMPage: React.FC<Props> = ({
<div className="tech-body">
<IconButton small className="tech-copy" label={tr('copyTechInfo')} icon={<Copy size={14} />} onClick={copyTechSummary} />
<dl className="kv-list">
<dt>{tr('fieldVMName')}</dt><dd className="mono">{name}</dd>
<dt>{tr('fieldKind')}</dt><dd>{detail.kind || '—'}</dd>
<dt>{tr('fieldCPUModel')}</dt><dd className="mono">{detail.cpu_model || 'auto'}</dd>
<dt>{tr('fieldGraphicsBackend')}</dt><dd>{detail.graphics}</dd>