paseo-follow-up 2.1.0-beta.0 → 2.1.0-beta.2

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.
package/README.md CHANGED
@@ -160,7 +160,7 @@ full data-access statement.
160
160
  ## Memory on Linux
161
161
 
162
162
  On Linux (glibc), a Follow-up that stays up for hours can slowly grow in memory: the allocator keeps memory Follow-up
163
- already freed. macOS isn't affected. Three allocator settings in the Paseo daemon's environment stop the growth. Every
163
+ already freed. macOS isn't affected. Three allocator settings in the Paseo daemon's environment stop most of the idle growth. Every
164
164
  process Paseo starts inherits them.
165
165
 
166
166
  If a systemd unit runs Paseo, add them to it (the unit name is your own; `paseo` here):
@@ -183,7 +183,9 @@ MALLOC_ARENA_MAX=2 MALLOC_MMAP_THRESHOLD_=131072 MALLOC_TRIM_THRESHOLD_=131072 p
183
183
  ```
184
184
 
185
185
  In our test harness (140 workspaces, 45 idle minutes) Follow-up grew about 20 MB without them and 3 to 6 MB with them,
186
- at no measurable CPU cost. To undo it, remove the settings and restart Paseo.
186
+ at no measurable CPU cost. On a busy real setup they kept Follow-up flat while idle, but memory still stepped up during
187
+ bursts of activity and stayed there: after about 4.7 hours it used 363 MB with them and 375 MB without. To undo it,
188
+ remove the settings and restart Paseo.
187
189
 
188
190
  ## Docs
189
191
 
package/client/brief.tsx CHANGED
@@ -16,7 +16,7 @@ import { errorText, mootNote } from "../shared/errors";
16
16
  import { OTHER, OTHER_LABEL, briefAnswerStatus, isOther, type Question } from "../shared/questions";
17
17
  import type { ListQuestion, ListWorkspace } from "../shared/list";
18
18
  import { useDetailGate, useWorkspace } from "./workspace-data";
19
- import { SubmitScope, submitHint, text, useNow } from "./kit";
19
+ import { SubmitScope, focusRing, submitHint, text, useNow } from "./kit";
20
20
  import { PrLinksProvider, RichText } from "./rich-text";
21
21
  import { useMergeButtons } from "./merge-button";
22
22
  import { prLinksByNumber } from "../shared/presentation";
@@ -50,10 +50,8 @@ const kindTone = (kind: Brief["kind"], c: Colors) => kind === "error" ? c.status
50
50
  const factTone = (tone: string, c: Colors) => tone === "ok" ? c.statusSuccess : tone === "warn" ? c.statusWarning : tone === "bad" ? c.statusDanger : c.foregroundMuted;
51
51
  /** The time in the device's own format (12- or 24-hour), like the chat's timestamps. */
52
52
  const clock = (iso: string | null) => { if (!iso) return ""; const d = new Date(iso); return Number.isFinite(d.getTime()) ? d.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : ""; };
53
- /** Whether the focused element got focus from the keyboard (a tap or click doesn't draw the ring). */
54
- const keyboardFocus = () => { try { return !!(globalThis as { document?: { activeElement?: { matches?(q: string): boolean } | null } }).document?.activeElement?.matches?.(":focus-visible"); } catch { return true; } };
55
53
  /** Web keyboard focus: a visible ring, since sending an answer is one-shot. Not after a tap, where it read as a state. */
56
- const ring = (focused: boolean | undefined, c: Colors) => focused && Platform.OS === "web" && keyboardFocus() ? ({ outlineWidth: 2, outlineStyle: "solid", outlineColor: withAlpha(c.accent, 0.6), outlineOffset: 2 } as object) : {};
54
+ const ring = (focused: boolean | undefined, c: Colors) => focusRing(focused, c);
57
55
  const letters = (d: BriefDecision) => { const l = d.options.map(o => o.letter); return l.length > 1 ? `${l.slice(0, -1).join(", ")} or ${l.at(-1)}` : l[0] ?? ""; };
58
56
 
59
57
  function Btn({ label, icon, primary, onPress, c, compact, disabled, shortcut = false, hint }: { label: string; icon?: string; primary?: boolean; onPress: () => void; c: Colors; compact: boolean; disabled?: boolean; shortcut?: boolean; hint?: string }) {
@@ -1,12 +1,12 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore, type ReactNode } from "react";
2
- import { Platform, ScrollView, TextInput, View } from "react-native";
2
+ import { Platform, TextInput, View } from "react-native";
3
3
  import { Pressable, Text } from "./text";
4
- import { Icon, useToast } from "@getpaseo/plugin/client/ui";
4
+ import { Icon, ScrollView, useToast } from "@getpaseo/plugin/client/ui";
5
5
  import { homeCounts, type HomeGroupId, type HomeModel } from "../shared/home";
6
6
  import { filterHome, homeSearchDocs, indexDocs, defaultActive, omniboxResults, overseerProvider, workspaceProvider, type OmniboxItem, type OmniboxProvider } from "../shared/search";
7
7
  import { DEFAULT_SORT, SORT_HINT, SORT_LABEL, SORT_MODES, type SortMode } from "../shared/sort";
8
- import { priorityNote, PRIORITY_SOURCE_LABEL } from "../shared/priorities";
9
- import { rankCost } from "../shared/ranker";
8
+ import { PRIORITY_SOURCE_LABEL } from "../shared/priorities";
9
+ import { rankFooter } from "../shared/ranker";
10
10
  import { meters, meterText, type Meter } from "../shared/usage";
11
11
  import { resourceMeter, type Resources } from "../shared/resources";
12
12
  import type { HomeSources } from "./home-data";
@@ -92,7 +92,14 @@ export function useSlashToFocus(omnibox: Omnibox, enabled = true) {
92
92
  * The one query field: Home's omnibox (SearchField) and the sidebar view's filter (FilterField) are this with
93
93
  * different words. `dense` is the phone layout: a 44px field with a rounder shape and body-size text.
94
94
  */
95
- function QueryField({ theme, value, onChange, placeholder, icon, dense, inputRef, slashHint, onSubmit, onArrow }: {
95
+ export function QueryField({ theme, value, onChange, placeholder, icon, dense, inputRef, slashHint, onSubmit, onArrow, listKeys = false, count, autoFocus = false, onEscape }: {
96
+ /** Its arrows step into the list below (client/list-keys.ts): the sidebar filter, and Home's search while empty. */
97
+ listKeys?: boolean;
98
+ /** "2 of 12" at the field's end (a panel section's search), in place of the field's own ✕: the section has its own. */
99
+ count?: string;
100
+ autoFocus?: boolean;
101
+ /** Esc's own action (a section search closes); without it Esc clears, then leaves the field. */
102
+ onEscape?: () => void;
96
103
  theme: Theme; value: string; onChange: (q: string) => void; placeholder: string; icon: string; dense: boolean;
97
104
  inputRef: { current: TextInput | null }; slashHint: boolean; onSubmit?: () => void; onArrow?: (delta: number) => void;
98
105
  }) {
@@ -102,17 +109,19 @@ function QueryField({ theme, value, onChange, placeholder, icon, dense, inputRef
102
109
  borderWidth: 1, borderColor: focused ? withAlpha(c.foreground, 0.35) : c.border, backgroundColor: c.surface1 }}>
103
110
  <Icon name={icon as never} size={dense ? 16 : 13} color={c.foregroundMuted} />
104
111
  <TextInput ref={inputRef} value={value} onChangeText={onChange} placeholder={placeholder} placeholderTextColor={c.foregroundMuted}
105
- accessibilityLabel={placeholder} autoCorrect={false} autoCapitalize="none" spellCheck={false} returnKeyType="go"
112
+ accessibilityLabel={placeholder} autoFocus={autoFocus} autoCorrect={false} autoCapitalize="none" spellCheck={false} returnKeyType="go"
113
+ {...(listKeys ? { dataSet: { listKeys: "1" } } as object : {})}
106
114
  onFocus={() => setFocused(true)} onBlur={() => setFocused(false)}
107
115
  onSubmitEditing={onSubmit}
108
116
  onKeyPress={e => {
109
117
  const key = (e.nativeEvent as { key?: string }).key;
110
118
  if (key === "ArrowDown" && onArrow) { e.preventDefault?.(); onArrow(1); }
111
119
  else if (key === "ArrowUp" && onArrow) { e.preventDefault?.(); onArrow(-1); }
112
- else if (key === "Escape") { if (value) onChange(""); else inputRef.current?.blur(); }
120
+ else if (key === "Escape") { if (onEscape) onEscape(); else if (value) onChange(""); else inputRef.current?.blur(); }
113
121
  }}
114
122
  style={{ flex: 1, minWidth: 0, color: c.foreground, fontSize: dense ? 15 : 13, paddingVertical: 0, ...(Platform.OS === "web" ? { outlineStyle: "none" } as object : {}) }} />
115
- {!!value && <Pressable accessibilityRole="button" accessibilityLabel={`Clear ${placeholder.toLowerCase()}`} hitSlop={dense ? 14 : 8} onPress={() => { onChange(""); inputRef.current?.focus(); }}>
123
+ {count !== undefined ? !!count && <Text accessibilityLiveRegion="polite" style={{ color: c.foregroundMuted, fontSize: dense ? 13 : 12, fontVariant: ["tabular-nums"] }}>{count}</Text>
124
+ : !!value && <Pressable accessibilityRole="button" accessibilityLabel={`Clear ${placeholder.toLowerCase()}`} hitSlop={dense ? 14 : 8} onPress={() => { onChange(""); inputRef.current?.focus(); }}>
116
125
  <Icon name="X" size={dense ? 16 : 13} color={c.foregroundMuted} />
117
126
  </Pressable>}
118
127
  {slashHint && !value && !focused && !dense && Platform.OS === "web" && <Text style={{ color: c.foregroundMuted, fontSize: 11, paddingHorizontal: 4, borderRadius: 3, borderWidth: 1, borderColor: c.border }}>/</Text>}
@@ -123,7 +132,7 @@ export function SearchField({ theme, omnibox, dense, onEnter }: { theme: Theme;
123
132
  const { query, setQuery, results, active, move, inputRef, askOn } = omnibox;
124
133
  const placeholder = askOn ? dense ? "Search or ask the Overseer" : "Search, or ask the Overseer" : "Search workspaces, branches, PRs";
125
134
  return <QueryField theme={theme} value={query} onChange={setQuery} placeholder={placeholder} icon="Search" dense={dense} inputRef={inputRef} slashHint
126
- onSubmit={() => { const item = results?.[active]; if (item) onEnter(item); }} onArrow={move} />;
135
+ onSubmit={() => { const item = results?.[active]; if (item) onEnter(item); }} onArrow={move} listKeys={!query.trim()} />;
127
136
  }
128
137
 
129
138
  /**
@@ -148,7 +157,7 @@ export function useListFilter(model: HomeModel, sources: HomeSources): ListFilte
148
157
  }
149
158
  /** "Filter workspaces": a filter icon and no key binding, so it never reads as Paseo's own Search (the Command Center, ⌘K). */
150
159
  export function FilterField({ theme, filter, dense }: { theme: Theme; filter: ListFilter; dense: boolean }) {
151
- return <QueryField theme={theme} value={filter.query} onChange={filter.setQuery} placeholder="Filter workspaces" icon="ListFilter" dense={dense} inputRef={filter.inputRef} slashHint={false} />;
160
+ return <QueryField theme={theme} value={filter.query} onChange={filter.setQuery} placeholder="Filter workspaces" icon="ListFilter" dense={dense} inputRef={filter.inputRef} slashHint={false} listKeys />;
152
161
  }
153
162
 
154
163
  // ---------- sort ----------
@@ -156,9 +165,9 @@ export function FilterField({ theme, filter, dense }: { theme: Theme; filter: Li
156
165
  export type RankState = { enabled: boolean; running: boolean; healthLine: string; error: string | null; costUsd?: number | null; last?: { ok: boolean; skipped: string | null; provider: string | null } | null } | null;
157
166
 
158
167
 
159
- export function SortMenu({ theme, mode, onChange, rankedAt, touch, rank = null, onRerank, compact = touch, shared = false }: { theme: Theme; mode: SortMode; onChange: (m: SortMode) => void; rankedAt: string | null; touch: boolean; rank?: RankState; onRerank?: () => Promise<{ ok: boolean; skipped: string | null; error: string | null; top?: { title: string }[] }>;
168
+ export function SortMenu({ theme, mode, onChange, rankedAt, touch, rank = null, onRerank, compact = touch }: { theme: Theme; mode: SortMode; onChange: (m: SortMode) => void; rankedAt: string | null; touch: boolean; rank?: RankState; onRerank?: () => Promise<{ ok: boolean; skipped: string | null; error: string | null; top?: { title: string }[] }>;
160
169
  /** An icon without the mode's name (phones, and the sidebar view's narrow column). */ compact?: boolean;
161
- /** Shown away from Home (the sidebar view): the menu says the order is Home's too. */ shared?: boolean }) {
170
+ }) {
162
171
  const c = theme.colors;
163
172
  const [open, setOpen] = useState(false);
164
173
  const now = useMinute();
@@ -174,9 +183,8 @@ export function SortMenu({ theme, mode, onChange, rankedAt, touch, rank = null,
174
183
  else toast.show(r.skipped === "same" ? "Nothing new in Linear, Slack, GitHub or the plan since the last ranking" : r.top?.[0] ? `Re-ranked · ${r.top[0].title} first` : "Re-ranked", { variant: "success" });
175
184
  } catch (e) { toast.error(e instanceof Error ? e.message : String(e)); }
176
185
  };
177
- // "Ranked 12m ago · Slack unavailable": the age, then any source the last run couldn't read.
178
- // The footer keeps the standing ranking's age and cost while a new one runs; the menu item says "Ranking…".
179
- const note = [priorityNote(rankedAt, now), rankedAt && rank?.enabled ? rankCost(rank) : "", rank?.enabled ? rank.healthLine : ""].filter(Boolean).join(" · ");
186
+ // "Ranked 12m ago": only when the ranking last ran (and a failed run's reason); never its cost.
187
+ const note = rankFooter({ rankedAt, now, rank });
180
188
  return <View style={{ position: "relative", zIndex: 20 }}>
181
189
  <Pressable accessibilityRole="button" accessibilityLabel={`Sort: ${SORT_LABEL[mode]}${running ? ", ranking" : ""}`} aria-expanded={open} accessibilityState={{ expanded: open }} onPress={() => setOpen(o => !o)}
182
190
  style={state => ({ flexDirection: "row", alignItems: "center", justifyContent: "center", gap: 4, height: touch ? 44 : compact ? 32 : 30, minWidth: touch ? 44 : compact ? 32 : undefined, paddingHorizontal: compact ? 0 : 8, borderRadius: touch ? 8 : 6, backgroundColor: open || (state as { hovered?: boolean }).hovered ? c.surface2 : "transparent" })}>
@@ -198,10 +206,7 @@ export function SortMenu({ theme, mode, onChange, rankedAt, touch, rank = null,
198
206
  style={state => ({ ...menuItemRow(touch), minHeight: touch ? 48 : 34, paddingHorizontal: touch ? 12 : 10, backgroundColor: (state as { hovered?: boolean }).hovered ? c.surface2 : "transparent" })}>
199
207
  <MenuItemContent theme={theme} touch={touch} glyph={running ? <Spinner color={c.foregroundMuted} size={menuGlyph(touch).size - 2} label="Ranking" /> : "RefreshCw"} label={running ? "Ranking…" : "Re-rank now"} muted={running} />
200
208
  </Pressable>}
201
- {/* Phones: before anything is ranked, "Priority: By urgency" only repeats the checked row's hint. */}
202
- {!(touch && !rankedAt) && <Text style={{ color: c.foregroundMuted, fontSize: 11, paddingHorizontal: 10, paddingTop: 4, paddingBottom: shared ? 0 : 4 }}>Priority: {note}</Text>}
203
- {/* One order, saved as the Display setting home_sort: changing it here reorders Home as well. */}
204
- {shared && <Text style={{ color: c.foregroundMuted, fontSize: 11, paddingHorizontal: 10, paddingTop: 2, paddingBottom: 6 }}>Home uses this order too.</Text>}
209
+ {note && <Text style={{ color: c.foregroundMuted, fontSize: 11, paddingHorizontal: touch ? 12 : 10, paddingTop: 4, paddingBottom: 6 }}>{note}</Text>}
205
210
  </View>
206
211
  </View>}
207
212
  </View>;
@@ -1,15 +1,19 @@
1
1
  import { memo, useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
2
- import { FlatList, View } from "react-native";
2
+ import { View, type FlatList as NativeFlatList } from "react-native";
3
3
  import { Pressable, Text } from "./text";
4
- import { Icon } from "@getpaseo/plugin/client/ui";
5
- import { GROUP_TITLE, quietFolds, type Badge, type HomeGroupId, type HomeModel, type Workstream } from "../shared/home";
6
- import { ASK_KEY, excerpt, FIELD_LABEL, highlightRuns, rowHit, type OmniboxItem, type Range, type RowHit, type SearchHit, type WorkspaceItem } from "../shared/search";
4
+ import { Icon, FlatList } from "@getpaseo/plugin/client/ui";
5
+ import { type Badge, type HomeGroupId, type HomeModel, type Workstream } from "../shared/home";
6
+ import { ASK_KEY, excerpt, FIELD_LABEL, type OmniboxItem, type Range, type RowHit, type SearchHit } from "../shared/search";
7
7
  import { AskRow, PriorityLine } from "./home-chrome";
8
8
  import { age, wakeLabel, wakeShort } from "../shared/inbox";
9
9
  import { headlineColor, mergedColor, readable, runningColor, tint, toneColor, withAlpha, type Colors } from "./theme";
10
10
  import { useMinute } from "./home-data";
11
+ import { marked } from "./rich-text";
11
12
  import { Spinner } from "./motion";
12
- import { Button, rowDomId, type Theme } from "./kit";
13
+ import { Button, focusRing, rowDomId, type Theme } from "./kit";
14
+ import { useListKeys } from "./list-keys";
15
+ import { walkOrder } from "../shared/list-keys";
16
+ import { BRIEF_KEY, OVERSEER_KEY, QUIET_PAGE, listEntries, type Entry } from "../shared/list-entries";
13
17
  import { RowMenu, useRowMenuTrigger, type OpenRowMenu, type RowMenuOpen } from "./row-menu";
14
18
  import type { RowMenuItem, RowMenuSection } from "../shared/row-menu";
15
19
  import { homeGroupOpen, writeHomeGroupOpen } from "../shared/settings-nav";
@@ -21,27 +25,12 @@ import { useViewVersion } from "./view-store";
21
25
  * that changes one row redraws only that row.
22
26
  */
23
27
 
24
- const QUIET_PAGE = 20;
25
- export const BRIEF_KEY = "brief";
26
- export const OVERSEER_KEY = "overseer";
28
+ export { BRIEF_KEY, OVERSEER_KEY, archivedRow } from "../shared/list-entries";
27
29
  /** The pinned Overseer row: not started yet (a one-time Start), working, asking, idle, or failed to come back. */
28
30
  export type OverseerRowState = { state: "start" | "idle" | "running" | "asks" | "error"; line: string;
29
31
  /** A list filter's match in `line`, highlighted like a row's (the sidebar view's "Filter workspaces"). */
30
32
  ranges?: Range[] };
31
33
 
32
- type Entry =
33
- | { type: "brief"; key: string }
34
- | { type: "overseer"; key: string }
35
- | { type: "header"; key: string; group: HomeGroupId; title: string; count: number; open: boolean }
36
- | { type: "row"; key: string; s: Workstream; hit?: RowHit | null }
37
- | { type: "fold"; key: string; project: string; count: number; archivable: number; open: boolean }
38
- | { type: "more"; key: string; project: string; left: number }
39
- | { type: "result"; key: string; item: WorkspaceItem; index: number; s: Workstream; hit: RowHit; archived: boolean }
40
- | { type: "ask"; key: string; ask: string; index: number }
41
- | { type: "label"; key: string; text: string }
42
- | { type: "hold"; key: string; text: string }
43
- | { type: "empty"; key: string }
44
- | { type: "slot"; key: string };
45
34
 
46
35
  export type HomeListProps = {
47
36
  model: HomeModel;
@@ -88,11 +77,20 @@ export type HomeListProps = {
88
77
  * own Copy/Paste menu opens instead.
89
78
  */
90
79
  menu: { build: (s: Workstream) => RowMenuSection[]; pick: (s: Workstream, item: RowMenuItem) => void };
80
+ /**
81
+ * Desktop and web keys (client/list-keys.ts, one-keyboard-walk-for-every-list): ↑/↓ and j/k walk the rows in this
82
+ * list's order, Home/End jump, Enter opens. "select" moves the selection (Home); "focus" moves only the focus and
83
+ * Enter opens (the sidebar view). `scope`: where the keys count (default: this list); `claimBody`: also with
84
+ * nothing focused.
85
+ */
86
+ keys?: { mode: "select" | "focus"; onOpen: (key: string) => void; scope?: { current: unknown }; claimBody?: boolean };
87
+ /** The selected row's fill. Paseo's sidebar view passes its own selected-item colour (sidebarSelected); Home: surface2. */
88
+ selectedBg?: string;
91
89
  };
92
90
 
93
91
  const noMenu: OpenRowMenu = () => undefined;
94
92
 
95
- export function HomeList({ model, theme, dense = false, touch, selectedKey, onSelect, briefLine, renderExpanded, header, footer, top, afterNeeds, emptyAction, results, hits = null, activeResult = 0, onResult, filter = null, overseer = null, stackOverseer = false, asking = false, menu, onSendNow }: HomeListProps) {
93
+ export function HomeList({ model, theme, dense = false, touch, selectedKey, onSelect, briefLine, renderExpanded, header, footer, top, afterNeeds, emptyAction, results, hits = null, activeResult = 0, onResult, filter = null, overseer = null, stackOverseer = false, asking = false, menu, onSendNow, keys, selectedBg }: HomeListProps) {
96
94
  const c = theme.colors;
97
95
  const [openMenu, setOpenMenu] = useState<RowMenuOpen | null>(null);
98
96
  const build = menu.build;
@@ -111,54 +109,9 @@ export function HomeList({ model, theme, dense = false, touch, selectedKey, onSe
111
109
  const toggle = useCallback((key: string) => { if (key === "needs") setNeedsClosed(v => !v); else writeHomeGroupOpen(key, !homeGroupOpen(key)); }, []);
112
110
  const toggleProject = useCallback((p: string) => setOpenProjects(s => { const n = new Set(s); if (n.has(p)) n.delete(p); else n.add(p); return n; }), []);
113
111
 
114
- const data = useMemo(() => {
115
- const out: Entry[] = [];
116
- if (results) {
117
- // Search ignores the sort and the groups: ranked by match, archived ones last under their own label.
118
- let archivedShown = false;
119
- results.forEach((item, index) => {
120
- if (item.ask !== undefined) {
121
- // The ask row closes the list; with no match it follows the "no match" line.
122
- if (index === 0) out.push({ type: "label", key: "l:none", text: "No workspace, branch or PR matches." });
123
- out.push({ type: "ask", key: item.key, ask: item.ask, index });
124
- return;
125
- }
126
- if (item.hit.group === "archived" && !archivedShown) { archivedShown = true; out.push({ type: "label", key: "l:archived", text: "Archived" }); }
127
- const live = model.byKey.get(item.key);
128
- const s = live ?? archivedRow(item.hit);
129
- out.push({ type: "result", key: `r:${item.provider}:${item.key}`, item, index, s, hit: rowHit(item.hit, s), archived: !live });
130
- });
131
- if (!results.length) out.push({ type: "label", key: "l:none", text: "No workspace, branch or PR matches." });
132
- return out;
133
- }
134
- if (briefLine !== undefined && !filter) out.push({ type: "brief", key: BRIEF_KEY });
135
- if (overseer && !filter) out.push({ type: "overseer", key: OVERSEER_KEY });
136
- for (const g of model.groups) {
137
- if (filter && g.id !== filter) continue;
138
- const open = !!filter || !!hits || !closed.has(g.id);
139
- // Phones with one group filtered: the chip above already says "N Needs you ×"; no header repeating it.
140
- if (!(touch && filter)) out.push({ type: "header", key: `h:${g.id}`, group: g.id, title: g.title, count: g.items.length, open });
141
- if (!open) { if (g.id === "needs" && afterNeeds && !filter) out.push({ type: "slot", key: "s:afterNeeds" }); continue; }
142
- // One hold line per machine, once, at the top of Sending (the model has it only while Sending has rows).
143
- if (g.id === "sending" && model.hold) out.push({ type: "hold", key: "l:hold", text: model.hold });
144
- const hitOf = (s: Workstream) => { const h = hits?.get(s.key); return h ? rowHit(h, s) : null; };
145
- if (g.id !== "quiet") { for (const s of g.items) out.push({ type: "row", key: s.key, s, hit: hitOf(s) }); if (g.id === "needs" && afterNeeds && !filter) out.push({ type: "slot", key: "s:afterNeeds" }); continue; }
146
- for (const f of quietFolds(g.items)) {
147
- const fopen = !!hits || openProjects.has(f.project);
148
- out.push({ type: "fold", key: `f:${f.project}`, project: f.project, count: f.items.length, archivable: f.archivable, open: fopen });
149
- if (!fopen) continue;
150
- const shown = (pages[f.project] ?? 1) * QUIET_PAGE;
151
- for (const s of f.items.slice(0, shown)) out.push({ type: "row", key: s.key, s, hit: hitOf(s) });
152
- if (f.items.length > shown) out.push({ type: "more", key: `m:${f.project}`, project: f.project, left: f.items.length - shown });
153
- }
154
- }
155
- // Phones: nothing followed yet says so and what fills the list, instead of a blank screen under the pinned rows.
156
- if (hits && !out.some(e => e.type === "row")) out.push({ type: "label", key: "l:none", text: "No workspace matches." });
157
- else if (touch && !filter && !hits && model.groups.every(g => !g.items.length)) out.push({ type: "empty", key: "l:nothing" });
158
- return out;
159
- if (filter && !out.length) out.push({ type: "label", key: "l:empty", text: `Nothing in ${GROUP_TITLE[filter as HomeGroupId]} right now.` });
160
- return out;
161
- }, [model, closed, openProjects, pages, briefLine, results, hits, filter, !!overseer, touch, !!afterNeeds]);
112
+ const data = useMemo(() => listEntries({ model, closed, openProjects, pages, briefLine, results, hits, filter, overseer: !!overseer, touch, afterNeeds: !!afterNeeds }),
113
+ // eslint-disable-next-line react-hooks/exhaustive-deps
114
+ [model, closed, openProjects, pages, briefLine, results, hits, filter, !!overseer, touch, !!afterNeeds]);
162
115
  // A result picks through onResult; Row only knows its key.
163
116
  const pickResult = useCallback((key: string) => {
164
117
  const item = results?.find(i => !i.ask && i.key === key);
@@ -182,7 +135,7 @@ export function HomeList({ model, theme, dense = false, touch, selectedKey, onSe
182
135
  onSelect={pickResult} onMenu={item.archived ? noMenu : onMenu} />;
183
136
  case "ask": return <AskRow ask={item.ask} theme={theme} active={item.index === activeResult} dense={dense} touch={touch} sending={!!asking} onPress={() => onResult?.({ provider: "overseer", key: ASK_KEY, ask: item.ask })} />;
184
137
  case "brief": return <BriefRow theme={theme} line={briefLine ?? ""} selected={!touch && (selectedKey === null || selectedKey === BRIEF_KEY)} touch={touch} onSelect={onSelect} />;
185
- case "overseer": return overseer ? <OverseerRow theme={theme} o={overseer} selected={selectedKey === OVERSEER_KEY} touch={touch} stacked={stackOverseer} onSelect={onSelect} /> : null;
138
+ case "overseer": return overseer ? <OverseerRow theme={theme} o={overseer} selected={selectedKey === OVERSEER_KEY} touch={touch} stacked={stackOverseer} onSelect={onSelect} selectedBg={selectedBg} /> : null;
186
139
  case "header": return <GroupHeader theme={theme} title={item.title} count={item.count} open={item.open} tone={item.group === "needs" && item.count ? c.statusWarning : undefined} dense={dense} touch={touch} onPress={() => toggle(item.group)} />;
187
140
  case "fold": return <Pressable accessibilityRole="button" aria-expanded={item.open} accessibilityState={{ expanded: item.open }} accessibilityLabel={`${item.project}, ${item.count}. ${item.open ? "Collapse" : "Expand"}`} onPress={() => toggleProject(item.project)}
188
141
  style={state => ({ flexDirection: "row", alignItems: "center", gap: 8, minHeight: touch ? 44 : dense ? 28 : 34, paddingHorizontal: dense ? 8 : 16, backgroundColor: (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
@@ -198,14 +151,26 @@ export function HomeList({ model, theme, dense = false, touch, selectedKey, onSe
198
151
  case "row": {
199
152
  const selected = selectedKey === item.key;
200
153
  return <View>
201
- <Row s={item.s} theme={theme} dense={dense} touch={touch} selected={selected} onSelect={onSelect} sig={item.s.sig} onMenu={onMenu} menuOpen={menuKey === item.key} hit={item.hit} onSendNow={onSendNow} />
154
+ <Row s={item.s} theme={theme} dense={dense} touch={touch} selected={selected} onSelect={onSelect} sig={item.s.sig} onMenu={onMenu} menuOpen={menuKey === item.key} hit={item.hit} onSendNow={onSendNow} selectedBg={selectedBg} />
202
155
  {selected && renderExpanded ? renderExpanded(item.s) : null}
203
156
  </View>;
204
157
  }
205
158
  }
206
- }, [theme, c, dense, touch, selectedKey, onSelect, briefLine, renderExpanded, toggle, toggleProject, activeResult, onResult, pickResult, model, overseer?.state, overseer?.line, overseer?.ranges, stackOverseer, asking, afterNeeds, emptyAction, onMenu, menuKey, onSendNow]);
159
+ }, [theme, c, dense, touch, selectedKey, onSelect, briefLine, renderExpanded, toggle, toggleProject, activeResult, onResult, pickResult, model, overseer?.state, overseer?.line, overseer?.ranges, stackOverseer, asking, afterNeeds, emptyAction, onMenu, menuKey, onSendNow, selectedBg]);
207
160
 
208
- const listRef = useRef<FlatList<Entry>>(null);
161
+ const listRef = useRef<NativeFlatList<Entry>>(null);
162
+ const rootRef = useRef<View>(null);
163
+ // The keyboard walk: the rows as drawn, the brief and the Overseer first (they're rows too). A search walks its
164
+ // results through the omnibox instead.
165
+ const order = useMemo(() => results ? [] : walkOrder(data), [data, results]);
166
+ useListKeys({
167
+ enabled: !!keys && !touch && !results, order, mode: keys?.mode ?? "focus",
168
+ // Home draws the brief as selected while nothing is.
169
+ selectedKey: selectedKey ?? (order[0] === BRIEF_KEY ? BRIEF_KEY : null),
170
+ scope: () => (keys?.scope?.current ?? rootRef.current) as { contains(n: unknown): boolean; checkVisibility?(): boolean } | null,
171
+ claimBody: keys?.claimBody, onSelect, onOpen: key => keys?.onOpen(key),
172
+ reveal: key => { const index = data.findIndex(e => e.key === key); if (index >= 0) listRef.current?.scrollToIndex({ index, viewPosition: 0.5, animated: false }); },
173
+ });
209
174
  // Keep the keyboard-active result in view.
210
175
  useEffect(() => {
211
176
  if (!results?.length) return;
@@ -218,7 +183,7 @@ export function HomeList({ model, theme, dense = false, touch, selectedKey, onSe
218
183
  style={{ flex: 1 }} contentContainerStyle={{ paddingBottom: 8 }} keyboardShouldPersistTaps="handled" />;
219
184
  const overlay = openMenu ? <RowMenu key={`${openMenu.s.key}:${openMenu.anchor?.x ?? "sheet"}:${openMenu.anchor?.y ?? ""}`} menu={openMenu} theme={theme} onClose={() => setOpenMenu(null)} onPick={item => menu.pick(openMenu.s, item)} /> : null;
220
185
  // The wrapper is always there, so opening the menu never remounts the list (and its scroll).
221
- return <View style={{ flex: 1, minHeight: 0 }}>{top}{list}{overlay}</View>;
186
+ return <View ref={rootRef} style={{ flex: 1, minHeight: 0 }}>{top}{list}{overlay}</View>;
222
187
  }
223
188
 
224
189
  function GroupHeader({ theme, title, count, open, tone, dense, touch, onPress }: { theme: Theme; title: string; count: number; open: boolean; tone?: string; dense: boolean; touch: boolean; onPress: () => void }) {
@@ -235,8 +200,8 @@ function GroupHeader({ theme, title, count, open, tone, dense, touch, onPress }:
235
200
 
236
201
  function BriefRow({ theme, line, selected, touch, onSelect }: { theme: Theme; line: string; selected: boolean; touch: boolean; onSelect: (key: string) => void }) {
237
202
  const c = theme.colors;
238
- return <Pressable accessibilityRole="button" accessibilityState={{ selected }} accessibilityLabel={`Morning brief. ${line}`} onPress={() => onSelect(BRIEF_KEY)}
239
- style={state => ({ flexDirection: "row", alignItems: "center", gap: 10, minHeight: touch ? 52 : 40, paddingHorizontal: 16, backgroundColor: selected ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
203
+ return <Pressable nativeID={rowDomId(BRIEF_KEY)} accessibilityRole="button" accessibilityState={{ selected }} accessibilityLabel={`Morning brief. ${line}`} onPress={() => onSelect(BRIEF_KEY)}
204
+ style={state => ({ ...focusRing((state as { focused?: boolean }).focused, c, true), flexDirection: "row", alignItems: "center", gap: 10, minHeight: touch ? 52 : 40, paddingHorizontal: 16, backgroundColor: selected ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
240
205
  <Icon name="Sun" size={touch ? 16 : 15} color={c.foregroundMuted} />
241
206
  <Text style={{ color: c.foreground, fontSize: touch ? 14 : 13, fontWeight: "600" }}>Morning brief</Text>
242
207
  <Text numberOfLines={1} style={{ flex: 1, color: c.foregroundMuted, fontSize: touch ? 13 : 12 }}>{line}</Text>
@@ -244,18 +209,18 @@ function BriefRow({ theme, line, selected, touch, onSelect }: { theme: Theme; li
244
209
  </Pressable>;
245
210
  }
246
211
 
247
- function OverseerRow({ theme, o, selected, touch, stacked = false, onSelect }: { theme: Theme; o: OverseerRowState; selected: boolean; touch: boolean; stacked?: boolean; onSelect: (key: string) => void }) {
212
+ function OverseerRow({ theme, o, selected, touch, stacked = false, onSelect, selectedBg }: { theme: Theme; o: OverseerRowState; selected: boolean; touch: boolean; stacked?: boolean; onSelect: (key: string) => void; selectedBg?: string }) {
248
213
  const c = theme.colors;
249
214
  const tone = o.state === "asks" ? c.statusWarning : o.state === "error" ? c.statusDanger : o.state === "running" ? runningColor(c) : c.foregroundMuted;
250
215
  const icon = o.state === "running" ? <Spinner color={tone} size={13} label="Overseer working" /> : <Icon name="MessagesSquare" size={touch ? 16 : 15} color={o.state === "idle" || o.state === "start" ? c.foregroundMuted : tone} />;
251
216
  const lineColor = o.state === "asks" || o.state === "error" ? tone : c.foregroundMuted;
252
217
  // Wide Home: one line, the phone's shorter start line. Stacked (the sidebar view): the whole line, wrapping to two.
253
218
  const line = marks(!stacked && touch && o.state === "start" ? "Ask about any workspace" : o.line, stacked || !(touch && o.state === "start") ? o.ranges : null, c);
254
- return <Pressable accessibilityRole="button" accessibilityState={{ selected }} accessibilityLabel={`Overseer. ${o.line}`} onPress={() => onSelect(OVERSEER_KEY)}
255
- style={state => ({ flexDirection: "row", alignItems: stacked ? "flex-start" : "center", gap: 10, minHeight: touch ? 52 : 40, paddingLeft: 14, paddingRight: 16, paddingVertical: stacked ? (touch ? 12 : 8) : 0, borderBottomWidth: 1, borderBottomColor: c.border,
219
+ return <Pressable nativeID={rowDomId(OVERSEER_KEY)} accessibilityRole="button" accessibilityState={{ selected }} accessibilityLabel={`Overseer. ${o.line}`} onPress={() => onSelect(OVERSEER_KEY)}
220
+ style={state => ({ ...focusRing((state as { focused?: boolean }).focused, c, true), flexDirection: "row", alignItems: stacked ? "flex-start" : "center", gap: 10, minHeight: touch ? 52 : 40, paddingLeft: 14, paddingRight: 16, paddingVertical: stacked ? (touch ? 12 : 8) : 0, borderBottomWidth: 1, borderBottomColor: c.border,
256
221
  // Its ask isn't a Needs-you row (it's yours to route), so the edge marks it the way blocking rows are marked.
257
222
  borderLeftWidth: 2, borderLeftColor: o.state === "asks" || o.state === "error" ? withAlpha(tone, 0.9) : "transparent",
258
- backgroundColor: selected ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
223
+ backgroundColor: selected ? selectedBg ?? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
259
224
  {stacked ? <View style={{ paddingTop: 2 }}>{icon}</View> : icon}
260
225
  {stacked
261
226
  ? <View style={{ flex: 1, gap: 2 }}>
@@ -329,22 +294,17 @@ export function Age({ iso, c, size = 12 }: { iso: string | null; c: Colors; size
329
294
  /** Matched words, highlighted inside a line of text: the hit colour, semibold, on a light warning tint. */
330
295
  export function marks(text: string, ranges: Range[] | null | undefined, c: Colors): ReactNode {
331
296
  if (!ranges?.length) return text;
332
- return highlightRuns(text, ranges).map((r, i) => r.hit ? <Text key={i} style={{ color: c.foreground, fontWeight: "600", backgroundColor: withAlpha(c.statusWarning, 0.22), borderRadius: 2 }}>{r.text}</Text> : r.text);
297
+ return marked(text, 0, ranges, c);
333
298
  }
334
299
 
335
- /** A search hit on a workspace Follow-up has archived: a muted row with the Archive glyph, reading "Archived". */
336
- export function archivedRow(hit: SearchHit): Workstream {
337
- return { key: hit.key, agentId: null, workspaceId: hit.key.startsWith("ws:") ? hit.key.slice(3) : null, title: hit.title, agent: null, project: null, group: "quiet", tier: null,
338
- icon: "Archive", tone: "muted", line: "Archived", word: null, badges: [], pr: null, at: null, readyToArchive: false, sig: `archived:${hit.key}` } as unknown as Workstream;
339
- }
340
300
 
341
301
  /**
342
302
  * One row component for every list, Home's groups and search results alike (search-row-is-the-list-row). A search
343
303
  * passes `hit`: the matched words are highlighted where they already are (title, "› agent", the ask line), and a match
344
304
  * in a field the row doesn't show replaces line 2 with "<Field> · excerpt", so a result is exactly as tall as the row.
345
305
  */
346
- type RowProps = { s: Workstream; sig: string; theme: Theme; dense: boolean; touch: boolean; selected: boolean; onSelect: (key: string) => void; onMenu: OpenRowMenu; menuOpen?: boolean; hit?: RowHit | null; onSendNow?: (s: Workstream) => Promise<void> };
347
- const Row = memo(function Row({ s, theme, dense, touch, selected, onSelect, onMenu, menuOpen = false, hit = null, onSendNow }: RowProps) {
306
+ type RowProps = { s: Workstream; sig: string; theme: Theme; dense: boolean; touch: boolean; selected: boolean; onSelect: (key: string) => void; onMenu: OpenRowMenu; menuOpen?: boolean; hit?: RowHit | null; onSendNow?: (s: Workstream) => Promise<void>; selectedBg?: string };
307
+ const Row = memo(function Row({ s, theme, dense, touch, selected, onSelect, onMenu, menuOpen = false, hit = null, onSendNow, selectedBg }: RowProps) {
348
308
  const c = theme.colors;
349
309
  const trigger = useRowMenuTrigger(s, onMenu, touch);
350
310
  const archived = s.icon === "Archive" && s.sig.startsWith("archived:");
@@ -368,10 +328,10 @@ const Row = memo(function Row({ s, theme, dense, touch, selected, onSelect, onMe
368
328
  const label = [s.title + (s.agent ? ` › ${s.agent}` : ""), s.word, s.line, hit?.via && `${FIELD_LABEL[hit.via.field]}: ${hit.via.text}`, wake && `Later until ${wake}`, waited && (waited === "now" ? "just now" : `waiting ${waited}`)].filter(Boolean).join(". ");
369
329
  return <Pressable ref={trigger.ref} nativeID={rowDomId(s.key)} accessibilityRole="button" accessibilityState={{ selected }} accessibilityLabel={label} accessibilityHint={quickActionsHint(touch)}
370
330
  onPress={() => onSelect(s.key)} onLongPress={trigger.onLongPress} delayLongPress={450}
371
- style={state => ({ flexDirection: "row", alignItems: dense ? "flex-start" : "center", gap: touch ? 10 : dense ? 8 : 10, minHeight: touch ? 56 : dense ? 36 : 38, paddingLeft: touch ? 14 : dense ? 8 : 16, paddingRight: touch ? 16 : dense ? 8 : 16, paddingVertical: touch ? 12 : dense ? 6 : 0,
331
+ style={state => ({ ...focusRing((state as { focused?: boolean }).focused, c, true), flexDirection: "row", alignItems: dense ? "flex-start" : "center", gap: touch ? 10 : dense ? 8 : 10, minHeight: touch ? 56 : dense ? 36 : 38, paddingLeft: touch ? 14 : dense ? 8 : 16, paddingRight: touch ? 16 : dense ? 8 : 16, paddingVertical: touch ? 12 : dense ? 6 : 0,
372
332
  ...(touch ? { borderBottomWidth: 1, borderBottomColor: withAlpha(c.border, 0.6) } : {}),
373
333
  borderLeftWidth: 2, borderLeftColor: blocking ? withAlpha(color, 0.9) : "transparent",
374
- backgroundColor: selected || menuOpen || state.pressed && touch ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
334
+ backgroundColor: selected ? selectedBg ?? c.surface2 : menuOpen || state.pressed && touch ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
375
335
  <View style={{ width: touch ? 18 : 16, alignItems: "center", paddingTop: touch ? 2 : dense ? 1 : 0 }}>
376
336
  {s.tone === "running" && s.icon === "LoaderCircle" ? <Spinner color={color} size={13} label="Running" /> : <Icon name={s.icon} size={touch ? 17 : 15} color={color} />}
377
337
  </View>
@@ -409,7 +369,7 @@ const Row = memo(function Row({ s, theme, dense, touch, selected, onSelect, onMe
409
369
  </View>{!!s.priority?.reason && <View style={{ paddingRight: 40 }}><PriorityLine reason={s.priority.reason} source={s.priority.source} c={c} /></View>}</View>}
410
370
  {!touch && <RowTime s={s} c={c} size={dense ? 11 : 12} />}
411
371
  </Pressable>;
412
- }, (a, b) => a.sig === b.sig && a.selected === b.selected && a.theme === b.theme && a.dense === b.dense && a.touch === b.touch && a.onSelect === b.onSelect && a.onMenu === b.onMenu && a.menuOpen === b.menuOpen && a.hit === b.hit && a.onSendNow === b.onSendNow);
372
+ }, (a, b) => a.sig === b.sig && a.selected === b.selected && a.theme === b.theme && a.dense === b.dense && a.touch === b.touch && a.onSelect === b.onSelect && a.onMenu === b.onMenu && a.menuOpen === b.menuOpen && a.hit === b.hit && a.onSendNow === b.onSendNow && a.selectedBg === b.selectedBg);
413
373
 
414
374
  /** The machine-wide auto-send hold, once above Sending's rows: the same words on every width (shared/sending.ts). */
415
375
  function HoldLine({ theme, text: line, dense, touch }: { theme: Theme; text: string; dense: boolean; touch: boolean }) {
package/client/home.tsx CHANGED
@@ -1,9 +1,9 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
2
2
  import { browserKey } from "./keys";
3
- import { Platform, ScrollView, TextInput, useWindowDimensions, View } from "react-native";
3
+ import { Platform, TextInput, useWindowDimensions, View } from "react-native";
4
4
  import { Pressable, Text } from "./text";
5
5
  import { usePaseo, useRpc, type PluginScreenProps } from "@getpaseo/plugin/client";
6
- import { Icon, Modal, useToast } from "@getpaseo/plugin/client/ui";
6
+ import { Icon, ScrollView, Modal, useToast } from "@getpaseo/plugin/client/ui";
7
7
  import { useQuery } from "@tanstack/react-query";
8
8
  import { browserStatusRpc, controlRpc, inboxBriefRpc, sendRpc } from "../shared/contracts";
9
9
  import { needsYou, workspaceSnoozed } from "../shared/attention";
@@ -154,6 +154,8 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
154
154
  setSelected(s.key); setAsk(a => ({ key: s.key, id, n: (a?.n ?? 0) + 1 }));
155
155
  }, [route, deps]);
156
156
  const omniRef = useRef(omnibox); omniRef.current = omnibox;
157
+ // Home's keys count anywhere on Home (the list and its detail), not just in the list.
158
+ const homeRef = useRef<View>(null);
157
159
  const prefillAsk = useCallback((text: string) => { omniRef.current.setQuery(text); setTimeout(() => omniRef.current.inputRef.current?.focus(), 0); }, []);
158
160
  const rowMenu = useRowMenu({ sources: deps.sources, openFull, openQuestion, prefillAsk, overseerOn: !!overseerStatus?.enabled });
159
161
  const signOffNext = useCallback((s: Workstream) => {
@@ -177,7 +179,13 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
177
179
  : <BriefPane theme={theme} compact={compact} pane={pane} onSelect={key => route ? route(key) : setSelected(key)} openLog={deps.openLog} sources={deps.sources} />;
178
180
  // Nothing followed at all: no sort, no meters, just the empty state and its action.
179
181
  const nothing = model.groups.every(g => !g.items.length);
182
+ // Enter on a row: its chat, as Open full does. The brief has nothing to open; the Overseer opens once it runs.
183
+ const openKey = (key: string) => {
184
+ if (key === OVERSEER_KEY) { const id = overseerStatus?.agentId; if (id && navigation) navigation.openAgent({ agentId: id }); return; }
185
+ const s = model.byKey.get(key); if (s) openFull(s);
186
+ };
180
187
  const list = <HomeList model={model} theme={theme} dense={compact} touch={compact} selectedKey={selected} onSelect={onSelect} briefLine={briefLine}
188
+ keys={{ mode: "select", onOpen: openKey, scope: homeRef, claimBody: true }}
181
189
  results={omnibox.results} activeResult={omnibox.active} onResult={item => void pick(item)} filter={filter} overseer={overseer} asking={asking} menu={rowMenu} onSendNow={sendNow}
182
190
  // Phones: the host header already says Follow-up, so no "Home" title row; search, sort and settings share one row and
183
191
  // the meters move to the end of the list.
@@ -216,7 +224,7 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
216
224
  {updateSheets}
217
225
  <View style={{ position: "absolute", left: 12, right: 12, bottom: bottomGap(true) + (current || selected === OVERSEER_KEY ? 132 : 0) }}><UndoBar store={inbox} theme={theme} touch /></View>
218
226
  </View>;
219
- return <View style={{ flex: 1, flexDirection: "row", backgroundColor: c.surface0 }}>
227
+ return <View ref={homeRef} style={{ flex: 1, flexDirection: "row", backgroundColor: c.surface0 }}>
220
228
  <View style={{ flex: 1, minWidth: 0, borderRightWidth: 1, borderRightColor: c.border }}>
221
229
  {list}
222
230
  {updateSheets}
package/client/kit.tsx CHANGED
@@ -153,14 +153,14 @@ export function PrLinkButton({ link, theme, compact = false }: { link: { url: st
153
153
  </PressScale></View>;
154
154
  }
155
155
 
156
- export function IconButton({ icon, label, onPress, theme, compact = false, disabled = false, spinning = false, color, tooltip = false }: { icon: string; label: string; onPress: () => void; theme: Theme; compact?: boolean; disabled?: boolean; spinning?: boolean; color?: string; tooltip?: boolean }) {
156
+ export function IconButton({ icon, label, onPress, theme, compact = false, disabled = false, spinning = false, color, tooltip = false, nativeID }: { icon: string; label: string; onPress: () => void; theme: Theme; compact?: boolean; disabled?: boolean; spinning?: boolean; color?: string; tooltip?: boolean; nativeID?: string }) {
157
157
  const c = theme.colors;
158
158
  const size = compact ? 44 : 28;
159
159
  // tooltip: the label as the desktop hover title. React Native Web drops `title` on a Pressable, so it goes on a
160
160
  // wrapper's DOM node (the client/linked.tsx pattern).
161
161
  const tip = useRef<View | null>(null);
162
162
  useEffect(() => { if (tooltip && Platform.OS === "web") (tip.current as unknown as { setAttribute?: (k: string, v: string) => void } | null)?.setAttribute?.("title", label); }, [tooltip, label]);
163
- const button = <PressScale accessibilityRole="button" accessibilityLabel={label} disabled={disabled} onPress={onPress} hitSlop={compact ? 0 : 6}
163
+ const button = <PressScale nativeID={nativeID} accessibilityRole="button" accessibilityLabel={label} disabled={disabled} onPress={onPress} hitSlop={compact ? 0 : 6}
164
164
  style={({ pressed, hovered }) => ({ width: size, height: size, borderRadius: 6, alignItems: "center", justifyContent: "center", backgroundColor: pressed ? c.surface2 : hovered ? c.surface1 : "transparent", opacity: disabled && !spinning ? 0.45 : 1 })}>
165
165
  {spinning ? <Spinner color={color ?? c.foregroundMuted} size={14} label={label} /> : <Icon name={icon} size={compact ? 18 : 15} color={color ?? c.foregroundMuted} />}
166
166
  </PressScale>;
@@ -168,9 +168,12 @@ export function IconButton({ icon, label, onPress, theme, compact = false, disab
168
168
  }
169
169
 
170
170
  export type CardTone = "plain" | "attention" | "success";
171
- /** A raised container with an icon title. Attention cards trade the ring for a warning border. */
172
- export function Card({ theme, icon, title, tone = "plain", count, right, children, compact = false, style }: {
173
- theme: Theme; icon: string; title: string; tone?: CardTone; count?: string | number; right?: ReactNode; children: ReactNode; compact?: boolean; style?: StyleProp<ViewStyle>;
171
+ /**
172
+ * A raised container with an icon title. Attention cards trade the ring for a warning border. `search`: the section
173
+ * is being searched (client/section-search.tsx), and its field takes the title's place in the header.
174
+ */
175
+ export function Card({ theme, icon, title, tone = "plain", count, right, children, compact = false, style, search }: {
176
+ theme: Theme; icon: string; title: string; tone?: CardTone; count?: string | number; right?: ReactNode; children: ReactNode; compact?: boolean; style?: StyleProp<ViewStyle>; search?: ReactNode;
174
177
  }) {
175
178
  const c = theme.colors;
176
179
  const accent = tone === "attention" ? c.statusWarning : tone === "success" ? c.statusSuccess : null;
@@ -178,10 +181,12 @@ export function Card({ theme, icon, title, tone = "plain", count, right, childre
178
181
  accent ? { borderWidth: 1, borderColor: withAlpha(accent, 0.7) } : raised(c), style]}>
179
182
  <View style={{ flexDirection: "row", alignItems: "center", gap: compact ? 8 : 7, paddingHorizontal: compact ? 14 : 12, paddingTop: 10, paddingBottom: 8, minHeight: compact ? 44 : undefined }}>
180
183
  <Icon name={icon} size={compact ? 16 : 14} color={accent ?? c.foregroundMuted} />
181
- <Text accessibilityRole="header" style={{ color: accent ?? c.foreground, fontSize: compact ? 14 : 13, lineHeight: compact ? 20 : 18, fontWeight: "600" }}>{title}</Text>
182
- {count !== undefined && count !== "" && <Chip theme={theme} color={accent ?? c.foregroundMuted} label={String(count)} />}
183
- <View style={{ flex: 1 }} />
184
- {right}
184
+ {search ?? <>
185
+ <Text accessibilityRole="header" style={{ color: accent ?? c.foreground, fontSize: compact ? 14 : 13, lineHeight: compact ? 20 : 18, fontWeight: "600" }}>{title}</Text>
186
+ {count !== undefined && count !== "" && <Chip theme={theme} color={accent ?? c.foregroundMuted} label={String(count)} />}
187
+ <View style={{ flex: 1 }} />
188
+ {right}
189
+ </>}
185
190
  </View>
186
191
  {children}
187
192
  </View>;
@@ -241,5 +246,10 @@ export function focusSoon(id: string, tries = 20): void {
241
246
  if (el) { el.focus(); return; }
242
247
  if (tries > 0) setTimeout(() => focusSoon(id, tries - 1), 50);
243
248
  }
249
+ /** Web: the focus came from the keyboard (:focus-visible), so a click never draws the ring. */
250
+ export const keyboardFocus = () => { try { return !!(globalThis as { document?: { activeElement?: { matches?(q: string): boolean } | null } }).document?.activeElement?.matches?.(":focus-visible"); } catch { return true; } };
251
+ /** The keyboard focus ring: buttons ring outside (offset 2); list rows ring inside their own bounds (`inset`). */
252
+ export const focusRing = (focused: boolean | undefined, c: Colors, inset = false) => focused && Platform.OS === "web" && keyboardFocus()
253
+ ? ({ outlineWidth: 2, outlineStyle: "solid", outlineColor: withAlpha(c.accent, 0.6), outlineOffset: inset ? -2 : 2 } as object) : {};
244
254
  /** The DOM id of a Home row, for focusSoon. */
245
255
  export const rowDomId = (key: string) => `follow-up-row-${key.replace(/[^\w-]/g, "_")}`;