Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/renderer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ export default function App() {
vms={vms}
states={states}
usage={latestUsage}
work={vmWork}
selected={selected}
draftName={null}
query={query}
Expand Down
18 changes: 13 additions & 5 deletions src/renderer/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { forwardRef } from 'react'
import { Search } from 'lucide-react'
import type { VmConfig } from '@shared/config'
import type { VmStatus, VmUsage } from '@shared/ipc'
import type { VmStatus, VmUsage, VmWork } from '@shared/ipc'
import OsMark from './OsMark'
import { filterVms, statusLabel } from '../util'
import { filterVms, statusLabel, workLabel } from '../util'

interface Props {
vms: VmConfig[]
states: Record<string, VmStatus>
/** latest sample of each running VM */
usage: Record<string, VmUsage>
/** profile operations and disk work by VM name, shown instead of the status */
work: Record<string, VmWork>
selected: string | null
draftName: string | null
/** the filter text. Kept in App, since the arrow keys move through what it shows */
Expand All @@ -19,7 +21,7 @@ interface Props {
}

// the ref is the filter box, for Ctrl+F
const Sidebar = forwardRef<HTMLInputElement, Props>(function Sidebar({ vms, states, usage, selected, draftName, query, onQuery, onSelect }, filterRef) {
const Sidebar = forwardRef<HTMLInputElement, Props>(function Sidebar({ vms, states, usage, work, selected, draftName, query, onQuery, onSelect }, filterRef) {
const q = query.trim()
const shown = filterVms(vms, query)

Expand Down Expand Up @@ -60,6 +62,7 @@ const Sidebar = forwardRef<HTMLInputElement, Props>(function Sidebar({ vms, stat
{shown.map((v) => {
const s = states[v.name] ?? 'off'
const u = s === 'running' ? usage[v.name] : undefined
const w = work[v.name]
return (
<li key={v.name}>
<button
Expand All @@ -69,8 +72,13 @@ const Sidebar = forwardRef<HTMLInputElement, Props>(function Sidebar({ vms, stat
onClick={() => onSelect(v.name)}
>
<OsMark os={v.os} />
<span className="row-name">{v.name}</span>
{u ? (
<span className="row-name" title={v.name}>
{v.name}
</span>
{w ? (
// a session save turns the VM off and on again, without this it looks like a crash
<span className="row-state running">{workLabel[w]}</span>

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With nowrap the label keeps its full width and the name gives way. "Compacting disk" is about 85 px of a 232 px sidebar, so a name like "Windows 11 Enterprise LTSC" is cut to "Windows 11 Ent…" while work runs, and the row has no title, so there's no way to read the full name without selecting it. The CPU % was short enough that this rarely came up. A title={v.name} on .row-name would cover it.

) : u ? (
// a running VM shows its CPU use instead of the word Running, still green
<span className="row-state running" title={`${statusLabel[s]} · CPU ${u.cpuPercent.toFixed(0)}%`}>
<span className="sr-only">{statusLabel[s]}, CPU </span>
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ button:disabled { cursor: default; }
.row.active::before { content: ''; width: 3px; height: 14px; margin-left: -6px; margin-right: -3px; border-radius: 2px; background: var(--accent); }
.row.draft { font-style: italic; color: var(--text-2); }
.row-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-state { font-size: 11px; color: var(--text-3); }
.row-state { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.row-state.running { color: var(--run); }
.row-state.paused { color: var(--warn); }
.tree-empty { padding: 8px 12px; color: var(--text-3); }
Expand Down
Loading