@saadnvd1/agent-os 0.3.594 → 0.3.595

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ import { useState, useEffect } from "react";
4
4
  import { QueryClientProvider } from "@tanstack/react-query";
5
5
  import { ThemeProvider as NextThemesProvider, useTheme } from "next-themes";
6
6
  import { TooltipProvider } from "@/components/ui/tooltip";
7
+ import { HoverTip } from "@/components/ui/HoverTip";
7
8
  import { createQueryClient } from "@/lib/query-client";
8
9
  import { parseTheme, getAllThemes } from "@/lib/theme-config";
9
10
 
@@ -41,7 +42,10 @@ export function Providers({ children }: { children: React.ReactNode }) {
41
42
  themes={getAllThemes()}
42
43
  >
43
44
  <ThemeClassHandler>
44
- <TooltipProvider delayDuration={200}>{children}</TooltipProvider>
45
+ <TooltipProvider delayDuration={200}>
46
+ {children}
47
+ <HoverTip />
48
+ </TooltipProvider>
45
49
  </ThemeClassHandler>
46
50
  </NextThemesProvider>
47
51
  </QueryClientProvider>
@@ -52,7 +52,7 @@ export function LiveLine({ compacting, prStage }: LiveInput) {
52
52
  href={prStage.url}
53
53
  target="_blank"
54
54
  rel="noreferrer"
55
- title={pr}
55
+ data-tip={pr}
56
56
  aria-label={pr}
57
57
  onClick={(e) => e.stopPropagation()}
58
58
  className={cn(
@@ -16,6 +16,7 @@ import { useRowContext } from "./RowContext";
16
16
  import { SessionRowMenu } from "./SessionRowMenu";
17
17
  import { RowRename, UnreadDot } from "./RowParts";
18
18
  import { QuickChangeRow } from "./QuickChangeRow";
19
+ import { NestRail } from "./RowParts";
19
20
 
20
21
  // A workspace's orchestrator, pinned above its sessions and titled with the
21
22
  // workspace's name: what it's doing and how many asks wait on you, on a line
@@ -54,7 +55,7 @@ export const OrchestratorPinRow = memo(function OrchestratorPinRow({
54
55
 
55
56
  const content = (
56
57
  <RowFrame
57
- title={`${label}\n${summary}`}
58
+ data-tip={`${label}\n${summary}`}
58
59
  onActivate={() => !renaming && ctx.onSelect(session.id)}
59
60
  className={
60
61
  active
@@ -172,9 +173,13 @@ export const OrchestratorPinRow = memo(function OrchestratorPinRow({
172
173
  {menu("context")}
173
174
  </CM.ContextMenuContent>
174
175
  </CM.ContextMenu>
175
- {row.quick?.map((q) => (
176
- <QuickChangeRow key={q.session.id} row={q} />
177
- ))}
176
+ {!!row.quick?.length && (
177
+ <NestRail>
178
+ {row.quick.map((q) => (
179
+ <QuickChangeRow key={q.session.id} row={q} />
180
+ ))}
181
+ </NestRail>
182
+ )}
178
183
  </>
179
184
  );
180
185
  }, sameProps);
@@ -190,7 +195,7 @@ export function OrchestratorStartRow({
190
195
  }) {
191
196
  return (
192
197
  <RowFrame
193
- title={`${name}\nStart orchestrator`}
198
+ data-tip={`${name}\nStart orchestrator`}
194
199
  onActivate={() => orchestratorOpenActions.request(workspaceId)}
195
200
  className="hover:bg-muted/50 border-dashed"
196
201
  >
@@ -42,7 +42,7 @@ export function QuickChangeRow({ row }: { row: SidebarRow }) {
42
42
  );
43
43
  const openPr = pr ? () => window.open(pr, "_blank") : undefined;
44
44
  return (
45
- <div className="ml-5">
45
+ <div>
46
46
  <RowShell
47
47
  title={`Quick change: ${session.name}\n${label}`}
48
48
  onActivate={openPr}
@@ -1,7 +1,9 @@
1
1
  "use client";
2
2
 
3
- import { useEffect, useRef, useState } from "react";
3
+ import { useEffect, useRef, useState, type ReactNode } from "react";
4
+ import { ClipboardList, Pencil } from "lucide-react";
4
5
  import { NEED_LABEL, type SidebarRow } from "@/lib/sidebar/shelves";
6
+ import { rowKindBadge, type RowKindBadge } from "@/lib/sidebar/row-badge";
5
7
  import { cn } from "@/lib/utils";
6
8
 
7
9
  // Amber when it needs you, red when it failed, green while it works, and a
@@ -26,7 +28,8 @@ export function RowDot({ row }: { row: SidebarRow }) {
26
28
  );
27
29
  }
28
30
 
29
- // What it needs from you, stalled, or a purple dot when it changed since you looked.
31
+ // What it needs from you, stalled, its plan step, or a purple dot when it
32
+ // changed since you looked.
30
33
  export function RowBadge({ row }: { row: SidebarRow }) {
31
34
  if (row.need) {
32
35
  const asks = row.status?.asks ?? 0;
@@ -50,10 +53,42 @@ export function RowBadge({ row }: { row: SidebarRow }) {
50
53
  Stalled
51
54
  </span>
52
55
  );
56
+ const kind = rowKindBadge(row);
57
+ if (kind) return <KindBadge badge={kind} />;
53
58
  if (row.unread) return <UnreadDot />;
54
59
  return null;
55
60
  }
56
61
 
62
+ // Planning in blue, a plan waiting for approval in the primary colour:
63
+ // an icon and a word, never colour alone.
64
+ function KindBadge({ badge }: { badge: RowKindBadge }) {
65
+ const Icon = badge.kind === "planning" ? Pencil : ClipboardList;
66
+ return (
67
+ <span
68
+ data-tip={badge.tip}
69
+ className={cn(
70
+ "flex shrink-0 items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] font-semibold whitespace-nowrap",
71
+ badge.kind === "planning"
72
+ ? "bg-blue-500/15 text-blue-700 dark:text-blue-400"
73
+ : "bg-primary/15 text-primary"
74
+ )}
75
+ >
76
+ <Icon aria-hidden className="h-3 w-3" />
77
+ {badge.label}
78
+ </span>
79
+ );
80
+ }
81
+
82
+ // What belongs to the row above it (a conductor's workers, an
83
+ // orchestrator's quick changes), behind a thin rule.
84
+ export function NestRail({ children }: { children: ReactNode }) {
85
+ return (
86
+ <div className="border-foreground/10 ml-3.5 border-l pl-1.5">
87
+ {children}
88
+ </div>
89
+ );
90
+ }
91
+
57
92
  export function UnreadDot() {
58
93
  return (
59
94
  <span
@@ -11,9 +11,11 @@ export type RowMenuKind = "dropdown" | "context";
11
11
 
12
12
  // Every sidebar row's frame: a leading mark, title over subtitle, what's on
13
13
  // the right (hidden under the ⋯ on hover), and the same menu on ⋯ and on
14
- // right-click. Session rows and queued tasks both draw through it.
14
+ // right-click. Session rows and queued tasks both draw through it. The
15
+ // title is its hover tip (lib/hover-tip), or tipKey's when one resolves.
15
16
  export function RowShell({
16
17
  title,
18
+ tipKey,
17
19
  highlight,
18
20
  onClick,
19
21
  onActivate,
@@ -26,6 +28,7 @@ export function RowShell({
26
28
  menuButton = true,
27
29
  }: {
28
30
  title: string;
31
+ tipKey?: string;
29
32
  highlight?: "selected" | "active" | null;
30
33
  onClick?: (e: React.MouseEvent) => void;
31
34
  // Enter or Space on the row; without it the row isn't a button.
@@ -45,7 +48,8 @@ export function RowShell({
45
48
  <div
46
49
  role={onActivate ? "button" : undefined}
47
50
  tabIndex={onActivate ? 0 : undefined}
48
- title={title}
51
+ data-tip={title}
52
+ data-tip-key={tipKey}
49
53
  onClick={onClick}
50
54
  onKeyDown={(e) => {
51
55
  if (!onActivate || e.target !== e.currentTarget) return;
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { Repeat, Layers } from "lucide-react";
3
+ import { Repeat, Layers, Pause } from "lucide-react";
4
4
  import { HostBadge } from "@/components/Hosts";
5
5
  import { rowGroup } from "@/lib/recipes/chip";
6
6
  import type { Session } from "@/lib/db";
@@ -21,10 +21,12 @@ export function RowSubtitle({
21
21
  session,
22
22
  detail,
23
23
  live,
24
+ hideHost = false,
24
25
  }: {
25
26
  session: Session;
26
27
  detail?: string | null;
27
28
  live?: LiveInput;
29
+ hideHost?: boolean;
28
30
  }) {
29
31
  const ctx = useRowContext();
30
32
  // What its processes use, on a busy session: "3.1 cores · 4.2 GB".
@@ -61,29 +63,34 @@ export function RowSubtitle({
61
63
  return (
62
64
  <span className="flex min-w-0 items-center gap-1.5">
63
65
  {pause ? (
64
- <span className="min-w-0 truncate text-xs text-amber-600 dark:text-amber-400">
65
- {pauseSubtitle({
66
- state: pause,
67
- until: session.paused_until
68
- ? Date.parse(`${session.paused_until.replace(" ", "T")}Z`)
69
- : null,
70
- note: session.pause_note,
71
- })}
66
+ <span className="flex min-w-0 items-center gap-1 text-xs text-amber-600 dark:text-amber-400">
67
+ <Pause aria-hidden className="h-3 w-3 shrink-0" />
68
+ <span className="truncate">
69
+ {pauseSubtitle({
70
+ state: pause,
71
+ until: session.paused_until
72
+ ? Date.parse(`${session.paused_until.replace(" ", "T")}Z`)
73
+ : null,
74
+ note: session.pause_note,
75
+ })}
76
+ </span>
72
77
  </span>
73
78
  ) : (
74
79
  <LiveLine {...live} />
75
80
  )}
76
81
  {group && (
77
82
  <span
78
- className="text-muted-foreground/70 hidden min-w-0 shrink items-center gap-1 truncate text-xs @[14rem]:flex"
79
- title={group.kind === "recipe" ? "A recipe run" : "A piece of a plan"}
83
+ className="text-muted-foreground/70 flex min-w-0 shrink-0 items-center gap-1 truncate text-xs @[14rem]:shrink"
84
+ data-tip={`${group.kind === "recipe" ? "Recipe run" : "Plan piece"}: ${group.text}`}
80
85
  >
81
86
  {group.kind === "recipe" ? (
82
87
  <Repeat aria-hidden className="h-3 w-3 shrink-0" />
83
88
  ) : (
84
89
  <Layers aria-hidden className="h-3 w-3 shrink-0" />
85
90
  )}
86
- <span className="truncate">{group.text}</span>
91
+ <span className="sr-only truncate @[14rem]:not-sr-only">
92
+ {group.text}
93
+ </span>
87
94
  </span>
88
95
  )}
89
96
  {(project || detail || usage || session.placed_note) && (
@@ -98,7 +105,7 @@ export function RowSubtitle({
98
105
  .join(" · ")}
99
106
  </span>
100
107
  )}
101
- <HostBadge hostId={session.host_id} />
108
+ {!hideHost && <HostBadge hostId={session.host_id} />}
102
109
  </span>
103
110
  );
104
111
  }
@@ -12,6 +12,7 @@ import {
12
12
  import { compactTimeAgo } from "@/lib/session-meta";
13
13
  import { wakeLabel } from "@/lib/sidebar/snooze";
14
14
  import { sameRow, type SidebarRow } from "@/lib/sidebar/shelves";
15
+ import { rowKindBadge } from "@/lib/sidebar/row-badge";
15
16
  import { useMinuteTick } from "@/hooks/useMinuteTick";
16
17
  import { selectionStore, selectionActions } from "@/stores/sessionSelection";
17
18
  import { cn } from "@/lib/utils";
@@ -19,7 +20,7 @@ import { QuickChangeRow } from "./QuickChangeRow";
19
20
  import { useRowContext } from "./RowContext";
20
21
  import { SessionRowMenu } from "./SessionRowMenu";
21
22
  import { RowShell, type RowMenuKind } from "./RowShell";
22
- import { RowBadge, RowDot, RowRename } from "./RowParts";
23
+ import { NestRail, RowBadge, RowDot, RowRename } from "./RowParts";
23
24
  import { RowSubtitle } from "./RowSubtitle";
24
25
  import { OrchestratorAsks } from "./OrchestratorAsks";
25
26
 
@@ -29,11 +30,12 @@ import { OrchestratorAsks } from "./OrchestratorAsks";
29
30
  export const SessionRow = memo(function SessionRow({
30
31
  row,
31
32
  muted = false,
32
- nested = false,
33
+ inMachineShelf = false,
33
34
  }: {
34
35
  row: SidebarRow;
35
36
  muted?: boolean;
36
- nested?: boolean;
37
+ // Under its machine's own shelf, which already names the machine.
38
+ inMachineShelf?: boolean;
37
39
  }) {
38
40
  const ctx = useRowContext();
39
41
  const { selectedIds } = useSnapshot(selectionStore);
@@ -69,9 +71,10 @@ export const SessionRow = memo(function SessionRow({
69
71
  );
70
72
 
71
73
  return (
72
- <div className={cn(nested && "pl-5")}>
74
+ <div>
73
75
  <RowShell
74
76
  title={session.name}
77
+ tipKey={`session:${session.id}`}
75
78
  highlight={selected ? "selected" : active ? "active" : null}
76
79
  onClick={onClick}
77
80
  onActivate={() => ctx.onSelect(session.id)}
@@ -89,7 +92,7 @@ export const SessionRow = memo(function SessionRow({
89
92
  aside={
90
93
  <>
91
94
  {viaName && (
92
- <span title={`Started by ${viaName}`} className="shrink-0">
95
+ <span data-tip={`Started by ${viaName}`} className="shrink-0">
93
96
  <Workflow
94
97
  aria-label={`Via orchestrator: ${viaName}`}
95
98
  className="text-muted-foreground/60 h-3 w-3"
@@ -104,7 +107,7 @@ export const SessionRow = memo(function SessionRow({
104
107
  trailing={
105
108
  <>
106
109
  <RowBadge row={row} />
107
- {!row.need && <RowTime row={row} />}
110
+ {!row.need && !rowKindBadge(row) && <RowTime row={row} />}
108
111
  </>
109
112
  }
110
113
  menu={menu}
@@ -132,6 +135,7 @@ export const SessionRow = memo(function SessionRow({
132
135
  )}
133
136
  <RowSubtitle
134
137
  session={session}
138
+ hideHost={inMachineShelf}
135
139
  detail={row.status?.detail}
136
140
  live={
137
141
  row.need
@@ -143,21 +147,28 @@ export const SessionRow = memo(function SessionRow({
143
147
  {session.role === "orchestrator" && row.need && (
144
148
  <OrchestratorAsks workspaceId={session.workspace_id} />
145
149
  )}
146
- {row.workers.map((worker) => (
147
- <SessionRow key={worker.session.id} row={worker} muted={muted} nested />
148
- ))}
149
- {row.quick?.map((q) => (
150
- <QuickChangeRow key={q.session.id} row={q} />
151
- ))}
150
+ {(row.workers.length > 0 || !!row.quick?.length) && (
151
+ <NestRail>
152
+ {row.workers.map((worker) => (
153
+ <SessionRow key={worker.session.id} row={worker} muted={muted} />
154
+ ))}
155
+ {row.quick?.map((q) => (
156
+ <QuickChangeRow key={q.session.id} row={q} />
157
+ ))}
158
+ </NestRail>
159
+ )}
152
160
  </div>
153
161
  );
154
162
  }, sameRowProps);
155
163
 
156
- function sameRowProps(
157
- a: { row: SidebarRow; muted?: boolean; nested?: boolean },
158
- b: { row: SidebarRow; muted?: boolean; nested?: boolean }
159
- ) {
160
- return a.muted === b.muted && a.nested === b.nested && sameRow(a.row, b.row);
164
+ type RowProps = { row: SidebarRow; muted?: boolean; inMachineShelf?: boolean };
165
+
166
+ function sameRowProps(a: RowProps, b: RowProps) {
167
+ return (
168
+ a.muted === b.muted &&
169
+ a.inMachineShelf === b.inMachineShelf &&
170
+ sameRow(a.row, b.row)
171
+ );
161
172
  }
162
173
 
163
174
  // Snoozed: when it wakes. Otherwise when it last did something.
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import type { ReactNode } from "react";
4
- import { ChevronDown } from "lucide-react";
4
+ import { ChevronDown, ListTodo, Server, type LucideIcon } from "lucide-react";
5
5
  import {
6
6
  DONE_PAGE,
7
7
  doneLimit,
@@ -16,21 +16,35 @@ import { OrchestratorPinRow, OrchestratorStartRow } from "./OrchestratorPinRow";
16
16
  import { QueuedRow } from "./QueuedRow";
17
17
  import type { QueuedRow as QueuedRowData } from "@/lib/sidebar/queued";
18
18
 
19
- function ShelfLabel({
19
+ // A shelf's header. Only groups that aren't a state (a machine, the line,
20
+ // terminals) carry an icon; a shelf that asks for you counts in amber.
21
+ export function ShelfLabel({
20
22
  label,
21
23
  count,
24
+ icon: Icon,
25
+ accent = false,
22
26
  collapsed,
23
27
  onToggle,
24
28
  }: {
25
29
  label: string;
26
30
  count?: number;
31
+ icon?: LucideIcon;
32
+ accent?: boolean;
27
33
  collapsed?: boolean;
28
34
  onToggle?: () => void;
29
35
  }) {
30
36
  const text = (
31
37
  <>
38
+ {Icon && <Icon aria-hidden className="h-3 w-3 shrink-0" />}
32
39
  {label}
33
- {count !== undefined && ` · ${count}`}
40
+ {count !== undefined && (
41
+ <>
42
+ {" · "}
43
+ <span className={cn(accent && "text-amber-600 dark:text-amber-400")}>
44
+ {count}
45
+ </span>
46
+ </>
47
+ )}
34
48
  {onToggle && (
35
49
  <ChevronDown
36
50
  className={cn(
@@ -63,15 +77,19 @@ function ShelfLabel({
63
77
  function Shelf({
64
78
  label,
65
79
  count,
80
+ icon,
81
+ accent,
66
82
  children,
67
83
  }: {
68
84
  label: string;
69
85
  count?: number;
86
+ icon?: LucideIcon;
87
+ accent?: boolean;
70
88
  children: ReactNode;
71
89
  }) {
72
90
  return (
73
91
  <section aria-label={label}>
74
- <ShelfLabel label={label} count={count} />
92
+ <ShelfLabel label={label} count={count} icon={icon} accent={accent} />
75
93
  {children}
76
94
  </section>
77
95
  );
@@ -80,9 +98,9 @@ function Shelf({
80
98
  // A linked machine's sessions no project here holds, under its name.
81
99
  export function MachineShelves({ groups }: { groups: MachineGroup[] }) {
82
100
  return groups.map((g) => (
83
- <Shelf key={g.hostId} label={g.name} count={g.rows.length}>
101
+ <Shelf key={g.hostId} label={g.name} count={g.rows.length} icon={Server}>
84
102
  {g.rows.map((r) => (
85
- <SessionRow key={r.session.id} row={r} />
103
+ <SessionRow key={r.session.id} row={r} inMachineShelf />
86
104
  ))}
87
105
  </Shelf>
88
106
  ));
@@ -108,6 +126,17 @@ export function SessionShelves({
108
126
  const shown = shelves.done.slice(0, doneLimit(donePages));
109
127
  const hidden = shelves.done.length - shown.length;
110
128
  const summary = doneSummary(shelves.done).text;
129
+ // Live work above, what's resting below a hairline.
130
+ const live =
131
+ shelves.orchestrators.length +
132
+ toStart.length +
133
+ shelves.pinned.length +
134
+ shelves.needsYou.length +
135
+ shelves.working.length +
136
+ shelves.inReview.length +
137
+ queued.length +
138
+ shelves.ongoing.length >
139
+ 0;
111
140
  return (
112
141
  <>
113
142
  {shelves.orchestrators.length + toStart.length > 0 && (
@@ -128,7 +157,7 @@ export function SessionShelves({
128
157
  </Shelf>
129
158
  )}
130
159
  {shelves.needsYou.length > 0 && (
131
- <Shelf label="Needs you" count={shelves.needsYou.length}>
160
+ <Shelf label="Needs you" count={shelves.needsYou.length} accent>
132
161
  {shelves.needsYou.map((r) => (
133
162
  <SessionRow key={r.session.id} row={r} />
134
163
  ))}
@@ -149,7 +178,7 @@ export function SessionShelves({
149
178
  </Shelf>
150
179
  )}
151
180
  {queued.length > 0 && (
152
- <Shelf label="Queued" count={queued.length}>
181
+ <Shelf label="Queued" count={queued.length} icon={ListTodo}>
153
182
  {queued.map((r) => (
154
183
  <QueuedRow key={r.item.id} row={r} />
155
184
  ))}
@@ -162,6 +191,9 @@ export function SessionShelves({
162
191
  ))}
163
192
  </Shelf>
164
193
  )}
194
+ {live && shelves.snoozed.length + shelves.done.length > 0 && (
195
+ <div aria-hidden className="border-border mx-2.5 mt-2.5 border-t" />
196
+ )}
165
197
  {shelves.snoozed.length > 0 && (
166
198
  <section aria-label="Snoozed">
167
199
  <ShelfLabel
@@ -4,7 +4,9 @@ import { DevServerCard } from "@/components/DevServers/DevServerCard";
4
4
  import { ElsewhereTmuxList, TmuxSessionRow } from "@/components/Hosts";
5
5
  import { useDevServersQuery } from "@/data/dev-servers";
6
6
  import { useDiscoveredTmuxQuery } from "@/data/hosts";
7
+ import { SquareTerminal } from "lucide-react";
7
8
  import type { ProjectWithRepositories } from "@/lib/projects";
9
+ import { ShelfLabel } from "./SessionShelves";
8
10
 
9
11
  interface DevServerHandlers {
10
12
  onStop: (id: string) => Promise<void>;
@@ -58,7 +60,11 @@ export function SidebarExtras({
58
60
  )}
59
61
  {tmux.length > 0 && (
60
62
  <section aria-label="Terminals">
61
- <div className={label}>Terminals · {tmux.length}</div>
63
+ <ShelfLabel
64
+ label="Terminals"
65
+ count={tmux.length}
66
+ icon={SquareTerminal}
67
+ />
62
68
  {tmux.map((t) => (
63
69
  <TmuxSessionRow key={`${t.hostId}:${t.name}`} session={t} />
64
70
  ))}
@@ -12,6 +12,7 @@ import type { OrchestratorOverview } from "@/lib/orchestrator/overview";
12
12
  import { useSessionListMutations } from "./hooks/useSessionListMutations";
13
13
  import { useBulkDelete } from "./hooks/useBulkDelete";
14
14
  import { useSidebarData } from "./useSidebarData";
15
+ import { useSessionTips } from "./useSessionTips";
15
16
  import { RowProvider, type RowContextValue } from "./RowContext";
16
17
  import { SidebarHeader } from "./SidebarHeader";
17
18
  import { useAddProject } from "@/components/Projects/AddProject/useAddProject";
@@ -43,6 +44,7 @@ export function SessionList({
43
44
  pinControls,
44
45
  }: SessionListProps) {
45
46
  const data = useSidebarData(sessionStatuses);
47
+ useSessionTips(data);
46
48
  const { shelves, ui, project } = data;
47
49
  const mutations = useSessionListMutations({ onSelectSession: onSelect });
48
50
  const bulkDelete = useBulkDelete();
@@ -0,0 +1,62 @@
1
+ "use client";
2
+
3
+ import { useEffect, useLayoutEffect, useRef } from "react";
4
+ import { useHostNames } from "@/data/hosts";
5
+ import type { SidebarRow } from "@/lib/sidebar/shelves";
6
+ import type { SidebarData } from "./useSidebarData";
7
+
8
+ function find(rows: readonly SidebarRow[], id: string): SidebarRow | null {
9
+ for (const row of rows) {
10
+ if (row.session.id === id) return row;
11
+ const nested = find(row.workers, id) ?? find(row.quick ?? [], id);
12
+ if (nested) return nested;
13
+ }
14
+ return null;
15
+ }
16
+
17
+ // A session row's hover tip, built from the latest list only when it
18
+ // opens: nothing runs per row, and registering never re-renders.
19
+ export function useSessionTips(data: SidebarData) {
20
+ const hostNames = useHostNames();
21
+ const latest = useRef({ data, hostNames });
22
+ useLayoutEffect(() => {
23
+ latest.current = { data, hostNames };
24
+ });
25
+ // Loaded after the page, like the tip itself: no first-load cost.
26
+ useEffect(() => {
27
+ let off: (() => void) | undefined;
28
+ let gone = false;
29
+ Promise.all([
30
+ import("@/lib/hover-tip"),
31
+ import("@/lib/sidebar/row-details"),
32
+ ]).then(([{ registerTip }, { rowDetails }]) => {
33
+ if (gone) return;
34
+ off = registerTip("session", (id) => {
35
+ const { data, hostNames } = latest.current;
36
+ const row = find(
37
+ [
38
+ ...Object.values(data.shelves).flat(),
39
+ ...data.machines.flatMap((g) => g.rows),
40
+ ],
41
+ id
42
+ );
43
+ if (!row) return null;
44
+ const s = row.session;
45
+ return rowDetails(row, {
46
+ project: data.projectNames.get(s.project_id ?? ""),
47
+ startedBy: s.started_by
48
+ ? data.orchestratorNames.get(s.started_by)
49
+ : undefined,
50
+ host:
51
+ s.host_id && s.host_id !== "local"
52
+ ? hostNames[s.host_id] || "remote"
53
+ : undefined,
54
+ });
55
+ });
56
+ });
57
+ return () => {
58
+ gone = true;
59
+ off?.();
60
+ };
61
+ }, []);
62
+ }
@@ -0,0 +1,20 @@
1
+ "use client";
2
+
3
+ import { useEffect } from "react";
4
+
5
+ // Mounted once: the app's single hover tooltip (lib/hover-tip.ts), loaded
6
+ // after the page so it costs the first load nothing.
7
+ export function HoverTip() {
8
+ useEffect(() => {
9
+ let off: (() => void) | undefined;
10
+ let gone = false;
11
+ import("@/lib/hover-tip").then(({ installHoverTip }) => {
12
+ if (!gone) off = installHoverTip();
13
+ });
14
+ return () => {
15
+ gone = true;
16
+ off?.();
17
+ };
18
+ }, []);
19
+ return null;
20
+ }
@@ -1,7 +1,3 @@
1
- import {
2
- startAuthentication,
3
- startRegistration,
4
- } from "@simplewebauthn/browser";
5
1
  import type {
6
2
  AuthenticationResponseJSON,
7
3
  PublicKeyCredentialCreationOptionsJSON,
@@ -30,12 +26,20 @@ export const passkeysHere = () =>
30
26
  export const NO_PASSKEYS_HERE =
31
27
  "Approving this needs a passkey, and passkeys need https or localhost: approve it on the machine running AgentOS, or over Connect.";
32
28
 
29
+ // The passkey library loads only when a passkey is used, fetched alongside
30
+ // the server's options so the prompt waits on nothing extra.
31
+ const webauthn = () => import("@simplewebauthn/browser");
32
+
33
33
  // Adds a passkey on this browser: free for the very first one, otherwise
34
34
  // with a code from a device that has one.
35
35
  export async function registerPasskey(enrollCode?: string): Promise<void> {
36
- const { options } = await post<{
37
- options: PublicKeyCredentialCreationOptionsJSON;
38
- }>("/api/presence/register/options", { enrollCode });
36
+ const [{ startRegistration }, { options }] = await Promise.all([
37
+ webauthn(),
38
+ post<{ options: PublicKeyCredentialCreationOptionsJSON }>(
39
+ "/api/presence/register/options",
40
+ { enrollCode }
41
+ ),
42
+ ]);
39
43
  const response = await startRegistration({ optionsJSON: options });
40
44
  await post("/api/presence/register/verify", { response, enrollCode });
41
45
  }
@@ -55,6 +59,8 @@ export async function provePresence(req: {
55
59
  needsPasskey?: boolean;
56
60
  canBootstrap?: boolean;
57
61
  };
62
+ const lib = webauthn();
63
+ lib.catch(() => {}); // awaited below; an early throw mustn't leave it unhandled
58
64
  let answer = await post<Answer>("/api/presence/options", req);
59
65
  if (answer.needsPasskey) {
60
66
  if (!answer.canBootstrap)
@@ -65,5 +71,6 @@ export async function provePresence(req: {
65
71
  answer = await post<Answer>("/api/presence/options", req);
66
72
  }
67
73
  if (!answer.options) throw new Error("No passkey for this host");
74
+ const { startAuthentication } = await lib;
68
75
  return startAuthentication({ optionsJSON: answer.options });
69
76
  }
@@ -0,0 +1,161 @@
1
+ // One hover tooltip for the whole app. An element opts in with data-tip
2
+ // (plain text) or data-tip-key ("session:<id>", resolved when it opens by
3
+ // whoever registered that prefix). Rows carry an attribute and nothing
4
+ // else: one element and a few passive document listeners do the rest, and
5
+ // a touch screen attaches none. It opens after resting on something, and
6
+ // once one is open the next opens at once, so a list can be scanned.
7
+
8
+ export interface TipContent {
9
+ title: string;
10
+ lines: [label: string, value: string][];
11
+ }
12
+ export type TipValue = string | TipContent | null | undefined;
13
+
14
+ export const OPEN_DELAY_MS = 600;
15
+ export const WARM_MS = 400;
16
+ const SELECTOR = "[data-tip],[data-tip-key]";
17
+ const TIP_ID = "hover-tip";
18
+
19
+ const resolvers = new Map<string, (id: string) => TipValue>();
20
+
21
+ export function registerTip(
22
+ prefix: string,
23
+ resolve: (id: string) => TipValue
24
+ ): () => void {
25
+ resolvers.set(prefix, resolve);
26
+ return () => {
27
+ if (resolvers.get(prefix) === resolve) resolvers.delete(prefix);
28
+ };
29
+ }
30
+
31
+ export function resolveTip(el: Element): TipValue {
32
+ const key = el.getAttribute("data-tip-key");
33
+ if (key) {
34
+ const at = key.indexOf(":");
35
+ const value = resolvers.get(key.slice(0, at))?.(key.slice(at + 1));
36
+ if (value) return value;
37
+ }
38
+ return el.getAttribute("data-tip");
39
+ }
40
+
41
+ // Text only: names are user text and never parsed as HTML.
42
+ function fill(el: HTMLElement, value: string | TipContent) {
43
+ if (typeof value === "string") {
44
+ el.textContent = value;
45
+ return;
46
+ }
47
+ const doc = el.ownerDocument;
48
+ const title = doc.createElement("div");
49
+ title.className = "font-medium";
50
+ title.textContent = value.title;
51
+ const rows = value.lines.map(([label, text]) => {
52
+ const line = doc.createElement("div");
53
+ const k = doc.createElement("span");
54
+ k.className = "text-muted-foreground";
55
+ k.textContent = `${label} `;
56
+ line.append(k, text);
57
+ return line;
58
+ });
59
+ el.replaceChildren(title, ...rows);
60
+ }
61
+
62
+ // Beside the target (a sidebar row's tip opens over the page, not the
63
+ // list), flipped or dropped below when there's no room. One measure.
64
+ function place(el: HTMLElement, target: Element, win: Window) {
65
+ const r = target.getBoundingClientRect();
66
+ const w = el.offsetWidth;
67
+ const h = el.offsetHeight;
68
+ const gap = 8;
69
+ let x = r.right + gap;
70
+ let y = r.top;
71
+ if (x + w > win.innerWidth - gap) x = r.left - w - gap;
72
+ if (x < gap) {
73
+ x = Math.min(Math.max(gap, r.left), win.innerWidth - w - gap);
74
+ y = r.bottom + gap;
75
+ }
76
+ y = Math.max(gap, Math.min(y, win.innerHeight - h - gap));
77
+ el.style.transform = `translate(${Math.round(x)}px, ${Math.round(y)}px)`;
78
+ }
79
+
80
+ // Works across documents (tests, frames), unlike instanceof Element.
81
+ const isElement = (node: EventTarget | null): node is Element =>
82
+ !!node && typeof (node as Element).closest === "function";
83
+
84
+ export function installHoverTip(win: Window = window): () => void {
85
+ if (!win.matchMedia?.("(hover: hover) and (pointer: fine)").matches)
86
+ return () => {};
87
+ const doc = win.document;
88
+ const el = doc.createElement("div");
89
+ el.id = TIP_ID;
90
+ el.setAttribute("role", "tooltip");
91
+ el.className =
92
+ "popover-surface text-popover-foreground pointer-events-none fixed top-0 left-0 z-[60] max-w-72 rounded-lg px-2.5 py-1.5 text-xs leading-relaxed whitespace-pre-line";
93
+ el.hidden = true;
94
+ doc.body.append(el);
95
+
96
+ let timer: ReturnType<typeof setTimeout> | undefined;
97
+ let pending: Element | null = null;
98
+ let shown: Element | null = null;
99
+ let warmUntil = 0;
100
+
101
+ const hide = () => {
102
+ clearTimeout(timer);
103
+ timer = undefined;
104
+ pending = null;
105
+ if (shown) {
106
+ shown.removeAttribute("aria-describedby");
107
+ warmUntil = Date.now() + WARM_MS;
108
+ shown = null;
109
+ }
110
+ el.hidden = true;
111
+ };
112
+ const show = (target: Element) => {
113
+ timer = undefined;
114
+ if (!target.isConnected) return;
115
+ const value = resolveTip(target);
116
+ if (!value) return;
117
+ fill(el, value);
118
+ el.hidden = false;
119
+ place(el, target, win);
120
+ target.setAttribute("aria-describedby", TIP_ID);
121
+ shown = target;
122
+ };
123
+ const arm = (target: Element | null) => {
124
+ if (target && (target === pending || target === shown)) return;
125
+ hide();
126
+ if (!target) return;
127
+ pending = target;
128
+ if (Date.now() < warmUntil) show(target);
129
+ else timer = setTimeout(() => show(target), OPEN_DELAY_MS);
130
+ };
131
+ const tipOf = (node: EventTarget | null) =>
132
+ isElement(node) ? node.closest(SELECTOR) : null;
133
+
134
+ const onOver = (e: Event) => arm(tipOf(e.target));
135
+ const onOut = (e: Event) => {
136
+ if (!(e as PointerEvent).relatedTarget) hide();
137
+ };
138
+ const onFocusIn = (e: Event) => {
139
+ const t = e.target;
140
+ if (isElement(t) && t.matches(SELECTOR) && t.matches(":focus-visible"))
141
+ arm(t);
142
+ };
143
+ const passive = { passive: true } as const;
144
+ const listeners: [string, (e: Event) => void, AddEventListenerOptions][] = [
145
+ ["pointerover", onOver, passive],
146
+ ["pointerout", onOut, passive],
147
+ ["pointerdown", hide, passive],
148
+ ["keydown", hide, passive],
149
+ ["focusin", onFocusIn, passive],
150
+ ["focusout", hide, passive],
151
+ ["scroll", hide, { passive: true, capture: true }],
152
+ ];
153
+ for (const [type, fn, opts] of listeners)
154
+ doc.addEventListener(type, fn, opts);
155
+ return () => {
156
+ hide();
157
+ for (const [type, fn, opts] of listeners)
158
+ doc.removeEventListener(type, fn, opts);
159
+ el.remove();
160
+ };
161
+ }
@@ -0,0 +1,40 @@
1
+ // The plan badge a row shows on its right: writing its plan, or a plan
2
+ // waiting for approval. A need or a stall says more and wins; finished,
3
+ // snoozed and quick-change rows show none. Client-safe.
4
+ import type { SidebarRow } from "./shelves";
5
+
6
+ export type RowKindBadge = {
7
+ kind: "planning" | "plan-ready";
8
+ label: string;
9
+ // What it means and what to do: the badge's hover text.
10
+ tip: string;
11
+ };
12
+
13
+ export function rowKindBadge(
14
+ row: Pick<SidebarRow, "need" | "task" | "settled" | "wakesAt"> & {
15
+ session: SidebarRow["session"];
16
+ status?: SidebarRow["status"];
17
+ }
18
+ ): RowKindBadge | null {
19
+ const s = row.session;
20
+ if (row.need || row.status?.stalled) return null;
21
+ if (row.settled || row.wakesAt || s.quick_of || s.role) return null;
22
+ if (s.task_status && s.task_status !== "running") return null;
23
+ if (row.task === "plan-ready" || s.plan_phase === "awaiting")
24
+ return {
25
+ kind: "plan-ready",
26
+ label: "Plan ready",
27
+ tip: "Plan ready: waiting for your approval. Open it to read the plan.",
28
+ };
29
+ if (s.plan_phase === "planning" || (!s.plan_phase && !!Number(s.chat_plan)))
30
+ return {
31
+ kind: "planning",
32
+ label: "Planning",
33
+ tip: s.plan_only
34
+ ? "Planning: plan only, it stops at the plan for your approval."
35
+ : s.plan_phase
36
+ ? "Planning: writing its plan, then it implements."
37
+ : "Plan mode: it plans and changes nothing yet.",
38
+ };
39
+ return null;
40
+ }
@@ -0,0 +1,53 @@
1
+ // What a session row's hover tip says: its full name, then what the row
2
+ // abbreviates. Built when the tip opens, never on render. Client-safe.
3
+ import type { TipContent } from "@/lib/hover-tip";
4
+ import { rowGroup } from "@/lib/recipes/chip";
5
+ import { compactTimeAgo } from "@/lib/session-meta";
6
+ import { prStageText } from "@/lib/tasks/pr-stage";
7
+ import { NEED_LABEL, type SidebarRow } from "./shelves";
8
+ import { pauseSubtitle } from "./paused";
9
+ import { rowKindBadge } from "./row-badge";
10
+
11
+ export function rowState(row: SidebarRow, now: number): string {
12
+ if (row.need) return `Needs you: ${NEED_LABEL[row.need]}`;
13
+ if (row.status?.stalled) return "Stalled";
14
+ const badge = rowKindBadge(row);
15
+ if (badge?.kind === "plan-ready") return "Plan ready, waiting for approval";
16
+ if (badge?.kind === "planning")
17
+ return row.session.plan_only ? "Planning (plan only)" : "Planning";
18
+ if (row.paused) return pauseSubtitle(row.paused, now);
19
+ if (row.compacting) return "Compacting its context";
20
+ const pr = row.status?.prStage;
21
+ if (pr) return prStageText(pr);
22
+ if (row.working) return "Working";
23
+ if (row.wakesAt) return "Snoozed";
24
+ return row.settled ? "Done" : "Idle";
25
+ }
26
+
27
+ export function rowDetails(
28
+ row: SidebarRow,
29
+ names: {
30
+ project?: string;
31
+ startedBy?: string;
32
+ host?: string;
33
+ },
34
+ now: number = Date.now()
35
+ ): TipContent {
36
+ const s = row.session;
37
+ const lines: TipContent["lines"] = [["State", rowState(row, now)]];
38
+ if (names.project) lines.push(["Project", names.project]);
39
+ const group = rowGroup(s);
40
+ if (group)
41
+ lines.push([group.kind === "recipe" ? "Recipe" : "Plan", group.text]);
42
+ if (s.pr_number) lines.push(["PR", `#${s.pr_number}`]);
43
+ if (names.host) lines.push(["Machine", names.host]);
44
+ if (names.startedBy) lines.push(["Started by", names.startedBy]);
45
+ if (row.activeAt) {
46
+ const ago = compactTimeAgo(new Date(row.activeAt), new Date(now));
47
+ lines.push([
48
+ "Last active",
49
+ ago === "now" ? "just now" : /^\d+[mhd]$/.test(ago) ? `${ago} ago` : ago,
50
+ ]);
51
+ }
52
+ return { title: s.name, lines };
53
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saadnvd1/agent-os",
3
- "version": "0.3.594",
3
+ "version": "0.3.595",
4
4
  "description": "Self-hosted web UI for managing Claude Code sessions",
5
5
  "bin": {
6
6
  "agent-os": "scripts/agent-os"