paseo-follow-up 1.4.0-beta.2 → 1.4.0-beta.21

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.
Files changed (92) hide show
  1. package/OVERVIEW.md +15 -4
  2. package/README.md +59 -6
  3. package/client/about.tsx +22 -12
  4. package/client/agents.tsx +132 -0
  5. package/client/brief.tsx +200 -72
  6. package/client/chat.tsx +12 -4
  7. package/client/display.tsx +62 -11
  8. package/client/header.tsx +40 -19
  9. package/client/home-chrome.tsx +135 -40
  10. package/client/home-list.tsx +90 -35
  11. package/client/home-view.ts +66 -8
  12. package/client/home.tsx +268 -77
  13. package/client/inbox-store.ts +15 -7
  14. package/client/keys.ts +3 -0
  15. package/client/kit.tsx +46 -15
  16. package/client/large.tsx +9 -10
  17. package/client/live.tsx +8 -6
  18. package/client/needs-you.tsx +36 -8
  19. package/client/onboarding.tsx +455 -0
  20. package/client/panel.tsx +98 -23
  21. package/client/pill.tsx +41 -21
  22. package/client/pr-controls.tsx +38 -14
  23. package/client/pr-sheet.tsx +8 -6
  24. package/client/questions.tsx +6 -4
  25. package/client/reviewers.tsx +63 -21
  26. package/client/settings-shell.tsx +77 -0
  27. package/client/settings.tsx +145 -49
  28. package/client/shipping.tsx +186 -0
  29. package/client/spec.tsx +1 -1
  30. package/client/stacks.tsx +4 -3
  31. package/client/tasks.tsx +1 -1
  32. package/client/theme.ts +21 -0
  33. package/client/visibility.ts +7 -0
  34. package/client/workspace-data.ts +37 -0
  35. package/docs/screenshots/decision-card-answered-phone-light.png +0 -0
  36. package/docs/screenshots/decision-card-expanded-chat-light.png +0 -0
  37. package/docs/screenshots/decision-card-partial-phone-dark.png +0 -0
  38. package/docs/screenshots/decision-card-unanswered-phone-dark.png +0 -0
  39. package/index.client.tsx +27 -8
  40. package/index.server.ts +257 -24
  41. package/package.json +5 -3
  42. package/server/about.ts +15 -4
  43. package/server/agent-actions.ts +75 -6
  44. package/server/agent-hook.mjs +54 -16
  45. package/server/agent-parity.ts +149 -0
  46. package/server/agent-settings.ts +124 -0
  47. package/server/ai-jobs.ts +88 -23
  48. package/server/daemon.ts +165 -105
  49. package/server/directory.ts +165 -0
  50. package/server/discovery.ts +34 -6
  51. package/server/engine.ts +31 -9
  52. package/server/etag.ts +14 -0
  53. package/server/github.ts +66 -5
  54. package/server/hook-source.ts +1 -1
  55. package/server/inbox-directory.ts +14 -19
  56. package/server/inbox.ts +28 -1
  57. package/server/mcp-source.ts +1 -1
  58. package/server/mcp.d.mts +3 -1
  59. package/server/mcp.mjs +83 -10
  60. package/server/native-tools.ts +3 -2
  61. package/server/onboarding.ts +101 -0
  62. package/server/overseer-prompt-source.ts +1 -1
  63. package/server/overseer-prompt.md +1 -0
  64. package/server/overseer.ts +72 -8
  65. package/server/pr-actions.ts +91 -15
  66. package/server/pr-workflow.ts +188 -0
  67. package/server/questions.ts +1 -1
  68. package/server/ranker.ts +431 -0
  69. package/server/recovery-config.ts +17 -0
  70. package/server/scopes.ts +20 -8
  71. package/server/tasks.ts +9 -3
  72. package/server/trust-bypass.ts +125 -0
  73. package/shared/about.ts +8 -3
  74. package/shared/activity.ts +3 -1
  75. package/shared/agent-settings.ts +169 -0
  76. package/shared/attention.ts +8 -4
  77. package/shared/brief.ts +44 -0
  78. package/shared/chat.ts +3 -1
  79. package/shared/contracts.ts +42 -4
  80. package/shared/display.ts +16 -1
  81. package/shared/headline.ts +5 -0
  82. package/shared/home.ts +6 -0
  83. package/shared/model.ts +12 -1
  84. package/shared/onboarding.ts +243 -0
  85. package/shared/overseer.ts +10 -2
  86. package/shared/pr-actions.ts +26 -4
  87. package/shared/pr-workflow.ts +133 -0
  88. package/shared/questions.ts +17 -0
  89. package/shared/ranker.ts +237 -0
  90. package/shared/search.ts +25 -5
  91. package/shared/settings-nav.ts +97 -0
  92. package/skills/follow-through/SKILL.md +3 -1
package/client/header.tsx CHANGED
@@ -2,7 +2,7 @@ import { Pressable, Text, View } from "react-native";
2
2
  import { Icon } from "@getpaseo/plugin/client/ui";
3
3
  import type { Workspace } from "../shared/model";
4
4
  import { ago, headline, liveLine, stackBar, type LiveIcon } from "../shared/attention";
5
- import { IconButton, Switch, text, type Theme } from "./kit";
5
+ import { Button, IconButton, Switch, text, type Theme } from "./kit";
6
6
  import { IconSwap, Spinner } from "./motion";
7
7
  import { segmentPaint, type Colors } from "./theme";
8
8
  import { SpecChip } from "./spec";
@@ -41,36 +41,28 @@ function LiveGlyph({ icon, colors }: { icon: LiveIcon; colors: Colors }) {
41
41
  }
42
42
  }
43
43
 
44
- export function WorkspaceHeader({ workspace: w, theme, compact, now, onSettings, onRefresh, refreshing, onAuto, autoPending, notice, onOpenPr, resize, hideTitle = false }: {
44
+ export function WorkspaceHeader({ workspace: w, theme, compact, now, onSettings, onRefresh, refreshing, onAuto, autoPending, notice, onOpenPr, resize, hideTitle = false, onHome }: {
45
45
  workspace: Workspace; theme: Theme; compact: boolean; now: number; onSettings: () => void; onRefresh: () => void; refreshing: boolean; onAuto: (next: boolean) => void; autoPending: boolean; notice: string | null; onOpenPr?: (key: string) => void;
46
46
  /** Expand to the larger view, or collapse back to the panel. Absent where the panel is already as wide as it gets. */
47
47
  resize?: { icon: "Maximize2" | "Minimize2"; label: string; onPress: () => void } | null;
48
48
  /** The larger view's screen bar already names the workspace. */
49
49
  hideTitle?: boolean;
50
+ /** Phones: the panel's Home link joins the header's own bar, one 44px row instead of two. */
51
+ onHome?: () => void;
50
52
  }) {
51
- const c = theme.colors; const t = text(c);
53
+ const c = theme.colors; const t = text(c, compact);
52
54
  const parts = headline(w, now);
53
55
  const live = liveLine(w, now);
54
56
  const checked = w.prs.map(p => p.snapshot?.observedAt).filter((v): v is string => !!v).sort().at(-1);
55
57
  const stale = !!checked && w.prs.some(p => p.snapshot?.state === "OPEN") && now - Date.parse(checked) > STALE_MS;
56
58
  const toneOf = (tone?: string) => tone === "warning" ? c.statusWarning : tone === "danger" ? c.statusDanger : tone === "success" ? c.statusSuccess : undefined;
57
59
  const pad = compact ? 16 : 12;
58
- return <View style={{ paddingHorizontal: pad, paddingTop: compact ? 14 : 12, paddingBottom: 10, gap: 6, borderBottomWidth: 1, borderBottomColor: c.border }}>
59
- <View style={{ flexDirection: "row", alignItems: "flex-start", gap: 8 }}>
60
- {/* On phones the host header right above already shows the workspace name. */}
61
- {compact || hideTitle ? <Text numberOfLines={2} style={[t.meta, { flex: 1, paddingTop: 2 }, hideTitle && !compact ? { fontSize: 13, lineHeight: 19, color: c.foreground } : null]}>{w.goal}</Text>
62
- : <Text accessibilityRole="header" style={[t.title, { flex: 1 }]}>{w.title}</Text>}
63
- <View style={{ flexDirection: "row", alignItems: "center", gap: 2, marginVertical: compact ? -12 : -4, marginRight: compact ? -10 : -4 }}>
64
- {!!w.spec?.url && <View style={{ marginRight: 4 }}><SpecChip workspace={w} theme={theme} compact={compact} /></View>}
65
- {resize && <IconButton icon={resize.icon} label={resize.label} onPress={resize.onPress} theme={theme} compact={compact} />}
66
- <IconButton icon="Settings" label="Follow-up settings" onPress={onSettings} theme={theme} compact={compact} />
67
- </View>
68
- </View>
69
- {!compact && !hideTitle && w.goal && w.goal !== w.title && <Text numberOfLines={2} style={t.meta}>{w.goal}</Text>}
70
- <Text accessibilityLiveRegion="polite" style={[t.meta, { color: c.foregroundMuted, marginTop: 2 }]}>
71
- {parts.map((part, i) => <Text key={part.text} style={toneOf(part.tone) ? { color: toneOf(part.tone), fontWeight: "600" } : { color: c.foreground }}>{i ? <Text style={{ color: c.foregroundMuted, fontWeight: "400" }}>{" · "}</Text> : null}{part.text}</Text>)}
72
- </Text>
73
- <StackBar workspace={w} theme={theme} onOpen={onOpenPr} />
60
+ const controls = <View style={{ flexDirection: "row", alignItems: "center", gap: 2, marginVertical: compact ? -12 : -4, marginRight: compact ? -10 : -4 }}>
61
+ {!!w.spec?.url && <View style={{ marginRight: 4 }}><SpecChip workspace={w} theme={theme} compact={compact} /></View>}
62
+ {resize && <IconButton icon={resize.icon} label={resize.label} onPress={resize.onPress} theme={theme} compact={compact} />}
63
+ <IconButton icon="Settings" label="Follow-up settings" onPress={onSettings} theme={theme} compact={compact} />
64
+ </View>;
65
+ const tail = <>
74
66
  <View style={{ flexDirection: "row", gap: 6, marginTop: 2 }}>
75
67
  <View style={{ paddingTop: 3 }}><IconSwap swapKey={live.icon} size={12}><LiveGlyph icon={live.icon} colors={c} /></IconSwap></View>
76
68
  <Text accessibilityLiveRegion="polite" style={[t.meta, { flex: 1, color: live.icon === "spinner" ? c.foreground : c.foregroundMuted }]}>
@@ -88,5 +80,34 @@ export function WorkspaceHeader({ workspace: w, theme, compact, now, onSettings,
88
80
  <Switch theme={theme} compact={compact} label="Auto-send" accessibilityLabel="Auto-send repairs" hint="Send repair batches to the main agent on its own when the agent is idle. Off means each batch waits for your click."
89
81
  value={w.enable_auto_sends} disabled={autoPending} onChange={onAuto} />
90
82
  </View>
83
+ </>;
84
+ if (compact && onHome) return <View style={{ paddingHorizontal: pad, paddingTop: 4, paddingBottom: 12, gap: 8, borderBottomWidth: 1, borderBottomColor: c.border }}>
85
+ {/* One bar: Home on the left, the Spec chip and settings on the right. The host header above names the workspace,
86
+ so the goal shows only when it says something the title doesn't. */}
87
+ <View style={{ flexDirection: "row", alignItems: "center", minHeight: 44, marginLeft: -14 }}>
88
+ <Button theme={theme} compact kind="ghost" icon="House" title="Home" accessibilityHint="Opens Follow-up Home with every workspace" onPress={onHome} />
89
+ <View style={{ flex: 1 }} />
90
+ <View style={{ marginVertical: 12 }}>{controls}</View>
91
+ </View>
92
+ {!!w.goal && w.goal.trim() !== w.title.trim() && <Text numberOfLines={2} style={t.meta}>{w.goal}</Text>}
93
+ <Text accessibilityLiveRegion="polite" style={[t.ask, { color: c.foregroundMuted }]}>
94
+ {parts.map((part, i) => <Text key={part.text} style={toneOf(part.tone) ? { color: toneOf(part.tone) } : { color: c.foreground }}>{i ? <Text style={{ color: c.foregroundMuted, fontWeight: "400" }}>{" · "}</Text> : null}{part.text}</Text>)}
95
+ </Text>
96
+ <StackBar workspace={w} theme={theme} onOpen={onOpenPr} />
97
+ {tail}
98
+ </View>;
99
+ return <View style={{ paddingHorizontal: pad, paddingTop: compact ? 14 : 12, paddingBottom: 10, gap: 6, borderBottomWidth: 1, borderBottomColor: c.border }}>
100
+ <View style={{ flexDirection: "row", alignItems: "flex-start", gap: 8 }}>
101
+ {/* On phones the host header right above already shows the workspace name. */}
102
+ {compact || hideTitle ? <Text numberOfLines={2} style={[t.meta, { flex: 1, paddingTop: 2 }, hideTitle && !compact ? { fontSize: 13, lineHeight: 19, color: c.foreground } : null]}>{w.goal}</Text>
103
+ : <Text accessibilityRole="header" style={[t.title, { flex: 1 }]}>{w.title}</Text>}
104
+ {controls}
105
+ </View>
106
+ {!compact && !hideTitle && w.goal && w.goal !== w.title && <Text numberOfLines={2} style={t.meta}>{w.goal}</Text>}
107
+ <Text accessibilityLiveRegion="polite" style={[t.meta, { color: c.foregroundMuted, marginTop: 2 }]}>
108
+ {parts.map((part, i) => <Text key={part.text} style={toneOf(part.tone) ? { color: toneOf(part.tone), fontWeight: "600" } : { color: c.foreground }}>{i ? <Text style={{ color: c.foregroundMuted, fontWeight: "400" }}>{" · "}</Text> : null}{part.text}</Text>)}
109
+ </Text>
110
+ <StackBar workspace={w} theme={theme} onOpen={onOpenPr} />
111
+ {tail}
91
112
  </View>;
92
113
  }
@@ -1,16 +1,18 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore, type ReactNode } from "react";
2
- import { Platform, Pressable, Text, TextInput, View } from "react-native";
3
- import { Icon } from "@getpaseo/plugin/client/ui";
2
+ import { Platform, Pressable, ScrollView, Text, TextInput, View } from "react-native";
3
+ import { Icon, useToast } from "@getpaseo/plugin/client/ui";
4
4
  import { GROUP_TITLE, homeCounts, type HomeGroupId, type HomeModel } from "../shared/home";
5
- import { FIELD_LABEL, excerpt, highlightRuns, homeSearchDocs, indexDocs, omniboxResults, workspaceProvider, type OmniboxItem, type OmniboxProvider, type Range } from "../shared/search";
6
- import { SORT_HINT, SORT_LABEL, SORT_MODES, type SortMode } from "../shared/sort";
5
+ import { FIELD_LABEL, excerpt, highlightRuns, homeSearchDocs, indexDocs, defaultActive, omniboxResults, overseerProvider, workspaceProvider, type OmniboxItem, type OmniboxProvider, type Range, type WorkspaceItem } from "../shared/search";
6
+ import { DEFAULT_SORT, SORT_HINT, SORT_LABEL, SORT_MODES, type SortMode } from "../shared/sort";
7
7
  import { priorityNote, PRIORITY_SOURCE_LABEL } from "../shared/priorities";
8
+ import { rankCost } from "../shared/ranker";
8
9
  import { meters, meterText, type Meter } from "../shared/usage";
9
10
  import { resourceMeter, type Resources } from "../shared/resources";
10
11
  import type { HomeSources } from "./home-data";
11
12
  import type { Workstream } from "../shared/home";
12
- import { Age, PrChipView } from "./home-list";
13
+ import { Age, glyphColor, PrChipView, PrSummaryText } from "./home-list";
13
14
  import { useMinute } from "./home-data";
15
+ import { Spinner } from "./motion";
14
16
  import { withAlpha, type Colors } from "./theme";
15
17
  import type { Theme } from "./kit";
16
18
 
@@ -29,33 +31,40 @@ export type Omnibox = {
29
31
  active: number;
30
32
  move(delta: number): void;
31
33
  inputRef: React.RefObject<TextInput | null>;
34
+ /** The Overseer is on, so a query can also be an ask. */
35
+ askOn: boolean;
32
36
  };
33
37
 
34
38
  /**
35
39
  * The search state for one list. The index is rebuilt only when Home's sources change, never per keystroke.
36
- * `extraProviders` is the seam for the next build's "Ask the Overseer" row, listed after the workspace results.
40
+ * The Overseer's "Ask the Overseer: <query>" row comes last while the Overseer is on; `extraProviders` go between.
37
41
  */
38
42
  export function useOmnibox(model: HomeModel, sources: HomeSources, extraProviders: readonly OmniboxProvider[] = []): Omnibox {
39
43
  const [query, setQueryState] = useState("");
40
- const [active, setActive] = useState(0);
44
+ // null: the default row. -1: none, so Enter does nothing.
45
+ const [active, setActive] = useState<number | null>(null);
41
46
  const inputRef = useRef<TextInput | null>(null);
42
47
  const live = useSyncExternalStore(sources.live.subscribe, sources.live.version, sources.live.version);
43
48
  const paseo = useSyncExternalStore(sources.paseo.subscribe, sources.paseo.version, sources.paseo.version);
44
49
  const extras = useSyncExternalStore(sources.extras.subscribe, sources.extras.version, sources.extras.version);
45
50
  const searching = query.trim().length > 0;
51
+ const overseer = useSyncExternalStore(sources.extras.subscribe, sources.extras.overseer, sources.extras.overseer);
52
+ const askOn = !!overseer?.enabled;
46
53
  // Built lazily: nothing is indexed until the developer types.
47
54
  const index = useMemo(() => searching ? indexDocs(homeSearchDocs({ model, paseo: sources.paseo.all(), tracked: sources.live.all(), archived: sources.live.archived(), agents: sources.extras.agents() })) : null,
48
55
  // eslint-disable-next-line react-hooks/exhaustive-deps
49
56
  [searching, model, live, paseo, extras]);
50
- const providers = useMemo(() => index ? [workspaceProvider(index), ...extraProviders] : [], [index, extraProviders]);
57
+ const providers = useMemo(() => index ? [workspaceProvider(index), ...extraProviders, overseerProvider(askOn)] : [], [index, extraProviders, askOn]);
51
58
  const results = useMemo(() => searching ? omniboxResults(providers, query) : null, [providers, query, searching]);
52
- const setQuery = useCallback((q: string) => { setQueryState(q); setActive(0); }, []);
53
- const move = useCallback((delta: number) => setActive(a => Math.max(0, Math.min((results?.length ?? 1) - 1, a + delta))), [results]);
59
+ const setQuery = useCallback((q: string) => { setQueryState(q); setActive(null); }, []);
60
+ const fallback = defaultActive(results);
61
+ const current = active ?? fallback;
62
+ const move = useCallback((delta: number) => setActive(a => Math.max(0, Math.min((results?.length ?? 1) - 1, (a ?? fallback) + delta))), [results, fallback]);
54
63
  // ⌘K "Follow-up: Search".
55
64
  const token = useSyncExternalStore(sources.extras.subscribe, sources.extras.focusToken, sources.extras.focusToken);
56
65
  const first = useRef(token);
57
66
  useEffect(() => { if (token !== first.current) inputRef.current?.focus(); }, [token]);
58
- return { query, setQuery, results, active: Math.min(active, Math.max(0, (results?.length ?? 1) - 1)), move, inputRef };
67
+ return { query, setQuery, results, active: Math.min(current, Math.max(0, (results?.length ?? 1) - 1)), move, inputRef, askOn };
59
68
  }
60
69
 
61
70
  type DomKey = { key: string; metaKey: boolean; ctrlKey: boolean; altKey: boolean; target: unknown; preventDefault(): void };
@@ -79,12 +88,14 @@ export function useSlashToFocus(omnibox: Omnibox, enabled = true) {
79
88
  export function SearchField({ theme, omnibox, dense, onEnter }: { theme: Theme; omnibox: Omnibox; dense: boolean; onEnter: (item: OmniboxItem) => void }) {
80
89
  const c = theme.colors;
81
90
  const [focused, setFocused] = useState(false);
82
- const { query, setQuery, results, active, move, inputRef } = omnibox;
83
- return <View style={{ flex: 1, minWidth: 0, flexDirection: "row", alignItems: "center", gap: 6, height: dense ? 30 : 32, paddingHorizontal: 8, borderRadius: 6,
91
+ const { query, setQuery, results, active, move, inputRef, askOn } = omnibox;
92
+ const placeholder = askOn ? dense ? "Search or ask the Overseer" : "Search, or ask the Overseer" : "Search workspaces, branches, PRs";
93
+ // `dense` is the phone layout: a 44px field with a rounder shape and body-size text.
94
+ return <View style={{ flex: 1, minWidth: 0, flexDirection: "row", alignItems: "center", gap: dense ? 8 : 6, height: dense ? 44 : 32, paddingHorizontal: dense ? 12 : 8, borderRadius: dense ? 12 : 6,
84
95
  borderWidth: 1, borderColor: focused ? withAlpha(c.foreground, 0.35) : c.border, backgroundColor: c.surface1 }}>
85
- <Icon name="Search" size={13} color={c.foregroundMuted} />
86
- <TextInput ref={inputRef} value={query} onChangeText={setQuery} placeholder="Search workspaces, branches, PRs" placeholderTextColor={c.foregroundMuted}
87
- accessibilityLabel="Search workspaces, branches, PRs" autoCorrect={false} autoCapitalize="none" spellCheck={false} returnKeyType="go"
96
+ <Icon name="Search" size={dense ? 16 : 13} color={c.foregroundMuted} />
97
+ <TextInput ref={inputRef} value={query} onChangeText={setQuery} placeholder={placeholder} placeholderTextColor={c.foregroundMuted}
98
+ accessibilityLabel={placeholder} autoCorrect={false} autoCapitalize="none" spellCheck={false} returnKeyType="go"
88
99
  onFocus={() => setFocused(true)} onBlur={() => setFocused(false)}
89
100
  onSubmitEditing={() => { const item = results?.[active]; if (item) onEnter(item); }}
90
101
  onKeyPress={e => {
@@ -93,38 +104,67 @@ export function SearchField({ theme, omnibox, dense, onEnter }: { theme: Theme;
93
104
  else if (key === "ArrowUp") { e.preventDefault?.(); move(-1); }
94
105
  else if (key === "Escape") { if (query) setQuery(""); else inputRef.current?.blur(); }
95
106
  }}
96
- style={{ flex: 1, minWidth: 0, color: c.foreground, fontSize: 13, paddingVertical: 0, ...(Platform.OS === "web" ? { outlineStyle: "none" } as object : {}) }} />
97
- {!!query && <Pressable accessibilityRole="button" accessibilityLabel="Clear search" hitSlop={8} onPress={() => { setQuery(""); inputRef.current?.focus(); }}>
98
- <Icon name="X" size={13} color={c.foregroundMuted} />
107
+ style={{ flex: 1, minWidth: 0, color: c.foreground, fontSize: dense ? 15 : 13, paddingVertical: 0, ...(Platform.OS === "web" ? { outlineStyle: "none" } as object : {}) }} />
108
+ {!!query && <Pressable accessibilityRole="button" accessibilityLabel="Clear search" hitSlop={dense ? 14 : 8} onPress={() => { setQuery(""); inputRef.current?.focus(); }}>
109
+ <Icon name="X" size={dense ? 16 : 13} color={c.foregroundMuted} />
99
110
  </Pressable>}
100
- {!query && !focused && Platform.OS === "web" && <Text style={{ color: c.foregroundMuted, fontSize: 11, paddingHorizontal: 4, borderRadius: 3, borderWidth: 1, borderColor: c.border }}>/</Text>}
111
+ {!query && !focused && !dense && Platform.OS === "web" && <Text style={{ color: c.foregroundMuted, fontSize: 11, paddingHorizontal: 4, borderRadius: 3, borderWidth: 1, borderColor: c.border }}>/</Text>}
101
112
  </View>;
102
113
  }
103
114
 
104
115
  // ---------- sort ----------
105
116
 
106
- export function SortMenu({ theme, mode, onChange, rankedAt, touch }: { theme: Theme; mode: SortMode; onChange: (m: SortMode) => void; rankedAt: string | null; touch: boolean }) {
117
+ 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;
118
+
119
+
120
+ export function SortMenu({ theme, mode, onChange, rankedAt, touch, rank = null, onRerank }: { 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 }[] }> }) {
107
121
  const c = theme.colors;
108
122
  const [open, setOpen] = useState(false);
109
123
  const now = useMinute();
124
+ const toast = useToast();
125
+ const running = !!rank?.running;
126
+ const rerank = async () => {
127
+ if (!onRerank || running) return;
128
+ setOpen(false);
129
+ try {
130
+ const r = await onRerank();
131
+ if (!r.ok) toast.error(r.error ?? "Couldn't re-rank.");
132
+ else if (r.skipped === "busy") toast.show("Still ranking; Home updates when it's done");
133
+ 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" });
134
+ } catch (e) { toast.error(e instanceof Error ? e.message : String(e)); }
135
+ };
136
+ // "Ranked 12m ago · Slack unavailable": the age, then any source the last run couldn't read.
137
+ // The footer keeps the standing ranking's age and cost while a new one runs; the menu item says "Ranking…".
138
+ const note = [priorityNote(rankedAt, now), rankedAt && rank?.enabled ? rankCost(rank) : "", rank?.enabled ? rank.healthLine : ""].filter(Boolean).join(" · ");
110
139
  return <View style={{ position: "relative", zIndex: 20 }}>
111
- <Pressable accessibilityRole="button" accessibilityLabel={`Sort: ${SORT_LABEL[mode]}`} aria-expanded={open} accessibilityState={{ expanded: open }} onPress={() => setOpen(o => !o)}
112
- style={state => ({ flexDirection: "row", alignItems: "center", gap: 4, height: touch ? 36 : 30, paddingHorizontal: 8, borderRadius: 6, backgroundColor: open || (state as { hovered?: boolean }).hovered ? c.surface2 : "transparent" })}>
113
- <Icon name="ArrowUpDown" size={13} color={c.foregroundMuted} />
114
- <Text numberOfLines={1} style={{ color: c.foreground, fontSize: 12 }}>{SORT_LABEL[mode]}</Text>
115
- <Icon name="ChevronDown" size={12} color={c.foregroundMuted} />
140
+ <Pressable accessibilityRole="button" accessibilityLabel={`Sort: ${SORT_LABEL[mode]}${running ? ", ranking" : ""}`} aria-expanded={open} accessibilityState={{ expanded: open }} onPress={() => setOpen(o => !o)}
141
+ style={state => ({ flexDirection: "row", alignItems: "center", justifyContent: "center", gap: 4, height: touch ? 44 : 30, minWidth: touch ? 44 : undefined, paddingHorizontal: touch ? 0 : 8, borderRadius: touch ? 8 : 6, backgroundColor: open || (state as { hovered?: boolean }).hovered ? c.surface2 : "transparent" })}>
142
+ {/* Phones: an icon; the mode's name lives in the menu (and the accessible name). */}
143
+ {running ? <Spinner color={c.foreground} size={12} label="Ranking" /> : <Icon name="ArrowUpDown" size={touch ? 18 : 13} color={touch && mode !== DEFAULT_SORT ? c.foreground : c.foregroundMuted} />}
144
+ {/* Phones: the icon carries no label, so a non-default sort shows as a dot on it. */}
145
+ {touch && mode !== DEFAULT_SORT && <View style={{ position: "absolute", top: 9, right: 9, width: 7, height: 7, borderRadius: 4, backgroundColor: c.accent }} />}
146
+ {!touch && <Text numberOfLines={1} style={{ color: c.foreground, fontSize: 12 }}>{SORT_LABEL[mode]}</Text>}
147
+ {!touch && <Icon name="ChevronDown" size={12} color={c.foregroundMuted} />}
116
148
  </Pressable>
117
- {open && <View accessibilityRole="menu" style={{ position: "absolute", top: touch ? 40 : 34, right: 0, minWidth: 220, paddingVertical: 4, borderRadius: 8, borderWidth: 1, borderColor: c.border, backgroundColor: c.surface1,
149
+ {open && <View accessibilityRole="menu" style={{ position: "absolute", top: touch ? 48 : 34, right: 0, minWidth: touch ? 240 : 220, paddingVertical: 4, borderRadius: 8, borderWidth: 1, borderColor: c.border, backgroundColor: c.surface1,
118
150
  shadowColor: "#000", shadowOpacity: 0.25, shadowRadius: 12, shadowOffset: { width: 0, height: 4 }, elevation: 8 }}>
119
151
  {SORT_MODES.map(m => <Pressable key={m} accessibilityRole="menuitem" accessibilityState={{ selected: m === mode }} onPress={() => { onChange(m); setOpen(false); }}
120
- style={state => ({ flexDirection: "row", alignItems: "center", gap: 8, minHeight: touch ? 44 : 34, paddingHorizontal: 10, backgroundColor: (state as { hovered?: boolean }).hovered ? c.surface2 : "transparent" })}>
152
+ style={state => ({ flexDirection: "row", alignItems: "center", gap: 8, minHeight: touch ? 48 : 34, paddingHorizontal: touch ? 12 : 10, backgroundColor: (state as { hovered?: boolean }).hovered ? c.surface2 : "transparent" })}>
121
153
  <View style={{ width: 14, alignSelf: "flex-start", paddingTop: 2 }}>{m === mode && <Icon name="Check" size={13} color={c.foreground} />}</View>
122
154
  <View style={{ flex: 1 }}>
123
155
  <Text style={{ color: c.foreground, fontSize: 13, lineHeight: 17 }}>{SORT_LABEL[m]}</Text>
124
156
  <Text numberOfLines={1} style={{ color: c.foregroundMuted, fontSize: 11, lineHeight: 15 }}>{SORT_HINT[m]}</Text>
125
157
  </View>
126
158
  </Pressable>)}
127
- <Text style={{ color: c.foregroundMuted, fontSize: 11, paddingHorizontal: 10, paddingTop: 6, paddingBottom: 4, marginTop: 4, borderTopWidth: 1, borderTopColor: c.border }}>Priority: {priorityNote(rankedAt, now)}</Text>
159
+ <View style={{ marginTop: 4, borderTopWidth: 1, borderTopColor: c.border, paddingTop: 2 }}>
160
+ {rank?.enabled && onRerank && <Pressable accessibilityRole="menuitem" accessibilityState={{ busy: running, disabled: running }} disabled={running} onPress={() => void rerank()}
161
+ style={state => ({ flexDirection: "row", alignItems: "center", gap: 8, minHeight: touch ? 44 : 34, paddingHorizontal: 10, backgroundColor: (state as { hovered?: boolean }).hovered ? c.surface2 : "transparent" })}>
162
+ <View style={{ width: 14 }}>{running ? <Spinner color={c.foregroundMuted} size={12} label="Ranking" /> : <Icon name="RefreshCw" size={13} color={c.foreground} />}</View>
163
+ <Text style={{ color: running ? c.foregroundMuted : c.foreground, fontSize: 13 }}>{running ? "Ranking…" : "Re-rank now"}</Text>
164
+ </Pressable>}
165
+ {/* Phones: before anything is ranked, "Priority: By urgency" only repeats the checked row's hint. */}
166
+ {!(touch && !rankedAt) && <Text style={{ color: c.foregroundMuted, fontSize: 11, paddingHorizontal: 10, paddingTop: 4, paddingBottom: 4 }}>Priority: {note}</Text>}
167
+ </View>
128
168
  </View>}
129
169
  </View>;
130
170
  }
@@ -145,19 +185,32 @@ export function StatusStrip({ theme, model, filter, onFilter, touch, dense }: {
145
185
  const chip = (key: string, label: string, n: number | null, selected: boolean, onPress: () => void, tone?: string) => {
146
186
  const muted = n === 0;
147
187
  const color = selected ? c.foreground : muted ? withAlpha(c.foregroundMuted, 0.6) : tone ?? c.foreground;
188
+ const pill = (hovered?: boolean) => ({ flexDirection: "row" as const, alignItems: "center" as const, gap: 5, height: touch ? 32 : 30, paddingHorizontal: touch ? 10 : 8, borderRadius: 16,
189
+ borderWidth: 1, borderColor: selected ? withAlpha(c.foreground, 0.4) : "transparent",
190
+ backgroundColor: selected ? c.surface2 : hovered ? c.surface1 : "transparent" });
148
191
  return <Pressable key={key} accessibilityRole="button" accessibilityState={{ selected }} accessibilityLabel={n === null ? label : `${label}, ${n}${selected ? ". Showing only these; press to show all" : ". Show only these"}`} onPress={onPress}
149
- style={state => ({ flexDirection: "row", alignItems: "center", gap: 5, height: touch ? 36 : 30, paddingHorizontal: 8, borderRadius: 15,
150
- borderWidth: 1, borderColor: selected ? withAlpha(c.foreground, 0.4) : "transparent",
151
- backgroundColor: selected ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
152
- {n !== null && <Text style={{ color, fontSize: 13, fontWeight: "600", fontVariant: ["tabular-nums"] }}>{n}</Text>}
153
- <Text style={{ color: selected ? c.foreground : muted ? withAlpha(c.foregroundMuted, 0.6) : c.foregroundMuted, fontSize: 12 }}>{label}</Text>
154
- {selected && <Icon name="X" size={11} color={c.foregroundMuted} />}
192
+ // Phones: a 32-tall chip inside a real 44 touch box (react-native-web ignores hitSlop).
193
+ style={touch ? { paddingVertical: 6 } : state => pill((state as { hovered?: boolean }).hovered)}>
194
+ {state => {
195
+ const inner = <>
196
+ {n !== null && <Text style={{ color, fontSize: 13, fontWeight: "600", fontVariant: ["tabular-nums"] }}>{n}</Text>}
197
+ <Text style={{ color: selected ? c.foreground : muted ? withAlpha(c.foregroundMuted, 0.6) : c.foregroundMuted, fontSize: 12 }}>{label}</Text>
198
+ {selected && <Icon name="X" size={11} color={c.foregroundMuted} />}
199
+ </>;
200
+ return touch ? <View style={pill((state as { hovered?: boolean }).hovered)}>{inner}</View> : inner;
201
+ }}
155
202
  </Pressable>;
156
203
  };
157
- return <View accessibilityRole="toolbar" accessibilityLabel="Status" style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", columnGap: dense ? 0 : 2, rowGap: 2, paddingHorizontal: dense ? 4 : 10 }}>
158
- {STRIP.map(s => chip(s.id, s.label, counts[s.id], filter === s.id, () => onFilter(filter === s.id ? null : s.id), s.id === "needs" && counts.needs ? c.statusWarning : undefined))}
204
+ const chips = <>
205
+ {STRIP.filter(s => !touch || counts[s.id] > 0 || filter === s.id).map(s => chip(s.id, s.label, counts[s.id], filter === s.id, () => onFilter(filter === s.id ? null : s.id), s.id === "needs" && counts.needs ? c.statusWarning : undefined))}
159
206
  {counts.later > 0 && chip("later", "Later", counts.later, filter === "later", () => onFilter(filter === "later" ? null : "later"))}
160
207
  {counts.archivable > 0 && <Text style={{ color: c.statusSuccess, fontSize: 12, paddingHorizontal: 6 }}>{counts.archivable} to archive</Text>}
208
+ </>;
209
+ // Phones: only groups that have something, on one line that scrolls sideways instead of wrapping.
210
+ if (touch) return <ScrollView horizontal showsHorizontalScrollIndicator={false} accessibilityRole="toolbar" accessibilityLabel="Status"
211
+ contentContainerStyle={{ flexDirection: "row", alignItems: "center", gap: 4, paddingHorizontal: 12, paddingVertical: 2 }}>{chips}</ScrollView>;
212
+ return <View accessibilityRole="toolbar" accessibilityLabel="Status" style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", columnGap: dense ? 0 : 2, rowGap: 2, paddingHorizontal: dense ? 4 : 10 }}>
213
+ {chips}
161
214
  </View>;
162
215
  }
163
216
 
@@ -232,11 +285,33 @@ export function GroupChip({ group, c }: { group: HomeGroupId | "archived"; c: Co
232
285
  </View>;
233
286
  }
234
287
 
235
- export function ResultRow({ item, theme, active, dense, touch, onPress, s: row }: { item: OmniboxItem; theme: Theme; active: boolean; dense: boolean; touch: boolean; onPress: () => void; s?: Workstream }) {
288
+ export function ResultRow({ item, theme, active, dense, touch, onPress, s: row }: { item: WorkspaceItem; theme: Theme; active: boolean; dense: boolean; touch: boolean; onPress: () => void; s?: Workstream }) {
236
289
  const c = theme.colors;
237
290
  const { hit } = item;
238
291
  const via = hit.via ? excerpt(hit.via.text, hit.via.ranges, dense ? 56 : 90) : null;
239
292
  const archived = hit.group === "archived";
293
+ // Phones: the list's own row (glyph, two-line 15/20 title with the age, state word in tone, PRs as text, a divider),
294
+ // with the match highlighted. No group pill: the state word already says it.
295
+ if (touch) {
296
+ const tone = row ? glyphColor(row, c, true) : c.foregroundMuted;
297
+ return <Pressable accessibilityRole="button" accessibilityState={{ selected: active }} accessibilityLabel={`${hit.title}${row?.word ? `. ${row.word}` : ""}${hit.via ? `, ${FIELD_LABEL[hit.via.field]}: ${hit.via.text}` : ""}`} onPress={onPress}
298
+ style={state => ({ flexDirection: "row", alignItems: "flex-start", gap: 10, minHeight: 56, paddingLeft: 14, paddingRight: 16, paddingVertical: 12, borderBottomWidth: 1, borderBottomColor: withAlpha(c.border, 0.6),
299
+ backgroundColor: active || state.pressed ? c.surface2 : "transparent" })}>
300
+ <View style={{ paddingTop: 2 }}><Icon name={archived ? "Archive" : row?.icon ?? "Circle"} size={17} color={archived ? c.foregroundMuted : tone} /></View>
301
+ <View style={{ flex: 1, minWidth: 0, gap: 3 }}>
302
+ <View style={{ flexDirection: "row", alignItems: "flex-start", gap: 8 }}>
303
+ <View style={{ flex: 1, minWidth: 0 }}><Highlighted text={hit.title} ranges={hit.titleRanges} color={archived ? c.foregroundMuted : c.foreground} hit={c.foreground} mark={c.statusWarning} size={15} weight="500" lines={2} /></View>
304
+ {row && <Age iso={row.at} c={c} size={12} />}
305
+ </View>
306
+ {via ? <Text numberOfLines={2} style={{ color: c.foregroundMuted, fontSize: 13, lineHeight: 18 }}>{FIELD_LABEL[hit.via!.field]} · <Highlighted text={via.text} ranges={via.ranges} color={c.foregroundMuted} hit={c.foreground} mark={c.statusWarning} size={13} /></Text>
307
+ : archived ? <Text style={{ color: c.foregroundMuted, fontSize: 13, lineHeight: 18 }}>Archived</Text>
308
+ : row && (row.word || row.line) ? <Text numberOfLines={2} style={{ color: c.foregroundMuted, fontSize: 13, lineHeight: 18 }}>
309
+ {row.word ? <Text style={{ color: tone, fontWeight: "600" }}>{row.word}</Text> : null}{row.word && row.line ? " · " : ""}{row.line}
310
+ </Text> : null}
311
+ {row?.pr && <Text numberOfLines={1} style={{ color: c.foregroundMuted, fontSize: 12, lineHeight: 17 }}><PrSummaryText s={row} c={c} /></Text>}
312
+ </View>
313
+ </Pressable>;
314
+ }
240
315
  return <Pressable accessibilityRole="button" accessibilityState={{ selected: active }} accessibilityLabel={`${hit.title}${hit.via ? `, ${FIELD_LABEL[hit.via.field]}: ${hit.via.text}` : ""}`} onPress={onPress}
241
316
  style={state => ({ flexDirection: "row", alignItems: "center", gap: 10, minHeight: touch ? 56 : dense ? 40 : 44, paddingHorizontal: dense ? 8 : 16, paddingVertical: 4,
242
317
  borderLeftWidth: 2, borderLeftColor: active ? withAlpha(c.foreground, 0.5) : "transparent",
@@ -255,13 +330,33 @@ export function ResultRow({ item, theme, active, dense, touch, onPress, s: row }
255
330
  </Pressable>;
256
331
  }
257
332
 
333
+ /**
334
+ * The omnibox's last row: the query as an ask for the Overseer. Enter (or a tap) sends it as typed; the Overseer
335
+ * finds the agent that owns it. Quiet until it's the active row, so it never competes with real matches.
336
+ */
337
+ export function AskRow({ ask, theme, active, dense, touch, sending, onPress }: { ask: string; theme: Theme; active: boolean; dense: boolean; touch: boolean; sending: boolean; onPress: () => void }) {
338
+ const c = theme.colors;
339
+ return <Pressable accessibilityRole="button" accessibilityState={{ selected: active, busy: sending }} accessibilityLabel={`Ask the Overseer: ${ask}`} accessibilityHint="Sends this to the Overseer, which passes it to the agent that owns it" disabled={sending} onPress={onPress}
340
+ style={state => ({ flexDirection: "row", alignItems: "center", gap: 10, minHeight: touch ? 56 : dense ? 40 : 44, paddingHorizontal: dense ? 8 : 16, paddingVertical: 4,
341
+ borderLeftWidth: 2, borderLeftColor: active ? withAlpha(c.foreground, 0.5) : "transparent",
342
+ backgroundColor: active ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
343
+ <Text numberOfLines={dense ? 2 : 1} style={{ flex: 1, minWidth: 0, fontSize: 13, lineHeight: 18 }}>
344
+ <Text style={{ color: c.foregroundMuted }}>Ask the Overseer: </Text>
345
+ <Text style={{ color: c.foreground, fontWeight: "500" }}>{ask}</Text>
346
+ </Text>
347
+ {sending ? <Spinner color={c.foregroundMuted} size={12} label="Sending to the Overseer" />
348
+ : active && Platform.OS === "web" && !touch ? <Text style={{ color: c.foregroundMuted, fontSize: 11, paddingHorizontal: 4, borderRadius: 3, borderWidth: 1, borderColor: withAlpha(c.foreground, 0.2) }}>↵</Text> : null}
349
+ <Icon name="MessagesSquare" size={14} color={active ? c.foreground : c.foregroundMuted} />
350
+ </Pressable>;
351
+ }
352
+
258
353
  /** The muted reason and source chip a fresh external priority adds to a row. */
259
- export function PriorityLine({ reason, source, c, size = 12 }: { reason: string; source: { kind: keyof typeof PRIORITY_SOURCE_LABEL; label: string } | null; c: Colors; size?: number }) {
354
+ export function PriorityLine({ reason, source, c, size = 12, lines = 1 }: { reason: string; source: { kind: keyof typeof PRIORITY_SOURCE_LABEL; label: string } | null; c: Colors; size?: number; lines?: number }) {
260
355
  return <View style={{ flexDirection: "row", alignItems: "center", gap: 6, minWidth: 0 }}>
261
356
  {source && <View style={{ paddingHorizontal: 5, height: 16, justifyContent: "center", borderRadius: 3, backgroundColor: c.surface2 }}>
262
357
  <Text numberOfLines={1} style={{ color: c.foregroundMuted, fontSize: 10, lineHeight: 13 }}>{PRIORITY_SOURCE_LABEL[source.kind]}</Text>
263
358
  </View>}
264
- <Text numberOfLines={1} style={{ flex: 1, minWidth: 0, color: c.foregroundMuted, fontSize: size, fontStyle: "italic" }}>{reason}</Text>
359
+ <Text numberOfLines={lines} style={{ flex: 1, minWidth: 0, color: c.foregroundMuted, fontSize: size, fontStyle: "italic" }}>{reason}</Text>
265
360
  </View>;
266
361
  }
267
362