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

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/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 }) {
@@ -92,7 +92,9 @@ 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
+ function QueryField({ theme, value, onChange, placeholder, icon, dense, inputRef, slashHint, onSubmit, onArrow, listKeys = false }: {
96
+ /** Its arrows step into the list below (client/list-keys.ts): the sidebar filter, and Home's search while empty. */
97
+ listKeys?: boolean;
96
98
  theme: Theme; value: string; onChange: (q: string) => void; placeholder: string; icon: string; dense: boolean;
97
99
  inputRef: { current: TextInput | null }; slashHint: boolean; onSubmit?: () => void; onArrow?: (delta: number) => void;
98
100
  }) {
@@ -103,6 +105,7 @@ function QueryField({ theme, value, onChange, placeholder, icon, dense, inputRef
103
105
  <Icon name={icon as never} size={dense ? 16 : 13} color={c.foregroundMuted} />
104
106
  <TextInput ref={inputRef} value={value} onChangeText={onChange} placeholder={placeholder} placeholderTextColor={c.foregroundMuted}
105
107
  accessibilityLabel={placeholder} autoCorrect={false} autoCapitalize="none" spellCheck={false} returnKeyType="go"
108
+ {...(listKeys ? { dataSet: { listKeys: "1" } } as object : {})}
106
109
  onFocus={() => setFocused(true)} onBlur={() => setFocused(false)}
107
110
  onSubmitEditing={onSubmit}
108
111
  onKeyPress={e => {
@@ -123,7 +126,7 @@ export function SearchField({ theme, omnibox, dense, onEnter }: { theme: Theme;
123
126
  const { query, setQuery, results, active, move, inputRef, askOn } = omnibox;
124
127
  const placeholder = askOn ? dense ? "Search or ask the Overseer" : "Search, or ask the Overseer" : "Search workspaces, branches, PRs";
125
128
  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} />;
129
+ onSubmit={() => { const item = results?.[active]; if (item) onEnter(item); }} onArrow={move} listKeys={!query.trim()} />;
127
130
  }
128
131
 
129
132
  /**
@@ -148,7 +151,7 @@ export function useListFilter(model: HomeModel, sources: HomeSources): ListFilte
148
151
  }
149
152
  /** "Filter workspaces": a filter icon and no key binding, so it never reads as Paseo's own Search (the Command Center, ⌘K). */
150
153
  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} />;
154
+ return <QueryField theme={theme} value={filter.query} onChange={filter.setQuery} placeholder="Filter workspaces" icon="ListFilter" dense={dense} inputRef={filter.inputRef} slashHint={false} listKeys />;
152
155
  }
153
156
 
154
157
  // ---------- sort ----------
@@ -2,14 +2,17 @@ import { memo, useCallback, useEffect, useMemo, useRef, useState, type ReactNode
2
2
  import { FlatList, View } from "react-native";
3
3
  import { Pressable, Text } from "./text";
4
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";
5
+ import { type Badge, type HomeGroupId, type HomeModel, type Workstream } from "../shared/home";
6
+ import { ASK_KEY, excerpt, FIELD_LABEL, highlightRuns, 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
11
  import { Spinner } from "./motion";
12
- import { Button, rowDomId, type Theme } from "./kit";
12
+ import { Button, focusRing, rowDomId, type Theme } from "./kit";
13
+ import { useListKeys } from "./list-keys";
14
+ import { walkOrder } from "../shared/list-keys";
15
+ import { BRIEF_KEY, OVERSEER_KEY, QUIET_PAGE, listEntries, type Entry } from "../shared/list-entries";
13
16
  import { RowMenu, useRowMenuTrigger, type OpenRowMenu, type RowMenuOpen } from "./row-menu";
14
17
  import type { RowMenuItem, RowMenuSection } from "../shared/row-menu";
15
18
  import { homeGroupOpen, writeHomeGroupOpen } from "../shared/settings-nav";
@@ -21,27 +24,12 @@ import { useViewVersion } from "./view-store";
21
24
  * that changes one row redraws only that row.
22
25
  */
23
26
 
24
- const QUIET_PAGE = 20;
25
- export const BRIEF_KEY = "brief";
26
- export const OVERSEER_KEY = "overseer";
27
+ export { BRIEF_KEY, OVERSEER_KEY, archivedRow } from "../shared/list-entries";
27
28
  /** The pinned Overseer row: not started yet (a one-time Start), working, asking, idle, or failed to come back. */
28
29
  export type OverseerRowState = { state: "start" | "idle" | "running" | "asks" | "error"; line: string;
29
30
  /** A list filter's match in `line`, highlighted like a row's (the sidebar view's "Filter workspaces"). */
30
31
  ranges?: Range[] };
31
32
 
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
33
 
46
34
  export type HomeListProps = {
47
35
  model: HomeModel;
@@ -88,11 +76,20 @@ export type HomeListProps = {
88
76
  * own Copy/Paste menu opens instead.
89
77
  */
90
78
  menu: { build: (s: Workstream) => RowMenuSection[]; pick: (s: Workstream, item: RowMenuItem) => void };
79
+ /**
80
+ * Desktop and web keys (client/list-keys.ts, one-keyboard-walk-for-every-list): ↑/↓ and j/k walk the rows in this
81
+ * list's order, Home/End jump, Enter opens. "select" moves the selection (Home); "focus" moves only the focus and
82
+ * Enter opens (the sidebar view). `scope`: where the keys count (default: this list); `claimBody`: also with
83
+ * nothing focused.
84
+ */
85
+ keys?: { mode: "select" | "focus"; onOpen: (key: string) => void; scope?: { current: unknown }; claimBody?: boolean };
86
+ /** The selected row's fill. Paseo's sidebar view passes its own selected-item colour (sidebarSelected); Home: surface2. */
87
+ selectedBg?: string;
91
88
  };
92
89
 
93
90
  const noMenu: OpenRowMenu = () => undefined;
94
91
 
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) {
92
+ 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
93
  const c = theme.colors;
97
94
  const [openMenu, setOpenMenu] = useState<RowMenuOpen | null>(null);
98
95
  const build = menu.build;
@@ -111,54 +108,9 @@ export function HomeList({ model, theme, dense = false, touch, selectedKey, onSe
111
108
  const toggle = useCallback((key: string) => { if (key === "needs") setNeedsClosed(v => !v); else writeHomeGroupOpen(key, !homeGroupOpen(key)); }, []);
112
109
  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
110
 
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]);
111
+ const data = useMemo(() => listEntries({ model, closed, openProjects, pages, briefLine, results, hits, filter, overseer: !!overseer, touch, afterNeeds: !!afterNeeds }),
112
+ // eslint-disable-next-line react-hooks/exhaustive-deps
113
+ [model, closed, openProjects, pages, briefLine, results, hits, filter, !!overseer, touch, !!afterNeeds]);
162
114
  // A result picks through onResult; Row only knows its key.
163
115
  const pickResult = useCallback((key: string) => {
164
116
  const item = results?.find(i => !i.ask && i.key === key);
@@ -182,7 +134,7 @@ export function HomeList({ model, theme, dense = false, touch, selectedKey, onSe
182
134
  onSelect={pickResult} onMenu={item.archived ? noMenu : onMenu} />;
183
135
  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
136
  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;
137
+ case "overseer": return overseer ? <OverseerRow theme={theme} o={overseer} selected={selectedKey === OVERSEER_KEY} touch={touch} stacked={stackOverseer} onSelect={onSelect} selectedBg={selectedBg} /> : null;
186
138
  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
139
  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
140
  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 +150,26 @@ export function HomeList({ model, theme, dense = false, touch, selectedKey, onSe
198
150
  case "row": {
199
151
  const selected = selectedKey === item.key;
200
152
  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} />
153
+ <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
154
  {selected && renderExpanded ? renderExpanded(item.s) : null}
203
155
  </View>;
204
156
  }
205
157
  }
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]);
158
+ }, [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
159
 
208
160
  const listRef = useRef<FlatList<Entry>>(null);
161
+ const rootRef = useRef<View>(null);
162
+ // The keyboard walk: the rows as drawn, the brief and the Overseer first (they're rows too). A search walks its
163
+ // results through the omnibox instead.
164
+ const order = useMemo(() => results ? [] : walkOrder(data), [data, results]);
165
+ useListKeys({
166
+ enabled: !!keys && !touch && !results, order, mode: keys?.mode ?? "focus",
167
+ // Home draws the brief as selected while nothing is.
168
+ selectedKey: selectedKey ?? (order[0] === BRIEF_KEY ? BRIEF_KEY : null),
169
+ scope: () => (keys?.scope?.current ?? rootRef.current) as { contains(n: unknown): boolean; checkVisibility?(): boolean } | null,
170
+ claimBody: keys?.claimBody, onSelect, onOpen: key => keys?.onOpen(key),
171
+ reveal: key => { const index = data.findIndex(e => e.key === key); if (index >= 0) listRef.current?.scrollToIndex({ index, viewPosition: 0.5, animated: false }); },
172
+ });
209
173
  // Keep the keyboard-active result in view.
210
174
  useEffect(() => {
211
175
  if (!results?.length) return;
@@ -218,7 +182,7 @@ export function HomeList({ model, theme, dense = false, touch, selectedKey, onSe
218
182
  style={{ flex: 1 }} contentContainerStyle={{ paddingBottom: 8 }} keyboardShouldPersistTaps="handled" />;
219
183
  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
184
  // 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>;
185
+ return <View ref={rootRef} style={{ flex: 1, minHeight: 0 }}>{top}{list}{overlay}</View>;
222
186
  }
223
187
 
224
188
  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 +199,8 @@ function GroupHeader({ theme, title, count, open, tone, dense, touch, onPress }:
235
199
 
236
200
  function BriefRow({ theme, line, selected, touch, onSelect }: { theme: Theme; line: string; selected: boolean; touch: boolean; onSelect: (key: string) => void }) {
237
201
  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" })}>
202
+ return <Pressable nativeID={rowDomId(BRIEF_KEY)} accessibilityRole="button" accessibilityState={{ selected }} accessibilityLabel={`Morning brief. ${line}`} onPress={() => onSelect(BRIEF_KEY)}
203
+ 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
204
  <Icon name="Sun" size={touch ? 16 : 15} color={c.foregroundMuted} />
241
205
  <Text style={{ color: c.foreground, fontSize: touch ? 14 : 13, fontWeight: "600" }}>Morning brief</Text>
242
206
  <Text numberOfLines={1} style={{ flex: 1, color: c.foregroundMuted, fontSize: touch ? 13 : 12 }}>{line}</Text>
@@ -244,18 +208,18 @@ function BriefRow({ theme, line, selected, touch, onSelect }: { theme: Theme; li
244
208
  </Pressable>;
245
209
  }
246
210
 
247
- function OverseerRow({ theme, o, selected, touch, stacked = false, onSelect }: { theme: Theme; o: OverseerRowState; selected: boolean; touch: boolean; stacked?: boolean; onSelect: (key: string) => void }) {
211
+ 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
212
  const c = theme.colors;
249
213
  const tone = o.state === "asks" ? c.statusWarning : o.state === "error" ? c.statusDanger : o.state === "running" ? runningColor(c) : c.foregroundMuted;
250
214
  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
215
  const lineColor = o.state === "asks" || o.state === "error" ? tone : c.foregroundMuted;
252
216
  // Wide Home: one line, the phone's shorter start line. Stacked (the sidebar view): the whole line, wrapping to two.
253
217
  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,
218
+ return <Pressable nativeID={rowDomId(OVERSEER_KEY)} accessibilityRole="button" accessibilityState={{ selected }} accessibilityLabel={`Overseer. ${o.line}`} onPress={() => onSelect(OVERSEER_KEY)}
219
+ 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
220
  // 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
221
  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" })}>
222
+ backgroundColor: selected ? selectedBg ?? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
259
223
  {stacked ? <View style={{ paddingTop: 2 }}>{icon}</View> : icon}
260
224
  {stacked
261
225
  ? <View style={{ flex: 1, gap: 2 }}>
@@ -332,19 +296,14 @@ export function marks(text: string, ranges: Range[] | null | undefined, c: Color
332
296
  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);
333
297
  }
334
298
 
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
299
 
341
300
  /**
342
301
  * One row component for every list, Home's groups and search results alike (search-row-is-the-list-row). A search
343
302
  * passes `hit`: the matched words are highlighted where they already are (title, "› agent", the ask line), and a match
344
303
  * 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
304
  */
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) {
305
+ 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 };
306
+ const Row = memo(function Row({ s, theme, dense, touch, selected, onSelect, onMenu, menuOpen = false, hit = null, onSendNow, selectedBg }: RowProps) {
348
307
  const c = theme.colors;
349
308
  const trigger = useRowMenuTrigger(s, onMenu, touch);
350
309
  const archived = s.icon === "Archive" && s.sig.startsWith("archived:");
@@ -368,10 +327,10 @@ const Row = memo(function Row({ s, theme, dense, touch, selected, onSelect, onMe
368
327
  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
328
  return <Pressable ref={trigger.ref} nativeID={rowDomId(s.key)} accessibilityRole="button" accessibilityState={{ selected }} accessibilityLabel={label} accessibilityHint={quickActionsHint(touch)}
370
329
  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,
330
+ 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
331
  ...(touch ? { borderBottomWidth: 1, borderBottomColor: withAlpha(c.border, 0.6) } : {}),
373
332
  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" })}>
333
+ backgroundColor: selected ? selectedBg ?? c.surface2 : menuOpen || state.pressed && touch ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
375
334
  <View style={{ width: touch ? 18 : 16, alignItems: "center", paddingTop: touch ? 2 : dense ? 1 : 0 }}>
376
335
  {s.tone === "running" && s.icon === "LoaderCircle" ? <Spinner color={color} size={13} label="Running" /> : <Icon name={s.icon} size={touch ? 17 : 15} color={color} />}
377
336
  </View>
@@ -409,7 +368,7 @@ const Row = memo(function Row({ s, theme, dense, touch, selected, onSelect, onMe
409
368
  </View>{!!s.priority?.reason && <View style={{ paddingRight: 40 }}><PriorityLine reason={s.priority.reason} source={s.priority.source} c={c} /></View>}</View>}
410
369
  {!touch && <RowTime s={s} c={c} size={dense ? 11 : 12} />}
411
370
  </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);
371
+ }, (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
372
 
414
373
  /** The machine-wide auto-send hold, once above Sending's rows: the same words on every width (shared/sending.ts). */
415
374
  function HoldLine({ theme, text: line, dense, touch }: { theme: Theme; text: string; dense: boolean; touch: boolean }) {
package/client/home.tsx CHANGED
@@ -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
@@ -241,5 +241,10 @@ export function focusSoon(id: string, tries = 20): void {
241
241
  if (el) { el.focus(); return; }
242
242
  if (tries > 0) setTimeout(() => focusSoon(id, tries - 1), 50);
243
243
  }
244
+ /** Web: the focus came from the keyboard (:focus-visible), so a click never draws the ring. */
245
+ export const keyboardFocus = () => { try { return !!(globalThis as { document?: { activeElement?: { matches?(q: string): boolean } | null } }).document?.activeElement?.matches?.(":focus-visible"); } catch { return true; } };
246
+ /** The keyboard focus ring: buttons ring outside (offset 2); list rows ring inside their own bounds (`inset`). */
247
+ export const focusRing = (focused: boolean | undefined, c: Colors, inset = false) => focused && Platform.OS === "web" && keyboardFocus()
248
+ ? ({ outlineWidth: 2, outlineStyle: "solid", outlineColor: withAlpha(c.accent, 0.6), outlineOffset: inset ? -2 : 2 } as object) : {};
244
249
  /** The DOM id of a Home row, for focusSoon. */
245
250
  export const rowDomId = (key: string) => `follow-up-row-${key.replace(/[^\w-]/g, "_")}`;
@@ -0,0 +1,101 @@
1
+ import { useEffect, useRef } from "react";
2
+ import { Platform } from "react-native";
3
+ import { listMove, ownsKey, surfaceVisible, walkTarget } from "../shared/list-keys";
4
+ import { rowDomId } from "./kit";
5
+
6
+ type Row = { focus(o?: { preventScroll?: boolean }): void; scrollIntoView?(o?: { block?: string }): void };
7
+ type Node = { contains(other: unknown): boolean; querySelector?(selector: string): Row | null; checkVisibility?(): boolean; getClientRects?(): { length: number } };
8
+ type Target = { tagName?: string; isContentEditable?: boolean; id?: string; closest?(selector: string): unknown } | null;
9
+ type DomKey = { key: string; metaKey: boolean; ctrlKey: boolean; altKey: boolean; shiftKey: boolean; target: unknown; preventDefault(): void; stopPropagation(): void };
10
+ type Doc = { body: unknown; activeElement: unknown; visibilityState?: string; querySelector(selector: string): Row | null;
11
+ addEventListener(t: string, f: (e: DomKey) => void, capture?: boolean): void; removeEventListener(t: string, f: (e: DomKey) => void, capture?: boolean): void };
12
+
13
+ export type ListKeysOptions = {
14
+ enabled: boolean;
15
+ /** The rows in the order the list draws them (brief, Overseer, then every row of an open group). */
16
+ order: readonly string[];
17
+ /**
18
+ * "select": the selection follows the keys (Home: its detail pane follows). "focus": only the focus moves, and Enter
19
+ * opens the row (the sidebar view: opening loads a chat and moves the main pane, so it waits for Enter).
20
+ */
21
+ mode: "select" | "focus";
22
+ selectedKey: string | null;
23
+ /** The surface the keys belong to: they act only while focus is inside it. */
24
+ scope: () => Node | null;
25
+ /**
26
+ * Keys pressed with nothing focused (the page body) are this surface's too: Home, the main screen. Only while its
27
+ * root is on screen: a Home kept mounted behind another tab or chat leaves body keys to what's in front.
28
+ */
29
+ claimBody?: boolean;
30
+ onSelect: (key: string) => void;
31
+ onOpen: (key: string) => void;
32
+ /** A row the virtualized list hasn't drawn yet: scroll it in, so it can take focus. */
33
+ reveal: (key: string) => void;
34
+ };
35
+
36
+ /**
37
+ * The one keyboard walk for a list of rows (invariant one-keyboard-walk-for-every-list): ↑/↓ and j/k step, Home/End
38
+ * jump, Enter opens. The focus moves with the keys, so the row's focus ring marks it and the browser keeps it in view.
39
+ * Not while typing, except the arrows in the list's own query field (`dataSet={{ listKeys: "1" }}`), which step into
40
+ * the list. Web and desktop only; phones have no hardware-key walk.
41
+ */
42
+ export function useListKeys(options: ListKeysOptions): void {
43
+ const ref = useRef(options); ref.current = options;
44
+ useEffect(() => {
45
+ const doc = (globalThis as { document?: Doc }).document;
46
+ if (!options.enabled || Platform.OS !== "web" || !doc) return;
47
+ const onKey = (e: DomKey) => {
48
+ const { order, mode, selectedKey, scope, claimBody, onSelect, onOpen, reveal } = ref.current;
49
+ const target = e.target as Target;
50
+ const typing = !!target && (!!target.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(target.tagName ?? ""));
51
+ if (typing && !target?.closest?.("[data-list-keys]")) return;
52
+ // A row menu or a dialog over the list keeps its own keys.
53
+ if (target?.closest?.('[role="menu"],[role="dialog"],[aria-modal="true"]')) return;
54
+ const root = scope();
55
+ const onBody = !target || target === doc.body;
56
+ if (!ownsKey({ inside: !!target && !!root?.contains(target), onBody, claimBody: !!claimBody,
57
+ visible: !!claimBody && surfaceVisible(root, doc) })) return;
58
+ const move = listMove(e, typing);
59
+ if (!move) return;
60
+ const focused = !typing && target?.id ? order.find(k => rowDomId(k) === target.id) ?? null : null;
61
+ if (move === "open") {
62
+ // Only a focused row opens: Enter on a header, a chip or a button keeps doing what that control does.
63
+ if (!focused) return;
64
+ e.preventDefault(); e.stopPropagation(); onOpen(focused);
65
+ // The sidebar view: if opening the chat left focus nowhere, give it back to the row, so ↓ ↓ Enter keeps
66
+ // walking. If Paseo put it somewhere (the composer), it stays there: never taken back.
67
+ if (mode === "focus") keepWalking(doc, scope() ?? doc, focused, reveal);
68
+ return;
69
+ }
70
+ const to = walkTarget({ order, focused, selectedKey, mode, typing, move });
71
+ if (!to) return;
72
+ e.preventDefault(); e.stopPropagation();
73
+ if (mode === "select" && to !== selectedKey) onSelect(to);
74
+ focusRow(scope() ?? doc, to, reveal);
75
+ };
76
+ doc.addEventListener("keydown", onKey, true);
77
+ return () => doc.removeEventListener("keydown", onKey, true);
78
+ }, [options.enabled]);
79
+ }
80
+
81
+ /**
82
+ * Focus a row inside this surface: Home and the sidebar view draw the same rows (the same ids) side by side, so the
83
+ * lookup never leaves the surface's own root.
84
+ */
85
+ function keepWalking(doc: Doc, root: Pick<Node, "querySelector">, key: string, reveal: (key: string) => void, waits = [300, 900, 1800]): void {
86
+ const [wait, ...rest] = waits;
87
+ if (wait === undefined) return;
88
+ setTimeout(() => {
89
+ const active = doc.activeElement;
90
+ if (active && active !== doc.body) return;
91
+ focusRow(root, key, reveal);
92
+ keepWalking(doc, root, key, reveal, rest);
93
+ }, wait);
94
+ }
95
+
96
+ function focusRow(root: Pick<Node, "querySelector">, key: string, reveal: (key: string) => void, tries = 10): void {
97
+ const el = root.querySelector?.(`#${rowDomId(key)}`) ?? null;
98
+ if (el) { el.focus({ preventScroll: true }); el.scrollIntoView?.({ block: "nearest" }); return; }
99
+ if (tries === 10) reveal(key);
100
+ if (tries > 0) requestAnimationFrame(() => focusRow(root, key, reveal, tries - 1));
101
+ }
@@ -5,6 +5,7 @@ import { View } from "react-native";
5
5
  import { Text } from "./text";
6
6
  import { UndoBar, useInbox, useSidebarViewMounted } from "./inbox";
7
7
  import { HomeList, OVERSEER_KEY, type OverseerRowState } from "./home-list";
8
+ import { sidebarSelected } from "./theme";
8
9
  import { FilterField, SortMenu, useListFilter } from "./home-chrome";
9
10
  import { useHomeModel, type HomeSources } from "./home-data";
10
11
  import { useRowMenu } from "./row-actions";
@@ -85,6 +86,10 @@ export function inboxSidebarView(sources: HomeSources, openOverseerHome: () => v
85
86
  if (!sources.inbox.enabled()) return <View style={{ padding: 12 }}><Text style={{ color: c.foregroundMuted, fontSize: 12 }}>The Needs-you inbox is off. Turn it on in Follow-up's display settings.</Text></View>;
86
87
  return <View style={{ flex: 1 }}>
87
88
  <HomeList model={model} hits={filter.hits} theme={view.theme} dense touch={touch} selectedKey={selectedKey} onSelect={onSelect} menu={menu} overseer={overseer} stackOverseer
89
+ // Each open loads a chat and moves the main pane, so the keys move the focus and Enter opens.
90
+ keys={{ mode: "focus", onOpen: onSelect }}
91
+ // The open chat's row wears Paseo's own selected-item fill, so it reads like a selected native item.
92
+ selectedBg={sidebarSelected(c)}
88
93
  // One row, nothing else (invariant 8): the filter takes the width, the sort is an icon. zIndex keeps the
89
94
  // sort menu above the list on web, where every View is its own stacking context.
90
95
  top={<View style={{ zIndex: 10, flexDirection: "row", alignItems: "center", gap: touch ? 8 : 4, paddingHorizontal: touch ? 12 : 8, paddingVertical: touch ? 8 : 6, borderBottomWidth: 1, borderBottomColor: c.border }}>
package/client/theme.ts CHANGED
@@ -46,6 +46,16 @@ export function withAlpha(color: string, alpha: number): string {
46
46
  return rgb ? `rgba(${rgb.join(", ")}, ${alpha})` : color;
47
47
  }
48
48
 
49
+ /**
50
+ * The selected row in Paseo's sidebar, as Paseo draws its own (surfaceSidebarSelected, which the plugin theme doesn't
51
+ * carry). Light themes: the sidebar ground is surface2, and Paseo selects with surface4, two steps darker; the
52
+ * foreground at 14% over the ground lands there (#f4f4f5 -> #d4d4d8 in the default theme). Dark themes: surface2, the
53
+ * same step Paseo uses.
54
+ */
55
+ export function sidebarSelected(colors: Colors): string {
56
+ return isLight(colors) ? withAlpha(colors.foreground, 0.14) : colors.surface2;
57
+ }
58
+
49
59
  /** A tag fill in the same hue as its text: 12% on light grounds, 16% on dark ones. */
50
60
  export function tint(color: string, colors: Colors): string {
51
61
  return withAlpha(color, isLight(colors) ? 0.12 : 0.16);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "paseo-follow-up",
3
3
  "private": false,
4
- "version": "2.1.0-beta.0",
4
+ "version": "2.1.0-beta.1",
5
5
  "description": "A Paseo plugin that follows every workspace until the work is done: one Home for what needs you, questions you answer anywhere, and repairs that send themselves.",
6
6
  "type": "module",
7
7
  "files": [
@@ -0,0 +1,82 @@
1
+ import { GROUP_TITLE, quietFolds, type HomeGroupId, type HomeModel, type Workstream } from "./home";
2
+ import { rowHit, type OmniboxItem, type RowHit, type SearchHit, type WorkspaceItem } from "./search";
3
+
4
+ /**
5
+ * What HomeList draws, in order: one entry per row, header, fold and line (client/home-list.tsx). Pure, so the keyboard
6
+ * walk's order (walkOrder, shared/list-keys.ts) is testable: it is exactly the rows drawn.
7
+ */
8
+ export const QUIET_PAGE = 20;
9
+ export const BRIEF_KEY = "brief";
10
+ export const OVERSEER_KEY = "overseer";
11
+ export type Entry =
12
+ | { type: "brief"; key: string }
13
+ | { type: "overseer"; key: string }
14
+ | { type: "header"; key: string; group: HomeGroupId; title: string; count: number; open: boolean }
15
+ | { type: "row"; key: string; s: Workstream; hit?: RowHit | null }
16
+ | { type: "fold"; key: string; project: string; count: number; archivable: number; open: boolean }
17
+ | { type: "more"; key: string; project: string; left: number }
18
+ | { type: "result"; key: string; item: WorkspaceItem; index: number; s: Workstream; hit: RowHit; archived: boolean }
19
+ | { type: "ask"; key: string; ask: string; index: number }
20
+ | { type: "label"; key: string; text: string }
21
+ | { type: "hold"; key: string; text: string }
22
+ | { type: "empty"; key: string }
23
+ | { type: "slot"; key: string };
24
+
25
+ /** A search hit on a workspace Follow-up has archived: a muted row with the Archive glyph, reading "Archived". */
26
+ export function archivedRow(hit: SearchHit): Workstream {
27
+ 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,
28
+ icon: "Archive", tone: "muted", line: "Archived", word: null, badges: [], pr: null, at: null, readyToArchive: false, sig: `archived:${hit.key}` } as unknown as Workstream;
29
+ }
30
+
31
+ export type ListEntriesInput = {
32
+ model: HomeModel; closed: Set<string>; openProjects: Set<string>; pages: Record<string, number>; briefLine: string | null | undefined;
33
+ results: OmniboxItem[] | null | undefined; hits: Map<string, SearchHit> | null; filter: HomeGroupId | null; overseer: boolean; touch: boolean; afterNeeds: boolean;
34
+ };
35
+ export function listEntries({ model, closed, openProjects, pages, briefLine, results, hits, filter, overseer, touch, afterNeeds }: ListEntriesInput): Entry[] {
36
+ const out: Entry[] = [];
37
+ if (results) {
38
+ // Search ignores the sort and the groups: ranked by match, archived ones last under their own label.
39
+ let archivedShown = false;
40
+ results.forEach((item, index) => {
41
+ if (item.ask !== undefined) {
42
+ // The ask row closes the list; with no match it follows the "no match" line.
43
+ if (index === 0) out.push({ type: "label", key: "l:none", text: "No workspace, branch or PR matches." });
44
+ out.push({ type: "ask", key: item.key, ask: item.ask, index });
45
+ return;
46
+ }
47
+ if (item.hit.group === "archived" && !archivedShown) { archivedShown = true; out.push({ type: "label", key: "l:archived", text: "Archived" }); }
48
+ const live = model.byKey.get(item.key);
49
+ const s = live ?? archivedRow(item.hit);
50
+ out.push({ type: "result", key: `r:${item.provider}:${item.key}`, item, index, s, hit: rowHit(item.hit, s), archived: !live });
51
+ });
52
+ if (!results.length) out.push({ type: "label", key: "l:none", text: "No workspace, branch or PR matches." });
53
+ return out;
54
+ }
55
+ if (briefLine !== undefined && !filter) out.push({ type: "brief", key: BRIEF_KEY });
56
+ if (overseer && !filter) out.push({ type: "overseer", key: OVERSEER_KEY });
57
+ for (const g of model.groups) {
58
+ if (filter && g.id !== filter) continue;
59
+ const open = !!filter || !!hits || !closed.has(g.id);
60
+ // Phones with one group filtered: the chip above already says "N Needs you ×"; no header repeating it.
61
+ if (!(touch && filter)) out.push({ type: "header", key: `h:${g.id}`, group: g.id, title: g.title, count: g.items.length, open });
62
+ if (!open) { if (g.id === "needs" && afterNeeds && !filter) out.push({ type: "slot", key: "s:afterNeeds" }); continue; }
63
+ // One hold line per machine, once, at the top of Sending (the model has it only while Sending has rows).
64
+ if (g.id === "sending" && model.hold) out.push({ type: "hold", key: "l:hold", text: model.hold });
65
+ const hitOf = (s: Workstream) => { const h = hits?.get(s.key); return h ? rowHit(h, s) : null; };
66
+ 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; }
67
+ for (const f of quietFolds(g.items)) {
68
+ const fopen = !!hits || openProjects.has(f.project);
69
+ out.push({ type: "fold", key: `f:${f.project}`, project: f.project, count: f.items.length, archivable: f.archivable, open: fopen });
70
+ if (!fopen) continue;
71
+ const shown = (pages[f.project] ?? 1) * QUIET_PAGE;
72
+ for (const s of f.items.slice(0, shown)) out.push({ type: "row", key: s.key, s, hit: hitOf(s) });
73
+ if (f.items.length > shown) out.push({ type: "more", key: `m:${f.project}`, project: f.project, left: f.items.length - shown });
74
+ }
75
+ }
76
+ // Phones: nothing followed yet says so and what fills the list, instead of a blank screen under the pinned rows.
77
+ if (hits && !out.some(e => e.type === "row")) out.push({ type: "label", key: "l:none", text: "No workspace matches." });
78
+ else if (touch && !filter && !hits && model.groups.every(g => !g.items.length)) out.push({ type: "empty", key: "l:nothing" });
79
+ return out;
80
+ if (filter && !out.length) out.push({ type: "label", key: "l:empty", text: `Nothing in ${GROUP_TITLE[filter as HomeGroupId]} right now.` });
81
+ return out;
82
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Walking a list of rows from the keyboard (desktop and web), the keys and the step. Home and Paseo's sidebar view
3
+ * walk HomeList with these through one hook (client/list-keys.ts; invariant one-keyboard-walk-for-every-list).
4
+ */
5
+ export type ListMove = "next" | "prev" | "first" | "last" | "open";
6
+ export type ListKeyEvent = { key: string; metaKey?: boolean; ctrlKey?: boolean; altKey?: boolean; shiftKey?: boolean };
7
+
8
+ /**
9
+ * Which move a key is. Modified keys stay Paseo's: ⌘[ ⌘] and ⌘1…9 (Ctrl, or Alt on the web) walk its own sidebar.
10
+ * Escape (Paseo's interrupt) and Space (its voice toggle) are never ours. In the list's own query field only the
11
+ * arrows count, so j, k, Home, End and Enter still type there.
12
+ */
13
+ export function listMove(e: ListKeyEvent, typing: boolean): ListMove | null {
14
+ if (e.metaKey || e.ctrlKey || e.altKey) return null;
15
+ if (e.key === "ArrowDown") return "next";
16
+ if (e.key === "ArrowUp") return "prev";
17
+ if (typing || e.shiftKey) return null;
18
+ switch (e.key) {
19
+ case "j": return "next";
20
+ case "k": return "prev";
21
+ case "Home": return "first";
22
+ case "End": return "last";
23
+ case "Enter": return "open";
24
+ default: return null;
25
+ }
26
+ }
27
+
28
+ /** The row a move lands on: one step, clamped at both ends (no wrap). From no row (or one that left), the first. */
29
+ export function stepKey(order: readonly string[], current: string | null, move: Exclude<ListMove, "open">): string | null {
30
+ if (!order.length) return null;
31
+ if (move === "last") return order[order.length - 1];
32
+ const i = current === null ? -1 : order.indexOf(current);
33
+ if (move === "first" || i < 0) return order[0];
34
+ return order[Math.max(0, Math.min(order.length - 1, i + (move === "next" ? 1 : -1)))];
35
+ }
36
+
37
+ /**
38
+ * The walk's order: the rows a list draws, in order (shared/list-entries.ts), so the brief and the Overseer come first
39
+ * and a collapsed group, a closed Quiet fold or a filtered-out row is never a stop. A search walks its results instead.
40
+ */
41
+ export function walkOrder(entries: readonly { type: string; key: string }[]): string[] {
42
+ return entries.filter(e => e.type === "brief" || e.type === "overseer" || e.type === "row").map(e => e.key);
43
+ }
44
+
45
+ /**
46
+ * Whether a key belongs to this surface: focus inside it, or (Home) nothing focused while Home is on screen. Home and
47
+ * the sidebar view sit side by side, so focus in one never moves the other; and a Home kept mounted behind another tab
48
+ * or chat never takes a body key, which there scrolls the chat in front.
49
+ */
50
+ export function ownsKey(input: { inside: boolean; onBody: boolean; claimBody: boolean; visible: boolean }): boolean {
51
+ return input.inside || input.claimBody && input.onBody && input.visible;
52
+ }
53
+
54
+ type Visible = { checkVisibility?(): boolean; getClientRects?(): { length: number } };
55
+
56
+ /**
57
+ * Whether a surface is on screen: its page is the visible one and its root is laid out (not display:none, nor inside a
58
+ * hidden ancestor). `checkVisibility` where the engine has it, else laid-out boxes. No root yet: not visible.
59
+ */
60
+ export function surfaceVisible(root: Visible | null | undefined, doc: { visibilityState?: string }): boolean {
61
+ if (!root) return false;
62
+ if (doc.visibilityState !== undefined && doc.visibilityState !== "visible") return false;
63
+ if (typeof root.checkVisibility === "function") return root.checkVisibility();
64
+ return (root.getClientRects?.().length ?? 0) > 0;
65
+ }
66
+
67
+ /**
68
+ * Where a move lands. From the list's own query field the arrows enter the list: at the selection on Home ("select"),
69
+ * at the first match in the sidebar view ("focus"). Otherwise one step from the focused row, or from the selection.
70
+ */
71
+ export function walkTarget(input: { order: readonly string[]; focused: string | null; selectedKey: string | null; mode: "select" | "focus"; typing: boolean; move: Exclude<ListMove, "open"> }): string | null {
72
+ const { order, focused, selectedKey, mode, typing, move } = input;
73
+ const from = focused ?? (selectedKey !== null && order.includes(selectedKey) ? selectedKey : null);
74
+ if (typing) return mode === "select" && from ? from : order[0] ?? null;
75
+ return stepKey(order, from, move);
76
+ }