paseo-follow-up 2.2.1-beta.0 → 2.3.0-beta.0
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/catch-up.tsx +22 -12
- package/client/home-chrome.tsx +6 -2
- package/client/home-list.tsx +6 -4
- package/client/home.tsx +60 -10
- package/client/kit.tsx +3 -2
- package/client/list-keys.ts +15 -6
- package/client/tasks.tsx +6 -4
- package/index.server.ts +2 -0
- package/package.json +1 -1
- package/server/daemon.ts +28 -13
- package/server/engine.ts +19 -6
- package/server/mcp-source.ts +1 -1
- package/server/mcp.mjs +1 -1
- package/shared/attention.ts +8 -3
- package/shared/home-keys.ts +16 -0
- package/shared/list-keys.ts +27 -4
- package/shared/model.ts +10 -1
- package/shared/send-decision.ts +38 -4
- package/shared/status-invariants.ts +17 -3
package/client/catch-up.tsx
CHANGED
|
@@ -596,27 +596,37 @@ export function Finished({ theme, compact, stats, empty, onHome, onSkipped }: {
|
|
|
596
596
|
</ScrollView>;
|
|
597
597
|
}
|
|
598
598
|
|
|
599
|
-
/**
|
|
600
|
-
export
|
|
599
|
+
/** A keys sheet's rows: a key (as spelled in its list) and what it does. */
|
|
600
|
+
export type KeySection = { title: string; keys: readonly { key: string; what: string }[] };
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* S: the keys, from the one list the handler reads (Catch up: shared/catch-up.ts; Home: shared/home-keys.ts). A dialog
|
|
604
|
+
* over the screen; S or its X closes it.
|
|
605
|
+
*/
|
|
606
|
+
export function KeysSheet({ theme, onClose, label = "Catch up keys", sections: given, keyWidth = 64 }: { theme: Theme; onClose: () => void; label?: string; sections?: readonly KeySection[]; /** The key column, wide enough for the list's longest key so every description lines up. */ keyWidth?: number }) {
|
|
601
607
|
const dictation = !!hostDictation();
|
|
608
|
+
const sections = given ?? catchUpSections(dictation);
|
|
602
609
|
const c = theme.colors; const t = text(c, false);
|
|
603
|
-
const row = (k:
|
|
604
|
-
<View style={{
|
|
605
|
-
<Text style={t.meta}>{k.what}</Text>
|
|
606
|
-
</View>;
|
|
607
|
-
const section = (title: string, keys: readonly typeof CATCH_UP_KEYS[number][]) => <View style={{ gap: 6 }}>
|
|
608
|
-
<Text style={[t.small, { fontWeight: "600" }]}>{title}</Text>{keys.map(row)}
|
|
610
|
+
const row = (k: KeySection["keys"][number], i: number) => <View key={`${k.key}-${i}`} style={{ flexDirection: "row", gap: 10, alignItems: "center" }}>
|
|
611
|
+
<View style={{ width: keyWidth }}><Text style={[t.meta, { alignSelf: "flex-start", paddingHorizontal: 6, borderRadius: 4, borderWidth: 1, borderColor: c.border, color: c.foreground, fontVariant: ["tabular-nums"] }]}>{keyLabel(k.key, isMac())}</Text></View>
|
|
612
|
+
<Text style={[t.meta, { flex: 1, minWidth: 0 }]}>{k.what}</Text>
|
|
609
613
|
</View>;
|
|
610
|
-
return <View role="dialog" accessibilityLabel=
|
|
614
|
+
return <View role="dialog" accessibilityLabel={label} style={{ position: "absolute", zIndex: 10, right: 20, top: 8, width: 236 + keyWidth, padding: 16, gap: 12, borderRadius: 10, borderWidth: 1, borderColor: c.border, backgroundColor: c.surface1, shadowColor: "#000", shadowOpacity: 0.25, shadowRadius: 12 }}>
|
|
611
615
|
<View style={{ flexDirection: "row", alignItems: "center" }}>
|
|
612
616
|
<Text style={[t.label, { flex: 1, fontWeight: "600" }]}>Keys</Text>
|
|
613
617
|
<IconButton theme={theme} compact={false} icon="X" label="Close the keys (S)" tooltip onPress={onClose} />
|
|
614
618
|
</View>
|
|
615
|
-
{
|
|
616
|
-
|
|
617
|
-
|
|
619
|
+
{sections.filter(s => s.keys.length).map(s => <View key={s.title} style={{ gap: 6 }}>
|
|
620
|
+
<Text style={[t.small, { fontWeight: "600" }]}>{s.title}</Text>{s.keys.map(row)}
|
|
621
|
+
</View>)}
|
|
618
622
|
</View>;
|
|
619
623
|
}
|
|
624
|
+
/** Catch up's sheet: the dictation key only where the host has a mic. */
|
|
625
|
+
const catchUpSections = (dictation: boolean): readonly KeySection[] => [
|
|
626
|
+
{ title: "On a card", keys: CATCH_UP_KEYS.filter(k => !k.when && (!k.needs || dictation)) },
|
|
627
|
+
{ title: "In More context", keys: CATCH_UP_KEYS.filter(k => k.when === "more") },
|
|
628
|
+
{ title: "In the queue", keys: CATCH_UP_KEYS.filter(k => k.when === "rail") },
|
|
629
|
+
];
|
|
620
630
|
|
|
621
631
|
/** A desktop hover title on any control (react-native-web drops `title` on a Pressable; IconButton does the same). */
|
|
622
632
|
function Tip({ label, children }: { label: string; children: ReactNode }) {
|
package/client/home-chrome.tsx
CHANGED
|
@@ -116,6 +116,9 @@ export function QueryField({ theme, value, onChange, placeholder, icon, dense, i
|
|
|
116
116
|
{...(listKeys ? { dataSet: { listKeys: "1" } } as object : {})}
|
|
117
117
|
onFocus={() => setFocused(true)} onBlur={() => setFocused(false)}
|
|
118
118
|
onSubmitEditing={onSubmit}
|
|
119
|
+
// A single-line field blurs on submit by default, which dropped focus on the page after a search pick while the
|
|
120
|
+
// results stayed up, so the second Enter reached nothing (the-selected-workspace-opens-with-enter).
|
|
121
|
+
blurOnSubmit={false}
|
|
119
122
|
onKeyPress={e => {
|
|
120
123
|
const key = (e.nativeEvent as { key?: string }).key;
|
|
121
124
|
if (key === "ArrowDown" && onArrow) { e.preventDefault?.(); onArrow(1); }
|
|
@@ -135,12 +138,13 @@ export function QueryField({ theme, value, onChange, placeholder, icon, dense, i
|
|
|
135
138
|
* Home's search. Its chip names the search-from-anywhere key when one is set (it works here too), else "/"; plain "/"
|
|
136
139
|
* focuses it on Home either way (useSlashToFocus).
|
|
137
140
|
*/
|
|
138
|
-
|
|
141
|
+
/** `onEnter`: the active result, or null when the query is empty (Home then opens its selection). */
|
|
142
|
+
export function SearchField({ theme, omnibox, dense, onEnter, anywhereKey }: { theme: Theme; omnibox: Omnibox; dense: boolean; onEnter: (item: OmniboxItem | null) => void; anywhereKey?: string | null }) {
|
|
139
143
|
const { query, setQuery, results, active, move, inputRef, askOn } = omnibox;
|
|
140
144
|
const placeholder = askOn ? dense ? "Search or ask the Overseer" : "Search, or ask the Overseer" : "Search workspaces, branches, PRs";
|
|
141
145
|
return <QueryField theme={theme} value={query} onChange={setQuery} placeholder={placeholder} icon="Search" dense={dense} inputRef={inputRef} slashHint={anywhereKey || "/"}
|
|
142
146
|
slashTitle={anywhereKey ? `${anywhereKey} from anywhere · / on Home` : "/ focuses the search"}
|
|
143
|
-
onSubmit={() => { const item = results?.[active]; if (item) onEnter(item); }} onArrow={move} listKeys={!query.trim()} />;
|
|
147
|
+
onSubmit={() => { const item = results?.[active]; if (item || !query.trim()) onEnter(item ?? null); }} onArrow={move} listKeys={!query.trim()} />;
|
|
144
148
|
}
|
|
145
149
|
|
|
146
150
|
/**
|
package/client/home-list.tsx
CHANGED
|
@@ -79,11 +79,11 @@ export type HomeListProps = {
|
|
|
79
79
|
menu: { build: (s: Workstream) => RowMenuSection[]; pick: (s: Workstream, item: RowMenuItem) => void };
|
|
80
80
|
/**
|
|
81
81
|
* Desktop and web keys (client/list-keys.ts, one-keyboard-walk-for-every-list): ↑/↓ and j/k walk the rows in this
|
|
82
|
-
* list's order, Home/End jump, Enter opens. "select" moves the selection (Home); "focus" moves only the focus and
|
|
82
|
+
* list's order, Home/End jump, Enter or O opens, S shows the keys (`onKeys`, Home). "select" moves the selection (Home); "focus" moves only the focus and
|
|
83
83
|
* Enter opens (the sidebar view). `scope`: where the keys count (default: this list); `claimBody`: also with
|
|
84
84
|
* nothing focused.
|
|
85
85
|
*/
|
|
86
|
-
keys?: { mode: "select" | "focus"; onOpen: (key: string) => void; scope?: { current: unknown }; claimBody?: boolean };
|
|
86
|
+
keys?: { mode: "select" | "focus"; onOpen: (key: string) => void; onKeys?: () => void; scope?: { current: unknown }; claimBody?: boolean };
|
|
87
87
|
/** The selected row's fill. Paseo's sidebar view passes its own selected-item colour (sidebarSelected); Home: surface2. */
|
|
88
88
|
selectedBg?: string;
|
|
89
89
|
};
|
|
@@ -164,11 +164,13 @@ export function HomeList({ model, theme, dense = false, touch, selectedKey, onSe
|
|
|
164
164
|
// results through the omnibox instead.
|
|
165
165
|
const order = useMemo(() => results ? [] : walkOrder(data), [data, results]);
|
|
166
166
|
useListKeys({
|
|
167
|
-
|
|
167
|
+
// On while a search shows its results too: the walk has no rows then (walkOrder), but Enter with nothing focused
|
|
168
|
+
// still opens the selection the search picked.
|
|
169
|
+
enabled: !!keys && !touch, order, mode: keys?.mode ?? "focus",
|
|
168
170
|
// Home draws the brief as selected while nothing is.
|
|
169
171
|
selectedKey: selectedKey ?? (order[0] === BRIEF_KEY ? BRIEF_KEY : null),
|
|
170
172
|
scope: () => (keys?.scope?.current ?? rootRef.current) as { contains(n: unknown): boolean; checkVisibility?(): boolean } | null,
|
|
171
|
-
claimBody: keys?.claimBody, onSelect, onOpen: key => keys?.onOpen(key),
|
|
173
|
+
claimBody: keys?.claimBody, onSelect, onOpen: key => keys?.onOpen(key), onKeys: keys?.onKeys ? () => keys.onKeys?.() : undefined,
|
|
172
174
|
reveal: key => { const index = data.findIndex(e => e.key === key); if (index >= 0) listRef.current?.scrollToIndex({ index, viewPosition: 0.5, animated: false }); },
|
|
173
175
|
});
|
|
174
176
|
// Keep the keyboard-active result in view.
|
package/client/home.tsx
CHANGED
|
@@ -36,7 +36,9 @@ import { withAlpha, isLight, mergedColor, type Colors } from "./theme";
|
|
|
36
36
|
import { UpdateNotice, VersionMark } from "./updates";
|
|
37
37
|
import { WhatsNewGate } from "./release-notes";
|
|
38
38
|
import { ViewSync } from "./view-store";
|
|
39
|
-
import { CatchUp, CatchUpButton } from "./catch-up";
|
|
39
|
+
import { CatchUp, CatchUpButton, KeysSheet } from "./catch-up";
|
|
40
|
+
import { searchEnter } from "../shared/list-keys";
|
|
41
|
+
import { HOME_KEYS } from "../shared/home-keys";
|
|
40
42
|
import { deckCards } from "../shared/catch-up";
|
|
41
43
|
import { ResizableSplit } from "./split";
|
|
42
44
|
import type { SearchKey } from "./search-key";
|
|
@@ -119,7 +121,9 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
|
|
|
119
121
|
// host's ← is the only back control and it lands on the list. Desktop selects in place beside the list.
|
|
120
122
|
const route = compact && deps.openItem ? deps.openItem : null;
|
|
121
123
|
const onSelect = useCallback((key: string) => { if (route) route(key); else setSelected(key === BRIEF_KEY ? null : key); }, [route]);
|
|
122
|
-
|
|
124
|
+
// A key names a row (`ws:…`, an agent row) or, from a ⌘K or chat link, an agent (`agent:<id>`): one lookup for both.
|
|
125
|
+
const resolve = (key: string | null) => key ? model.byKey.get(key) ?? (key.startsWith("agent:") ? [...model.byKey.values()].find(x => x.agentId === key.slice(6)) ?? null : null) : null;
|
|
126
|
+
const current = resolve(selected);
|
|
123
127
|
const tracked = useSyncExternalStore(deps.sources.live.subscribe, deps.sources.live.version, deps.sources.live.version);
|
|
124
128
|
const rows = useInbox(inbox, () => inbox.rows());
|
|
125
129
|
// Go through's count is its cards (one per ask), the same deck the mode opens on.
|
|
@@ -137,20 +141,31 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
|
|
|
137
141
|
try {
|
|
138
142
|
const after = await send({ workspaceId: s.workspaceId, batchId: s.sendNow.batchId });
|
|
139
143
|
const b = after.batches.find(x => x.id === s.sendNow!.batchId);
|
|
140
|
-
toast.show(!b || ["sent", "sending", "completed"].includes(b.state) ? `Sent to ${s.title}` : b.result || "Queued. It goes out when the agent is free.", { variant: !b || ["sent", "sending", "completed"].includes(b.state) ? "success" : "info" });
|
|
144
|
+
toast.show(!b || ["sent", "sending", "completed"].includes(b.state) ? `Sent to ${s.title}` : b.result || "Queued. It goes out when the main agent is free.", { variant: !b || ["sent", "sending", "completed"].includes(b.state) ? "success" : "info" });
|
|
141
145
|
} catch (e) { toast.error(errorText(e)); } finally { deps.sources.live.refresh(); }
|
|
142
146
|
}, [send, toast, deps.sources.live]);
|
|
143
147
|
// The omnibox's "Ask the Overseer" row: send, then show the conversation it lands in.
|
|
144
148
|
const [asking, setAsking] = useState(false);
|
|
145
149
|
const [pendingAsk, setPendingAsk] = useState<string | null>(null);
|
|
146
|
-
|
|
150
|
+
// Enter in the search (the-selected-workspace-opens-with-enter): the first press shows the result in the pane, a
|
|
151
|
+
// press on the result already showing opens its chat, and with no query Enter opens what is selected.
|
|
152
|
+
const openRef = useRef<(key: string) => void>(() => undefined);
|
|
153
|
+
const selectedRef = useRef<string | null>(null); selectedRef.current = current?.key ?? selected;
|
|
154
|
+
const pick = useCallback(async (picked: OmniboxItem | null) => {
|
|
155
|
+
if (!route && (!picked || picked.ask === undefined)) {
|
|
156
|
+
const move = searchEnter({ item: picked ? resolve(picked.key)?.key ?? picked.key : null, selected: selectedRef.current, query: omnibox.query });
|
|
157
|
+
if (move === "open") { openRef.current(picked?.key ?? selectedRef.current!); return; }
|
|
158
|
+
}
|
|
159
|
+
if (!picked) return;
|
|
160
|
+
const item = picked;
|
|
147
161
|
if (item.ask === undefined) { if (route) route(item.key); else setSelected(item.key); return; }
|
|
148
162
|
if (asking) return;
|
|
149
163
|
setAsking(true);
|
|
150
164
|
// No toast: the conversation opens on the sent words, which says it more plainly.
|
|
151
165
|
try { await deps.sources.extras.askOverseer(item.ask); omnibox.setQuery(""); omnibox.inputRef.current?.blur(); setPendingAsk(item.ask); if (route) route(OVERSEER_KEY); else setSelected(OVERSEER_KEY); inbox.refresh(); }
|
|
152
166
|
catch (e) { toast.error(errorText(e)); } finally { setAsking(false); }
|
|
153
|
-
|
|
167
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
168
|
+
}, [asking, deps.sources.extras, omnibox, inbox, toast, route, model]);
|
|
154
169
|
// ⌘K "Follow-up: Ask the Overseer" opens Home with `?ask=<nonce>`: select it and focus its reply box. A param, not
|
|
155
170
|
// shared state, so it works whether Home was already open or mounts fresh.
|
|
156
171
|
const [replyFocus, setReplyFocus] = useState(0);
|
|
@@ -207,10 +222,13 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
|
|
|
207
222
|
// Enter on a row: its chat, as Open full does. The brief has nothing to open; the Overseer opens once it runs.
|
|
208
223
|
const openKey = (key: string) => {
|
|
209
224
|
if (key === OVERSEER_KEY) { const id = overseerStatus?.agentId; if (id && navigation) navigation.openAgent({ agentId: id }); return; }
|
|
210
|
-
const s =
|
|
225
|
+
const s = resolve(key); if (s) openFull(s);
|
|
211
226
|
};
|
|
227
|
+
openRef.current = openKey;
|
|
228
|
+
// S: Home's keys (desktop web), from the one list (shared/home-keys.ts).
|
|
229
|
+
const [keysOpen, setKeysOpen] = useState(false);
|
|
212
230
|
const list = <HomeList model={model} theme={theme} dense={compact} touch={compact} selectedKey={selected} onSelect={onSelect} briefLine={briefLine}
|
|
213
|
-
keys={{ mode: "select", onOpen: openKey, scope: homeRef, claimBody: true }}
|
|
231
|
+
keys={{ mode: "select", onOpen: openKey, onKeys: () => setKeysOpen(v => !v), scope: homeRef, claimBody: true }}
|
|
214
232
|
results={omnibox.results} activeResult={omnibox.active} onResult={item => void pick(item)} filter={filter} overseer={overseer} asking={asking} menu={rowMenu} onSendNow={sendNow}
|
|
215
233
|
// Phones: the host header already says Follow-up, so no "Home" title row; search, sort and settings share one row and
|
|
216
234
|
// the meters move to the end of the list.
|
|
@@ -222,7 +240,7 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
|
|
|
222
240
|
// Phones: the setup offer goes after the Needs-you group when there is one, so the first ask stays high.
|
|
223
241
|
afterNeeds={compact && model.needs > 0 ? <SetupOffer theme={theme} compact view={props.onboarding} /> : undefined}
|
|
224
242
|
emptyAction={compact ? <Button theme={theme} compact kind="secondary" icon="Settings" title="Project settings" onPress={deps.openSettings} /> : undefined}
|
|
225
|
-
top={<ListTop theme={theme} dense={compact} title={compact ? undefined : <ListHeader theme={theme} compact={compact} onSettings={deps.openSettings} />}>
|
|
243
|
+
top={<ListTop theme={theme} dense={compact} title={compact ? undefined : <ListHeader theme={theme} compact={compact} onSettings={deps.openSettings} onKeys={() => setKeysOpen(v => !v)} />}>
|
|
226
244
|
{/* zIndex: on web every View is its own stacking context, so the sort menu only paints and hit-tests above the
|
|
227
245
|
strip and meters below if this row sits above them. */}
|
|
228
246
|
<View style={{ zIndex: 2, flexDirection: "row", alignItems: "center", gap: compact ? 2 : 6, paddingLeft: compact ? 16 : 16, paddingRight: compact ? 6 : 16 }}>
|
|
@@ -256,6 +274,11 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
|
|
|
256
274
|
{updateSheets}
|
|
257
275
|
<View style={{ position: "absolute", left: 12, right: 12, bottom: 12 }}><UndoBar store={inbox} theme={theme} touch={false} /></View>
|
|
258
276
|
</View>} />
|
|
277
|
+
{keysOpen && <KeysSheet theme={theme} label="Home keys" keyWidth={104} onClose={() => setKeysOpen(false)} sections={[
|
|
278
|
+
{ title: "In the list", keys: HOME_KEYS.filter(k => !k.when) },
|
|
279
|
+
{ title: "In the search", keys: HOME_KEYS.filter(k => k.when === "search").map(k => k.key === "/" && anywhereKey ? { ...k, key: `/ or ${anywhereKey}` } : k) },
|
|
280
|
+
{ title: "Answering", keys: HOME_KEYS.filter(k => k.when === "pane") },
|
|
281
|
+
]} />}
|
|
259
282
|
</View>;
|
|
260
283
|
}
|
|
261
284
|
|
|
@@ -296,7 +319,7 @@ export function DisplaySplit({ theme, main, side, field, defaultFraction, range,
|
|
|
296
319
|
const HOME_DETAIL_MIN_PX = 360;
|
|
297
320
|
const HOME_LIST_MIN_PX = 480;
|
|
298
321
|
|
|
299
|
-
function ListHeader({ theme, compact, onSettings }: { theme: Theme; compact: boolean; onSettings: () => void }) {
|
|
322
|
+
function ListHeader({ theme, compact, onSettings, onKeys }: { theme: Theme; compact: boolean; onSettings: () => void; onKeys?: () => void }) {
|
|
300
323
|
const c = theme.colors;
|
|
301
324
|
return <View style={{ flexDirection: "row", alignItems: "center", gap: 8, paddingHorizontal: 16 }}>
|
|
302
325
|
{/* Home first, the version second: a muted caption on the title's line, never a control beside the cog. */}
|
|
@@ -304,6 +327,8 @@ function ListHeader({ theme, compact, onSettings }: { theme: Theme; compact: boo
|
|
|
304
327
|
<Text accessibilityRole="header" style={{ color: c.foreground, fontSize: compact ? 17 : 15, fontWeight: "600" }}>Home</Text>
|
|
305
328
|
<VersionMark theme={theme} touch={compact} openSettings={onSettings} />
|
|
306
329
|
</View>
|
|
330
|
+
{/* The keys sheet's way in for the mouse (S from the keyboard); desktop web, where the keys are. */}
|
|
331
|
+
{onKeys && Platform.OS === "web" && <IconButton theme={theme} compact={compact} icon="Keyboard" label="Keys (S)" tooltip onPress={onKeys} />}
|
|
307
332
|
<IconButton theme={theme} compact={compact} icon="Settings" label="Follow-up settings" onPress={onSettings} />
|
|
308
333
|
</View>;
|
|
309
334
|
}
|
|
@@ -368,6 +393,30 @@ function useTail(handle: ReturnType<typeof useAgentLive>["handle"], key: string,
|
|
|
368
393
|
return { steps, error, seenAt, asleep, loading, woken: wake > 0, load: () => setWake(n => n + 1) };
|
|
369
394
|
}
|
|
370
395
|
|
|
396
|
+
/**
|
|
397
|
+
* Send now under a queued message's line in the detail pane: phones list Sending rows without it (dense rows), so this
|
|
398
|
+
* is where a phone sends a waiting repair (a-repair-goes-to-a-free-main-agent). The same Send as the row's and the
|
|
399
|
+
* Tasks strip's: taken while the main agent is busy, it goes the moment the main agent is free.
|
|
400
|
+
*/
|
|
401
|
+
function DetailSendNow({ s, theme, compact, deps }: { s: Workstream; theme: Theme; compact: boolean; deps: HomeDeps }) {
|
|
402
|
+
const send = useRpc(sendRpc); const toast = useToast();
|
|
403
|
+
const [busy, setBusy] = useState(false);
|
|
404
|
+
const n = s.sendNow!.count;
|
|
405
|
+
const press = async () => {
|
|
406
|
+
if (!s.workspaceId || !s.sendNow) return;
|
|
407
|
+
setBusy(true);
|
|
408
|
+
try {
|
|
409
|
+
const after = await send({ workspaceId: s.workspaceId, batchId: s.sendNow.batchId });
|
|
410
|
+
const b = after.batches.find(x => x.id === s.sendNow!.batchId);
|
|
411
|
+
const out = !b || ["sent", "sending", "completed"].includes(b.state);
|
|
412
|
+
toast.show(out ? `Sent to ${s.title}` : b.result || "Queued. It goes out when the main agent is free.", { variant: out ? "success" : "info" });
|
|
413
|
+
} catch (e) { toast.error(errorText(e)); } finally { setBusy(false); deps.sources.live.refresh(); }
|
|
414
|
+
};
|
|
415
|
+
return <View style={{ flexDirection: "row" }}>
|
|
416
|
+
<Button theme={theme} compact={compact} kind="secondary" title="Send now" accessibilityLabel={`Send ${n} task${n === 1 ? "" : "s"} to ${s.title} now`} loading={busy} disabled={busy} onPress={() => void press()} />
|
|
417
|
+
</View>;
|
|
418
|
+
}
|
|
419
|
+
|
|
371
420
|
function DetailPane({ s, model, theme, compact, deps, openFull, signOffNext, ask, onBack }: {
|
|
372
421
|
s: Workstream; model: HomeModel; theme: Theme; compact: boolean; deps: HomeDeps;
|
|
373
422
|
openFull: (s: Workstream) => void; signOffNext: (s: Workstream) => void; onBack?: () => void;
|
|
@@ -450,7 +499,7 @@ function DetailPane({ s, model, theme, compact, deps, openFull, signOffNext, ask
|
|
|
450
499
|
{onBack && <IconButton theme={theme} compact icon="ChevronLeft" label="Back to Home" onPress={onBack} />}
|
|
451
500
|
<Icon name={s.icon} size={16} color={color} />
|
|
452
501
|
<Text accessibilityRole="header" numberOfLines={2} style={[t.title, { flex: 1, fontSize: 16 }]}>{s.title}{s.agent ? <Text style={{ color: c.foregroundMuted, fontWeight: "400" }}>{` › ${s.agent}`}</Text> : null}</Text>
|
|
453
|
-
<Button theme={theme} compact={compact} icon="PanelRightOpen" title="Open full" accessibilityHint="Opens the agent's chat and docks this list beside it" onPress={() => openFull(s)} />
|
|
502
|
+
<Button theme={theme} compact={compact} icon="PanelRightOpen" title="Open full" keyHint="↵" accessibilityHint="Opens the agent's chat and docks this list beside it (Enter)" onPress={() => openFull(s)} />
|
|
454
503
|
</View>
|
|
455
504
|
{s.workspaceId && w && <SummaryLine key={s.workspaceId} workspace={w} theme={theme} compact={false} />}
|
|
456
505
|
{s.workspaceId && w && <ReferencesLine key={`refs:${s.workspaceId}`} workspace={w} theme={theme} compact={false} />}
|
|
@@ -556,6 +605,7 @@ function DetailPane({ s, model, theme, compact, deps, openFull, signOffNext, ask
|
|
|
556
605
|
: echoed || (b && compact && b.source === "none" && asks.length) ? null
|
|
557
606
|
: row?.needs && !agent.permissions.length && !b ? <Text style={compact ? t.ask : [t.body, { fontSize: 15, lineHeight: 21, fontWeight: "600" }]}>{s.line || s.word || "Needs you"}</Text>
|
|
558
607
|
: !row?.needs && s.line ? <Text style={t.body}>{s.line}</Text> : null}
|
|
608
|
+
{!row?.needs && s.sendNow && <DetailSendNow s={s} theme={theme} compact={compact} deps={deps} />}
|
|
559
609
|
{w && <NeedsYouBlock workspace={w} theme={theme} compact={compact} now={Date.now()} style={{ marginHorizontal: 0, marginTop: 0 }}
|
|
560
610
|
brief={inBlock ? b : null} briefCard={inBlock && <BriefCard {...({ embedded: true, bare: true, item: { data: b }, theme, layout: { compact }, agentId: s.agentId, deps: deps.briefDeps } as unknown as Parameters<typeof BriefCard>[0])} />}
|
|
561
611
|
actions={{ openPr: (key, intent) => setSheet({ key, intent }), openQuestion: setQuestion, openAgent: () => openFull(s) }} />}
|
package/client/kit.tsx
CHANGED
|
@@ -110,11 +110,12 @@ export function SubmitScope({ enabled, onSubmit, children, style, accessibilityR
|
|
|
110
110
|
|
|
111
111
|
export type ButtonKind = "primary" | "secondary" | "ghost" | "danger";
|
|
112
112
|
/** One button vocabulary for the whole plugin: 32px on desktop with a hit slop, 44px on touch layouts. */
|
|
113
|
-
export function Button({ title, onPress, theme, kind = "secondary", disabled = false, loading = false, icon, compact = false, accessibilityLabel, accessibilityHint, grow = false, shortcut = false, nativeID, onInteract }: {
|
|
113
|
+
export function Button({ title, onPress, theme, kind = "secondary", disabled = false, loading = false, icon, compact = false, accessibilityLabel, accessibilityHint, grow = false, shortcut = false, keyHint, nativeID, onInteract }: {
|
|
114
114
|
/** Focus and hover, for a surface that pauses while the button is in use (the Undo bar). */ onInteract?: (event: "focus" | "blur" | "hoverIn" | "hoverOut") => void;
|
|
115
115
|
/** A DOM id on web, so focusSoon can move focus here after the control that had it goes away. */ nativeID?: string;
|
|
116
116
|
title: string; onPress: () => void; theme: Theme; kind?: ButtonKind; disabled?: boolean; loading?: boolean; icon?: string; compact?: boolean; accessibilityLabel?: string; accessibilityHint?: string; grow?: boolean;
|
|
117
117
|
/** The SubmitScope's action: shows a quiet ⌘↵ on desktop web. */ shortcut?: boolean;
|
|
118
|
+
/** A key that does what this button does from elsewhere on the screen (Home's ↵ for Open full): the same quiet hint. */ keyHint?: string;
|
|
118
119
|
}) {
|
|
119
120
|
const c = theme.colors;
|
|
120
121
|
const fg = kind === "primary" ? c.accentForeground : kind === "danger" ? c.statusDanger : c.foreground;
|
|
@@ -130,7 +131,7 @@ export function Button({ title, onPress, theme, kind = "secondary", disabled = f
|
|
|
130
131
|
})}>
|
|
131
132
|
{loading ? <Spinner color={fg} size={12} /> : icon ? <Icon name={icon} size={compact ? 16 : 14} color={fg} /> : null}
|
|
132
133
|
<Text numberOfLines={1} style={{ color: fg, fontSize: compact ? 14 : 12, lineHeight: compact ? 19 : 16, fontWeight: "600" }}>{title}</Text>
|
|
133
|
-
{shortcut && !compact && Platform.OS === "web" && <Text accessibilityElementsHidden importantForAccessibility="no" style={{ color: fg, opacity: 0.6, fontSize: 11, lineHeight: 16, fontWeight: "500", marginLeft: 2 }}>{submitHint()}</Text>}
|
|
134
|
+
{(shortcut || keyHint) && !compact && Platform.OS === "web" && <Text accessibilityElementsHidden importantForAccessibility="no" style={{ color: fg, opacity: 0.6, fontSize: 11, lineHeight: 16, fontWeight: "500", marginLeft: 2 }}>{shortcut ? submitHint() : keyHint}</Text>}
|
|
134
135
|
</PressScale>;
|
|
135
136
|
}
|
|
136
137
|
|
package/client/list-keys.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
2
|
import { Platform } from "react-native";
|
|
3
|
-
import { listMove, ownsKey, surfaceVisible, walkTarget } from "../shared/list-keys";
|
|
3
|
+
import { enterTarget, listMove, ownsKey, surfaceVisible, walkTarget } from "../shared/list-keys";
|
|
4
4
|
import { rowDomId } from "./kit";
|
|
5
5
|
|
|
6
6
|
type Row = { focus(o?: { preventScroll?: boolean }): void; scrollIntoView?(o?: { block?: string }): void };
|
|
@@ -29,6 +29,8 @@ export type ListKeysOptions = {
|
|
|
29
29
|
claimBody?: boolean;
|
|
30
30
|
onSelect: (key: string) => void;
|
|
31
31
|
onOpen: (key: string) => void;
|
|
32
|
+
/** S: show this surface's keys (Home's keys sheet). Without it S stays unclaimed. */
|
|
33
|
+
onKeys?: () => void;
|
|
32
34
|
/** A row the virtualized list hasn't drawn yet: scroll it in, so it can take focus. */
|
|
33
35
|
reveal: (key: string) => void;
|
|
34
36
|
};
|
|
@@ -45,7 +47,7 @@ export function useListKeys(options: ListKeysOptions): void {
|
|
|
45
47
|
const doc = (globalThis as { document?: Doc }).document;
|
|
46
48
|
if (!options.enabled || Platform.OS !== "web" || !doc) return;
|
|
47
49
|
const onKey = (e: DomKey) => {
|
|
48
|
-
const { order, mode, selectedKey, scope, claimBody, onSelect, onOpen, reveal } = ref.current;
|
|
50
|
+
const { order, mode, selectedKey, scope, claimBody, onSelect, onOpen, onKeys, reveal } = ref.current;
|
|
49
51
|
const target = e.target as Target;
|
|
50
52
|
const typing = !!target && (!!target.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(target.tagName ?? ""));
|
|
51
53
|
if (typing && !target?.closest?.("[data-list-keys]")) return;
|
|
@@ -59,13 +61,20 @@ export function useListKeys(options: ListKeysOptions): void {
|
|
|
59
61
|
const move = listMove(e, typing);
|
|
60
62
|
if (!move) return;
|
|
61
63
|
const focused = !typing && target?.id ? order.find(k => rowDomId(k) === target.id) ?? null : null;
|
|
64
|
+
if (move === "keys") {
|
|
65
|
+
if (!onKeys || typing) return;
|
|
66
|
+
e.preventDefault(); e.stopPropagation(); onKeys();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
62
69
|
if (move === "open") {
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
// A focused row opens itself; on Home, with nothing focused, the selection does (a click, a search or ⌘K pick,
|
|
71
|
+
// coming back). Enter on a header, a chip or a button keeps doing what that control does.
|
|
72
|
+
const open = enterTarget({ focused, selectedKey, mode, onBody });
|
|
73
|
+
if (!open) return;
|
|
74
|
+
e.preventDefault(); e.stopPropagation(); onOpen(open);
|
|
66
75
|
// The sidebar view: if opening the chat left focus nowhere, give it back to the row, so ↓ ↓ Enter keeps
|
|
67
76
|
// walking. If Paseo put it somewhere (the composer), it stays there: never taken back.
|
|
68
|
-
if (mode === "focus") keepWalking(doc, scope() ?? doc,
|
|
77
|
+
if (mode === "focus") keepWalking(doc, scope() ?? doc, open, reveal);
|
|
69
78
|
return;
|
|
70
79
|
}
|
|
71
80
|
const to = walkTarget({ order, focused, selectedKey, mode, typing, move });
|
package/client/tasks.tsx
CHANGED
|
@@ -169,14 +169,16 @@ function StripRow({ strip, w, theme, compact, onPreview, openAgent }: { strip: M
|
|
|
169
169
|
try {
|
|
170
170
|
const result = await send({ workspaceId: w.id, batchId: strip.batchId });
|
|
171
171
|
const b = result.batches.find(x => x.id === strip.batchId);
|
|
172
|
-
toast.show(!b || ["sent", "sending", "completed"].includes(b.state) ? `Sent to ${strip.to}` : b.state === "pending" ? "Queued. It goes out when the agent is free." : b.result || "The message couldn't be sent.", { variant: !b || ["sent", "sending", "completed"].includes(b.state) ? "success" : "info" });
|
|
172
|
+
toast.show(!b || ["sent", "sending", "completed"].includes(b.state) ? `Sent to ${strip.to}` : b.state === "pending" ? "Queued. It goes out when the main agent is free." : b.result || "The message couldn't be sent.", { variant: !b || ["sent", "sending", "completed"].includes(b.state) ? "success" : "info" });
|
|
173
173
|
} catch (error) { toast.error(error instanceof Error ? error.message : "The message couldn't be sent."); }
|
|
174
174
|
finally { setBusy(false); void cache.invalidateQueries(); }
|
|
175
175
|
};
|
|
176
|
-
|
|
176
|
+
// The why is the point of the row (a-repair-goes-to-a-free-main-agent): it keeps a readable width, and the buttons
|
|
177
|
+
// wrap under it in a narrow panel instead of squeezing it into a column.
|
|
178
|
+
return <View accessibilityRole="summary" style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 8, rowGap: 8, paddingHorizontal: compact ? 14 : 12, paddingVertical: compact ? 12 : 8, borderTopWidth: 1, borderTopColor: c.border, backgroundColor: c.surface1 }}>
|
|
177
179
|
<Icon name="Send" size={13} color={c.foregroundMuted} />
|
|
178
|
-
<Text style={[t.meta, {
|
|
179
|
-
<View style={{ flexDirection: "row", gap: 8, marginLeft:
|
|
180
|
+
<Text style={[t.meta, { flexGrow: 1, flexShrink: 1, flexBasis: compact ? "80%" : 240, minWidth: 0 }]}><Text style={{ color: c.foreground, fontWeight: "500" }}>{line.lead}</Text>{line.rest}</Text>
|
|
181
|
+
<View style={{ flexDirection: "row", gap: 8, marginLeft: "auto" }}>
|
|
180
182
|
{strip.phase === "queued" && <Button theme={theme} compact={compact} title="Preview" accessibilityLabel={`Preview the next message to ${strip.to}`} onPress={onPreview} />}
|
|
181
183
|
{strip.phase === "queued" && strip.sendNow && <Button theme={theme} compact={compact} title="Send now" accessibilityLabel={`Send ${tasks(strip.count)} to ${strip.to} now`} loading={busy} disabled={busy} onPress={() => void sendNow()} />}
|
|
182
184
|
{strip.phase === "sent" && openAgent && <Button theme={theme} compact={compact} title="Open agent" accessibilityLabel={`Open ${strip.to}`} onPress={() => openAgent(strip.recipientId)} />}
|
package/index.server.ts
CHANGED
|
@@ -196,6 +196,8 @@ export default function contribute(server: PluginServerContext) {
|
|
|
196
196
|
// Settings → Agents: which agent each special role uses, in agents.json (defaults when absent).
|
|
197
197
|
const agentSettings = new AgentSettingsStore(directory);
|
|
198
198
|
gateway.recoveryRole = () => agentSettings.role("recovery");
|
|
199
|
+
// The main agent's own background job holds its repairs only while Wait for background jobs is on (Q96 = A).
|
|
200
|
+
gateway.waitForJobs = () => agentSettings.waitEnabled();
|
|
199
201
|
const graphite = new Graphite();
|
|
200
202
|
const github = new Github(undefined, graphite, new Deployments(undefined, undefined, undefined, undefined, repo => prWorkflow.current().repos[repoKey(repo)]?.deploy));
|
|
201
203
|
github.workflow = repo => prWorkflow.workflow(repo);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paseo-follow-up",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.0-beta.0",
|
|
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": [
|
package/server/daemon.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { readSharedJson } from "./shared-file";
|
|
|
9
9
|
import { createRequire } from "node:module";
|
|
10
10
|
import type { Workspace, Batch } from "../shared/model";
|
|
11
11
|
import type { Gateway, Runtime } from "./engine";
|
|
12
|
+
import { MAIN_WAIT, QUIET_WAIT, repairWait } from "../shared/send-decision";
|
|
12
13
|
import type { State } from "../shared/model";
|
|
13
14
|
import { defaultTracking, followsEvery, optedOut, projectSetting, type Project } from "../shared/settings";
|
|
14
15
|
import { recoveryHandoff } from "./recovery-handoff";
|
|
@@ -480,6 +481,9 @@ export class PaseoGateway implements Gateway {
|
|
|
480
481
|
*/
|
|
481
482
|
/** A new engine tick: sends re-list agents at most once in it (a-send-lists-agents-at-most-once-per-tick). */
|
|
482
483
|
tickStarted(): void { this.directory.tickStarted(); }
|
|
484
|
+
/** Settings → Agents → Wait for background jobs (index.server.ts sets it). Unset or unreadable: on (Unknown is not off). */
|
|
485
|
+
waitForJobs?: () => Promise<boolean>;
|
|
486
|
+
private async waitsForJobs(): Promise<boolean> { try { return (await this.waitForJobs?.()) ?? true; } catch { return true; } }
|
|
483
487
|
async observe(w: Workspace, fresh = false): Promise<Runtime> {
|
|
484
488
|
const [rows, compacting, pauses] = await Promise.all([this.directory.read(fresh ? { fresh: "agents" } : {}), this.compacting(w.mainAgentId), this.guard.read()]);
|
|
485
489
|
const { agents, workspaces } = rows;
|
|
@@ -500,29 +504,37 @@ export class PaseoGateway implements Gateway {
|
|
|
500
504
|
const guarded = this.guard.waiting(pauses, { agentIds: [w.mainAgentId, ...scoped.map(agent => agent.id)], workspaceId: w.id, excludedAgentIds: [...recoveryIds].filter((id): id is string => !!id) });
|
|
501
505
|
const guardedInterruptionId = this.guard.ownsInterruption(pauses, w.mainAgentId, w.interruption)?.id;
|
|
502
506
|
const context = { guardedInterruptionId, mainTurnId: turnIdOf(a.activeTurn), mainTitle: a.title?.trim() || null };
|
|
503
|
-
if (guarded || !pauses && workspace.labels?.some(label => /^(Paused|Paused by Session Guard)$/i.test(label))) return { taskAgents, ...context, guarded: true, busy: false, reason: "Waiting for Session Guard to resume this workspace", archived: false };
|
|
504
|
-
if (compacting) return { taskAgents, busy: true, reason: "Smart Session is compacting the main agent", archived: false };
|
|
507
|
+
if (guarded || !pauses && workspace.labels?.some(label => /^(Paused|Paused by Session Guard)$/i.test(label))) return { taskAgents, ...context, guarded: true, busy: false, mainBusy: "guard", reason: "Waiting for Session Guard to resume this workspace", archived: false };
|
|
508
|
+
if (compacting) return { taskAgents, busy: true, mainBusy: "compacting", reason: "Smart Session is compacting the main agent", archived: false };
|
|
505
509
|
const mainLoaded = isLoaded(a), mainRecent = recentlyUsed(a, this.windowMs, this.now());
|
|
506
510
|
if (conversationGone(a.lastError)) return { taskAgents, busy: false, reason: a.lastError ?? "Conversation not found", archived: false, gone: a.lastError ?? "Conversation not found", mainLoaded, mainRecent };
|
|
507
|
-
if (a.pendingPermissions.length || a.status === "error") return { taskAgents, busy: false, reason: a.status === "error" ? "Main agent needs recovery" : "Main agent is waiting for a permission or answer", archived: false };
|
|
508
|
-
|
|
511
|
+
if (a.pendingPermissions.length || a.status === "error") return { taskAgents, busy: false, ...(a.status === "error" ? {} : { mainBusy: "permission" as const }), reason: a.status === "error" ? "Main agent needs recovery" : "Main agent is waiting for a permission or answer", archived: false };
|
|
512
|
+
// One busy computation, two scopes (Q96 = A, a-repair-goes-to-a-free-main-agent). `busy` and `backgroundBusy` are the
|
|
513
|
+
// whole workspace: Done, a sent message's turn, "all work finished". `mainBusy` is the main agent's own work, and only
|
|
514
|
+
// it holds a repair: its turn, and its own background job while Wait for background jobs is on. Another agent in the
|
|
515
|
+
// workspace (a subagent the main agent started) and provider subagents never hold a repair. 2026-11-18: a repair sat
|
|
516
|
+
// pending over two hours while the main agent was idle and a subagent it started ran one task after another.
|
|
517
|
+
let busy = false; let backgroundBusy = false; let mainBusy: "turn" | "jobs" | null = null;
|
|
509
518
|
const members = here.filter(agent => !recoveryIds.has(agent.id) && !isRecovery(agent.labels));
|
|
510
519
|
for (const agent of members) {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
520
|
+
const main = agent.id === w.mainAgentId;
|
|
521
|
+
if (["running", "initializing"].includes(agent.status)) { busy = true; if (main) mainBusy = "turn"; else backgroundBusy = true; }
|
|
522
|
+
// 0.16: work an agent started and ended its turn on (a shell, a task) is still work: no Done yet, and the main
|
|
523
|
+
// agent's own job holds its repairs while Wait for background jobs is on.
|
|
524
|
+
else if (backgroundCount(agent) > 0) { backgroundBusy = true; if (main && await this.waitsForJobs()) mainBusy = "jobs"; }
|
|
514
525
|
}
|
|
515
|
-
// Subagents only decide
|
|
516
|
-
//
|
|
517
|
-
const
|
|
518
|
-
|
|
526
|
+
// Subagents only decide the whole workspace's quiet: Done, a sent message's turn, and the Done check's send (a fresh
|
|
527
|
+
// read). Repairs never wait for them (Q96 = A), so a queued repair, or its send, never lists subagents (2026-11-12).
|
|
528
|
+
const doneCheckGoing = (b: Workspace["batches"][number]) => fresh && ["pending", "sending"].includes(b.state) && b.tasks.some(t => t.kind === "completion");
|
|
529
|
+
// A Done declaration is waiting to be accepted: Done needs the whole workspace quiet, subagents included.
|
|
530
|
+
const subagentsMatter = !!w.completion || !!w.declaration || w.batches.some(b => !b.tasks.every(t => t.kind === "inventory") && (b.state === "sent" || doneCheckGoing(b)));
|
|
519
531
|
const idleLoaded = members.filter(agent => isLoaded(agent) && !["running", "initializing"].includes(agent.status));
|
|
520
532
|
if (subagentsMatter && !backgroundBusy && idleLoaded.length) await this.connect(async client => {
|
|
521
533
|
for (const listed of idleLoaded) {
|
|
522
534
|
if (await subagentsRunning(client, listed, "Subagent observation unavailable", this.directory)) { busy = true; backgroundBusy = true; break; }
|
|
523
535
|
}
|
|
524
536
|
});
|
|
525
|
-
return { taskAgents, ...context, busy, reason: null, archived: false, backgroundBusy, mainLoaded, mainRecent };
|
|
537
|
+
return { taskAgents, ...context, busy, reason: null, archived: false, backgroundBusy, mainBusy, mainLoaded, mainRecent };
|
|
526
538
|
}
|
|
527
539
|
async recoveryRuntime(w: Workspace, batch: Batch): Promise<{ busy: boolean; reason: string | null }> {
|
|
528
540
|
return this.connect(async client => {
|
|
@@ -551,7 +563,10 @@ export class PaseoGateway implements Gateway {
|
|
|
551
563
|
// The dispatch observed fresh this tick; this re-check reads the same tick's list (a-send-lists-agents-at-most-once-per-tick).
|
|
552
564
|
try { runtime = await this.observe(w, true); }
|
|
553
565
|
catch { throw new DeliveryDeferred("Agent or Session Guard state is unavailable; follow-up will wait and retry."); }
|
|
554
|
-
|
|
566
|
+
// A repair waits only for the main agent itself (Q96 = A); the Done check for the whole workspace to be quiet.
|
|
567
|
+
const main = repairWait(runtime);
|
|
568
|
+
const holds = batch.tasks.some(t => t.kind === "completion") ? (runtime.busy || runtime.backgroundBusy ? QUIET_WAIT : null) : main && MAIN_WAIT[main];
|
|
569
|
+
if (holds || runtime.reason || runtime.archived) throw new DeliveryDeferred(holds || runtime.reason || "The workspace was archived.");
|
|
555
570
|
}
|
|
556
571
|
await this.connect(async client => {
|
|
557
572
|
const recipient = batch.recipientAgentId ?? w.mainAgentId;
|
package/server/engine.ts
CHANGED
|
@@ -19,12 +19,18 @@ import { PASEO_UNREACHABLE, deliveryOf, type NewQueueItem, type QueueItem, type
|
|
|
19
19
|
import { recordSnapshot } from "./deployment-anchor";
|
|
20
20
|
import { pruneUnsent } from "./batch-archive";
|
|
21
21
|
import { holdSuperseded, liftHold } from "../shared/status";
|
|
22
|
-
import { conditionId, isCapped, mootReason, personHeld, readSince, sendDecision, settleUnacknowledged, stillApplies, stuckRepair, UNACKNOWLEDGED_MS } from "../shared/send-decision";
|
|
22
|
+
import { conditionId, isCapped, MAIN_WAIT, mootReason, personHeld, QUIET_WAIT, readSince, repairWait, sendDecision, settleUnacknowledged, stillApplies, stuckRepair, UNACKNOWLEDGED_MS, type MainWait } from "../shared/send-decision";
|
|
23
23
|
import { isRepair } from "../shared/task-rows";
|
|
24
|
-
export { settleUnacknowledged, UNACKNOWLEDGED_MS, NO_PROGRESS_CAP } from "../shared/send-decision";
|
|
24
|
+
export { settleUnacknowledged, UNACKNOWLEDGED_MS, NO_PROGRESS_CAP, repairWait, QUIET_WAIT } from "../shared/send-decision";
|
|
25
25
|
|
|
26
26
|
export interface Runtime {
|
|
27
27
|
busy: boolean; reason: string | null; archived: boolean; backgroundBusy?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* What the main agent itself is doing that holds a repair (Workspace.mainBusy, Q96 = A). `busy` and `backgroundBusy`
|
|
30
|
+
* are the whole workspace (Done, "all work finished"); only this decides a repair. Undefined: unknown, so a repair
|
|
31
|
+
* treats the workspace's busy as the main agent's (repairWait).
|
|
32
|
+
*/
|
|
33
|
+
mainBusy?: MainWait | null;
|
|
28
34
|
/** Live state of the agents working tasks name (Workspace.taskAgents). Undefined: unknown, so every line naming an agent says "Agent unavailable". */
|
|
29
35
|
taskAgents?: Workspace["taskAgents"];
|
|
30
36
|
guarded?: boolean; guardedInterruptionId?: string;
|
|
@@ -259,6 +265,7 @@ export class Engine {
|
|
|
259
265
|
if (!untouched) await this.store.mutateWorkspace(original.id, w => {
|
|
260
266
|
w.runtimeBusy = runtime.busy; w.runtimeReason = runtime.reason; w.taskAgents = runtime.taskAgents;
|
|
261
267
|
w.backgroundBusy = runtime.backgroundBusy ?? false;
|
|
268
|
+
w.mainBusy = repairWait(runtime);
|
|
262
269
|
if (runtime.mainTitle !== undefined && (w.mainAgentTitle ?? null) !== runtime.mainTitle) w.mainAgentTitle = runtime.mainTitle;
|
|
263
270
|
if (runtime.gone && w.goneAgent?.agentId !== w.mainAgentId) w.goneAgent = { agentId: w.mainAgentId, at: new Date(this.now()).toISOString(), reason: runtime.gone };
|
|
264
271
|
if (w.goneAgent?.agentId === w.mainAgentId) w.runtimeReason = GONE_REASON;
|
|
@@ -343,8 +350,8 @@ export class Engine {
|
|
|
343
350
|
const heldItem = held && this.queue?.get(repairItemId(current.id, held.id));
|
|
344
351
|
// An Auto send keeps its own pace (a refusal retries once per settle window: the-send-line-matches-the-send-decision);
|
|
345
352
|
// only the developer's Send, or any repair waiting out a turn, goes on this tick.
|
|
346
|
-
const due = heldItem?.state === "queued" && !!heldItem.reason && (heldItem.reason
|
|
347
|
-
if (due && !runtime
|
|
353
|
+
const due = heldItem?.state === "queued" && !!heldItem.reason && (MAIN_WAITS.has(heldItem.reason) || !heldItem.ref.automatic && heldAgentSide(heldItem.reason));
|
|
354
|
+
if (due && !repairWait(runtime) && !runtime.reason) await this.queue!.retry(heldItem!.id).catch(() => undefined);
|
|
348
355
|
current = findWorkspace(await this.store.snapshot(), original.id);
|
|
349
356
|
const done = !current.archived && !!current.completion && completionBlockers(current, this.now()).length === 0;
|
|
350
357
|
if (done || current.managedDoneLabel) {
|
|
@@ -527,7 +534,10 @@ export class Engine {
|
|
|
527
534
|
try { runtime = await this.gateway.observe(w, true); }
|
|
528
535
|
catch { return { defer: "Paseo unreachable" }; }
|
|
529
536
|
if (runtime.archived) return { cancel: "The workspace was archived." };
|
|
530
|
-
|
|
537
|
+
// A repair waits only for the main agent itself (Q96 = A); the Done check waits for the whole workspace to be quiet.
|
|
538
|
+
if (completionCheck(b) && (runtime.busy || runtime.backgroundBusy)) return { defer: QUIET_WAIT };
|
|
539
|
+
const holds = repairWait(runtime);
|
|
540
|
+
if (holds) return { defer: MAIN_WAIT[holds] };
|
|
531
541
|
if (runtime.reason) return { defer: runtime.reason };
|
|
532
542
|
// The runtime read awaited Paseo: what the developer changed meanwhile (Auto off, a hold) still wins.
|
|
533
543
|
const fresh = (await this.store.snapshot()).workspaces.find(x => x.id === w.id);
|
|
@@ -594,7 +604,7 @@ export class Engine {
|
|
|
594
604
|
if (!b || this.queue?.get(repairItemId(w.id, b.id))) return [];
|
|
595
605
|
if (!sendDecision({ ...w, sendWait: null }, this.now(), { settleMs: 0, batch: b }).send || this.autoSendsHeld()) return [];
|
|
596
606
|
const runtime = await this.gateway.observe(w, true).catch(() => null);
|
|
597
|
-
if (!runtime || runtime
|
|
607
|
+
if (!runtime || repairWait(runtime) || runtime.reason || runtime.archived) return [];
|
|
598
608
|
return [this.repairItem(w, b, true)];
|
|
599
609
|
}
|
|
600
610
|
/**
|
|
@@ -697,6 +707,7 @@ export class Engine {
|
|
|
697
707
|
const w = ownedWorkspace(state, agentId, workspaceId);
|
|
698
708
|
w.runtimeBusy = runtime.busy; w.runtimeReason = runtime.reason; w.taskAgents = runtime.taskAgents;
|
|
699
709
|
w.backgroundBusy = runtime.backgroundBusy ?? false;
|
|
710
|
+
w.mainBusy = repairWait(runtime);
|
|
700
711
|
if (runtime.archived) w.archived = true;
|
|
701
712
|
for (const pr of w.prs) {
|
|
702
713
|
const observation = observations.get(pr.key);
|
|
@@ -840,5 +851,7 @@ export function agentWorkspace(state: State, agentId: string, access: "read" | "
|
|
|
840
851
|
export const answerItemId = (workspaceId: string, q: Pick<Question, "id" | "answer">) => `answer:${workspaceId}:${q.id}:${q.answer?.delivery.messageId ?? ""}`;
|
|
841
852
|
/** A batch's queue item: one per batch (a Retry makes a new batch, so a new item). */
|
|
842
853
|
/** A repair's hold that only the agent's runtime can clear, so a tick that sees the agent free retries it. */
|
|
854
|
+
/** The main agent's own waits: a repair held by one goes on the tick that sees the main agent free. */
|
|
855
|
+
const MAIN_WAITS = new Set<string>(Object.values(MAIN_WAIT));
|
|
843
856
|
export const heldAgentSide = (reason: string) => reason !== PASEO_UNREACHABLE && !reason.startsWith("waits for the last message") && !reason.startsWith("waits until GitHub answers");
|
|
844
857
|
export const repairItemId = (workspaceId: string, batchId: string) => `repair:${workspaceId}:${batchId}`;
|
package/server/mcp-source.ts
CHANGED
|
@@ -258,7 +258,7 @@ export const mcpSource: string = [
|
|
|
258
258
|
" if (type === \"string\" && (schema.minLength !== undefined && value.length < schema.minLength || schema.maxLength !== undefined && value.length > schema.maxLength)) throw new Error(`${path}: outside the allowed length.`);",
|
|
259
259
|
"}",
|
|
260
260
|
"function currentWork(w) {",
|
|
261
|
-
" return { id: w.id, title: w.title, goal: w.goal, mainAgentId: w.mainAgentId, enable_tracking: w.enable_tracking, enable_auto_sends: w.enable_auto_sends, hold: w.hold, archived: w.archived, runtimeBusy: w.runtimeBusy, runtimeReason: w.runtimeReason, backgroundBusy: w.backgroundBusy, completion: w.completion,",
|
|
261
|
+
" return { id: w.id, title: w.title, goal: w.goal, mainAgentId: w.mainAgentId, enable_tracking: w.enable_tracking, enable_auto_sends: w.enable_auto_sends, hold: w.hold, archived: w.archived, runtimeBusy: w.runtimeBusy, runtimeReason: w.runtimeReason, backgroundBusy: w.backgroundBusy, mainBusy: w.mainBusy ?? null, completion: w.completion,",
|
|
262
262
|
" prs: w.prs.map(p => ({ key: p.key, stack: p.stack, parent: p.parent, disposition: p.disposition, error: p.error, ...(p.snapshot ? { title: p.snapshot.title, state: p.snapshot.state, head: p.snapshot.head, draft: p.snapshot.draft, reviewDecision: p.snapshot.reviewDecision, conflict: p.snapshot.conflict, openThreads: p.snapshot.threads.length, failedChecks: p.snapshot.failedChecks, otherFailedChecks: p.snapshot.otherFailedChecks ?? [], deployment: p.snapshot.deployment } : {}) })),",
|
|
263
263
|
" obligations: w.obligations.filter(o => ![\"done\", \"waived\"].includes(o.status)), completedObligations: w.obligations.filter(o => [\"done\", \"waived\"].includes(o.status)).length,",
|
|
264
264
|
" openQuestions: (w.questions ?? []).filter(q => !q.answer && !q.closed).map(q => ({ id: q.id, title: q.title, question: q.question, options: q.options, recommend: q.recommend, big: q.big, mode: q.mode, askedBy: q.askedBy, taskId: q.taskId })),",
|
package/server/mcp.mjs
CHANGED
|
@@ -256,7 +256,7 @@ function validate(value, schema, path = "arguments") {
|
|
|
256
256
|
if (type === "string" && (schema.minLength !== undefined && value.length < schema.minLength || schema.maxLength !== undefined && value.length > schema.maxLength)) throw new Error(`${path}: outside the allowed length.`);
|
|
257
257
|
}
|
|
258
258
|
function currentWork(w) {
|
|
259
|
-
return { id: w.id, title: w.title, goal: w.goal, mainAgentId: w.mainAgentId, enable_tracking: w.enable_tracking, enable_auto_sends: w.enable_auto_sends, hold: w.hold, archived: w.archived, runtimeBusy: w.runtimeBusy, runtimeReason: w.runtimeReason, backgroundBusy: w.backgroundBusy, completion: w.completion,
|
|
259
|
+
return { id: w.id, title: w.title, goal: w.goal, mainAgentId: w.mainAgentId, enable_tracking: w.enable_tracking, enable_auto_sends: w.enable_auto_sends, hold: w.hold, archived: w.archived, runtimeBusy: w.runtimeBusy, runtimeReason: w.runtimeReason, backgroundBusy: w.backgroundBusy, mainBusy: w.mainBusy ?? null, completion: w.completion,
|
|
260
260
|
prs: w.prs.map(p => ({ key: p.key, stack: p.stack, parent: p.parent, disposition: p.disposition, error: p.error, ...(p.snapshot ? { title: p.snapshot.title, state: p.snapshot.state, head: p.snapshot.head, draft: p.snapshot.draft, reviewDecision: p.snapshot.reviewDecision, conflict: p.snapshot.conflict, openThreads: p.snapshot.threads.length, failedChecks: p.snapshot.failedChecks, otherFailedChecks: p.snapshot.otherFailedChecks ?? [], deployment: p.snapshot.deployment } : {}) })),
|
|
261
261
|
obligations: w.obligations.filter(o => !["done", "waived"].includes(o.status)), completedObligations: w.obligations.filter(o => ["done", "waived"].includes(o.status)).length,
|
|
262
262
|
openQuestions: (w.questions ?? []).filter(q => !q.answer && !q.closed).map(q => ({ id: q.id, title: q.title, question: q.question, options: q.options, recommend: q.recommend, big: q.big, mode: q.mode, askedBy: q.askedBy, taskId: q.taskId })),
|
package/shared/attention.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { deliveryStatus } from "./queue";
|
|
|
3
3
|
import { sentence } from "./errors";
|
|
4
4
|
import { blockedOnDeveloper, completionCheck, liveWorkingTask, statusKnown, summary, type Task, type Status } from "./model";
|
|
5
5
|
import type { ListBatch as Batch, ListPr as Pr, ListWorkspace as Workspace } from "./list";
|
|
6
|
-
import { IDLE_REASON, NO_PROGRESS_CAP } from "./send-decision";
|
|
6
|
+
import { IDLE_REASON, MAIN_WAIT, NO_PROGRESS_CAP, QUIET_WAIT, mainWait } from "./send-decision";
|
|
7
7
|
import { workingLine } from "./task-status";
|
|
8
8
|
import { followUpObligations, recoveryBatch } from "./follow-up";
|
|
9
9
|
import { orderedStacks, prLink, settledForDisplay, type PrLink } from "./presentation";
|
|
@@ -96,7 +96,11 @@ export const workflowReady = (pr: Pr) => isGithubFlow(pr.snapshot) ? mergeBlocke
|
|
|
96
96
|
/** Why a pending batch cannot be sent right now, or null when Send is available. Mirrors the server's guards. */
|
|
97
97
|
export function sendBlocker(w: Workspace, batch: Batch): string | null {
|
|
98
98
|
if (w.hold) return "Resume follow-up first";
|
|
99
|
-
|
|
99
|
+
// The Done check waits for the whole workspace; a repair only for the main agent's own wait (Q96 = A), said in the
|
|
100
|
+
// send decision's words.
|
|
101
|
+
if (completionCheck(batch) && (w.runtimeBusy || w.backgroundBusy)) return capitalize(QUIET_WAIT);
|
|
102
|
+
const main = mainWait(w);
|
|
103
|
+
if (main) return capitalize(MAIN_WAIT[main]);
|
|
100
104
|
if (w.runtimeReason) return w.runtimeReason;
|
|
101
105
|
if (w.batches.some(other => other.id !== batch.id && ["sending", "sent", "blocked", "uncertain"].includes(other.state))) return "Another batch is still open";
|
|
102
106
|
return null;
|
|
@@ -347,7 +351,8 @@ export function liveLine(w: Workspace, now = Date.now()): { icon: LiveIcon; text
|
|
|
347
351
|
if (w.runtimeReason) return { icon: "waiting", text: w.runtimeReason, since: null };
|
|
348
352
|
// Queued work, in the same words as the agent card and Home (shared/status.ts). Repairs you send by hand live in Needs you.
|
|
349
353
|
if (view?.phase === "queued" && (view.kind === "finish" || w.enable_auto_sends)) return { icon: "waiting", text: view.line, since: view.batch.createdAt };
|
|
350
|
-
|
|
354
|
+
// Say who: the main agent only when it is its own turn (Q96 = A), never for a subagent at work beside an idle main.
|
|
355
|
+
if (w.runtimeBusy) return { icon: "spinner", text: mainWait(w) === "turn" ? "Main agent is working" : "Agents in this workspace are working", since: null };
|
|
351
356
|
// A working task spins only while its recorded agent is running (invariant `a-task-only-says-working-when-its-agent-is`).
|
|
352
357
|
// Otherwise it says what the task row says: "<agent> idle", "<agent> closed", "Agent unavailable" or "In progress", with no spinner.
|
|
353
358
|
const live = liveWorkingTask(w);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Home's keys (desktop and web), the one list the keys sheet draws (client/home.tsx `HomeKeysSheet`). The handlers are
|
|
3
|
+
* the list walk (`listMove`, shared/list-keys.ts), the search field and Search from anywhere; a letter Catch up also
|
|
4
|
+
* uses does the same thing here (O opens the chat, S shows the keys).
|
|
5
|
+
*/
|
|
6
|
+
export const HOME_KEYS: readonly { key: string; what: string; when?: "search" | "pane" }[] = [
|
|
7
|
+
{ key: "↑ ↓ / J K", what: "Move through the list" },
|
|
8
|
+
{ key: "Home / End", what: "First or last row" },
|
|
9
|
+
{ key: "↵ / O", what: "Open the selected workspace's chat" },
|
|
10
|
+
{ key: "S", what: "Show the keys" },
|
|
11
|
+
{ key: "/", what: "Search", when: "search" },
|
|
12
|
+
{ key: "↑ / ↓", what: "Move through the results", when: "search" },
|
|
13
|
+
{ key: "↵", what: "Show the result; ↵ again opens its chat", when: "search" },
|
|
14
|
+
{ key: "Esc", what: "Clear the search, then leave it", when: "search" },
|
|
15
|
+
{ key: "⌘↵", what: "Send the answer you're writing", when: "pane" },
|
|
16
|
+
];
|
package/shared/list-keys.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Walking a list of rows from the keyboard (desktop and web), the keys and the step. Home and Paseo's sidebar view
|
|
3
3
|
* walk HomeList with these through one hook (client/list-keys.ts; invariant one-keyboard-walk-for-every-list).
|
|
4
4
|
*/
|
|
5
|
-
export type ListMove = "next" | "prev" | "first" | "last" | "open";
|
|
5
|
+
export type ListMove = "next" | "prev" | "first" | "last" | "open" | "keys";
|
|
6
6
|
export type ListKeyEvent = { key: string; metaKey?: boolean; ctrlKey?: boolean; altKey?: boolean; shiftKey?: boolean };
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -20,13 +20,36 @@ export function listMove(e: ListKeyEvent, typing: boolean): ListMove | null {
|
|
|
20
20
|
case "k": return "prev";
|
|
21
21
|
case "Home": return "first";
|
|
22
22
|
case "End": return "last";
|
|
23
|
-
case "Enter": return "open";
|
|
23
|
+
case "Enter": case "o": return "open";
|
|
24
|
+
// Catch up's letter for the keys sheet: the same letter does the same thing on Home.
|
|
25
|
+
case "s": return "keys";
|
|
24
26
|
default: return null;
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
/**
|
|
31
|
+
* The row Enter (or O) opens (invariant the-selected-workspace-opens-with-enter). A focused row opens itself. On Home
|
|
32
|
+
* ("select") the selection opens too when nothing has focus: after a click, a ⌘K or search pick, or coming back to
|
|
33
|
+
* Home the selection is on screen but focus is on the page, not on its row. Enter on any other control (a button, a
|
|
34
|
+
* chip, a field) stays that control's: the caller never asks then.
|
|
35
|
+
*/
|
|
36
|
+
export function enterTarget(input: { focused: string | null; selectedKey: string | null; mode: "select" | "focus"; onBody: boolean }): string | null {
|
|
37
|
+
if (input.focused) return input.focused;
|
|
38
|
+
return input.mode === "select" && input.onBody ? input.selectedKey : null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Enter in Home's search: the first press picks the active result (the detail pane shows it); a press on the result
|
|
43
|
+
* that is already selected opens it, as Enter on its row would. With no query, Enter opens the selection.
|
|
44
|
+
*/
|
|
45
|
+
export function searchEnter(input: { item: string | null; selected: string | null; query: string }): "select" | "open" | null {
|
|
46
|
+
if (!input.query.trim()) return input.selected ? "open" : null;
|
|
47
|
+
if (!input.item) return null;
|
|
48
|
+
return input.item === input.selected ? "open" : "select";
|
|
49
|
+
}
|
|
50
|
+
|
|
28
51
|
/** 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 {
|
|
52
|
+
export function stepKey(order: readonly string[], current: string | null, move: Exclude<ListMove, "open" | "keys">): string | null {
|
|
30
53
|
if (!order.length) return null;
|
|
31
54
|
if (move === "last") return order[order.length - 1];
|
|
32
55
|
const i = current === null ? -1 : order.indexOf(current);
|
|
@@ -68,7 +91,7 @@ export function surfaceVisible(root: Visible | null | undefined, doc: { visibili
|
|
|
68
91
|
* Where a move lands. From the list's own query field the arrows enter the list: at the selection on Home ("select"),
|
|
69
92
|
* at the first match in the sidebar view ("focus"). Otherwise one step from the focused row, or from the selection.
|
|
70
93
|
*/
|
|
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 {
|
|
94
|
+
export function walkTarget(input: { order: readonly string[]; focused: string | null; selectedKey: string | null; mode: "select" | "focus"; typing: boolean; move: Exclude<ListMove, "open" | "keys"> }): string | null {
|
|
72
95
|
const { order, focused, selectedKey, mode, typing, move } = input;
|
|
73
96
|
const from = focused ?? (selectedKey !== null && order.includes(selectedKey) ? selectedKey : null);
|
|
74
97
|
if (typing) return mode === "select" && from ? from : order[0] ?? null;
|
package/shared/model.ts
CHANGED
|
@@ -138,6 +138,15 @@ export const workspaceSchema = z.object({
|
|
|
138
138
|
sendWait: z.enum(["unloaded", "setup"]).nullable().optional(),
|
|
139
139
|
updatedAt: z.string(), managedDoneLabel: z.boolean(),
|
|
140
140
|
runtimeReason: z.string().nullable(), runtimeBusy: z.boolean(), backgroundBusy: z.boolean().default(false),
|
|
141
|
+
/**
|
|
142
|
+
* What the main agent itself is doing that holds a repair (Q96 = A, invariant a-repair-goes-to-a-free-main-agent): its
|
|
143
|
+
* own turn, its own background job while Wait for background jobs is on, a permission prompt or question, a Session
|
|
144
|
+
* Guard pause or a compaction. Set with runtimeBusy, by the same read
|
|
145
|
+
* (server/daemon.ts observe). runtimeBusy and backgroundBusy stay the whole workspace (Done, "all work finished");
|
|
146
|
+
* other agents and subagents never land here. Absent (a record no refresh has read yet): unknown, so the send
|
|
147
|
+
* decision treats the workspace's busy as the main agent's (Unknown is not off).
|
|
148
|
+
*/
|
|
149
|
+
mainBusy: z.enum(["turn", "jobs", "permission", "guard", "compacting"]).nullable().optional(),
|
|
141
150
|
/** Live state of the agents this workspace's working tasks name, refreshed with runtimeBusy from Paseo's agent list
|
|
142
151
|
* (metadata only). Every surface that says a task's agent is working reads this, never the stored status alone. */
|
|
143
152
|
taskAgents: z.record(z.string(), z.object({ title: z.string().nullable(), state: z.enum(["working", "idle", "closed", "archived"]) })).optional(),
|
|
@@ -272,7 +281,7 @@ export function summary(w: ListWorkspace, now = Date.now()): { status: Status; l
|
|
|
272
281
|
const batch = w.batches.find(b => !recoveryBatch(b) && ["pending", "sending", "sent"].includes(b.state) && !(b.state === "pending" && completionCheck(b)));
|
|
273
282
|
if (batch) return { status: batch.state === "pending" ? "active" : "handling", label: batch.state === "pending" ? w.enable_auto_sends ? "Auto queued" : "Ready to send" : "Agent handling", reason: `${batch.tasks.length} follow-up task${batch.tasks.length === 1 ? "" : "s"} ${batch.state === "pending" ? "queued" : batch.recipientAgentId && batch.recipientAgentId !== w.mainAgentId ? "sent to the recovery agent" : "sent to the main agent"}` };
|
|
274
283
|
const live = liveWorkingTask(w);
|
|
275
|
-
if (w.runtimeBusy || live) return { status: "handling", label: "Agent handling", reason: live?.title ?? "The main agent is working" };
|
|
284
|
+
if (w.runtimeBusy || live) return { status: "handling", label: "Agent handling", reason: live?.title ?? (w.mainBusy === null ? "Agents in this workspace are working" : "The main agent is working") };
|
|
276
285
|
if (w.prs.some(pr => !statusKnown(pr))) return { status: "waiting", label: "Waiting", reason: "PR status unavailable; refresh will retry" };
|
|
277
286
|
const pending = obligations.find(o => !["done", "waived"].includes(o.status));
|
|
278
287
|
if (pending) return { status: pending.status === "waiting" ? "waiting" : "active", label: pending.status === "waiting" ? "Waiting" : "Active", reason: pending.title };
|
package/shared/send-decision.ts
CHANGED
|
@@ -39,6 +39,38 @@ const iso = (ms: number) => new Date(ms).toISOString();
|
|
|
39
39
|
/** The reason the settle gives: why "in a minute" and not now (Tom, 2026-11-12: "sending in a moment? why not now?"). */
|
|
40
40
|
export const SETTLE_REASON = "waits a minute so new changes join the same message";
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Why a repair waits on the main agent itself, said the same on every surface and in the queue (Q96 = A). Only the
|
|
44
|
+
* main agent's own work holds a repair: never another agent in the workspace, never a subagent.
|
|
45
|
+
*/
|
|
46
|
+
export const MAIN_WAIT = {
|
|
47
|
+
turn: "sends when the main agent's turn ends, so it isn't interrupted",
|
|
48
|
+
jobs: "sends when the main agent's background job ends (Wait for background jobs is on)",
|
|
49
|
+
permission: "sends once the main agent's permission prompt is answered",
|
|
50
|
+
guard: "sends when Session Guard resumes the main agent",
|
|
51
|
+
compacting: "sends when Smart Session finishes compacting the main agent",
|
|
52
|
+
} as const;
|
|
53
|
+
export type MainWait = keyof typeof MAIN_WAIT;
|
|
54
|
+
/** Auto-send is off for the workspace: the repair waits for the developer's Send. */
|
|
55
|
+
export const AUTO_OFF_REASON = "Auto-send is off here, so it waits for your Send";
|
|
56
|
+
/**
|
|
57
|
+
* The main agent's own wait. A record no refresh has read yet (`mainBusy` absent) counts the workspace's busy as the
|
|
58
|
+
* main agent's: unknown is not off.
|
|
59
|
+
*/
|
|
60
|
+
export const mainWait = (w: Pick<Workspace, "mainBusy" | "runtimeBusy" | "backgroundBusy">): MainWait | null =>
|
|
61
|
+
repairWait({ busy: w.runtimeBusy, backgroundBusy: w.backgroundBusy, mainBusy: w.mainBusy });
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* What holds a repair: the main agent's own wait (Runtime.mainBusy, Q96 = A). A gateway that doesn't say (undefined)
|
|
65
|
+
* counts the workspace's busy as the main agent's: unknown is not off.
|
|
66
|
+
*/
|
|
67
|
+
export function repairWait(runtime: { busy: boolean; backgroundBusy?: boolean; mainBusy?: MainWait | null }): MainWait | null {
|
|
68
|
+
if (runtime.mainBusy !== undefined) return runtime.mainBusy;
|
|
69
|
+
return runtime.busy ? "turn" : runtime.backgroundBusy ? "jobs" : null;
|
|
70
|
+
}
|
|
71
|
+
/** The Done check reads whether all work is finished, so it alone still waits for every agent in the workspace. */
|
|
72
|
+
export const QUIET_WAIT = "waits until every agent in the workspace is done, so the check sees finished work";
|
|
73
|
+
|
|
42
74
|
/**
|
|
43
75
|
* The one auto-send rule (status invariant the-send-line-matches-the-send-decision). The worker's refresh sends the
|
|
44
76
|
* queued batch when, and only when, `send` is true; the batch line on every surface (shared/status.ts) and the Tasks
|
|
@@ -52,19 +84,21 @@ export function sendDecision(w: Workspace, now: number, o: { settleMs?: number;
|
|
|
52
84
|
// What the developer's own Send (Engine.sendPending/dispatch) refuses, checked in the same order.
|
|
53
85
|
const prUnread = b && needsPrObservations(w, b) ? w.prs.find(p => p.error || !p.snapshot?.complete) : undefined;
|
|
54
86
|
const openBatch = !!b && w.batches.some(x => x.id !== b.id && !recoveryBatch(x) && OPEN_BATCH_STATES.includes(x.state));
|
|
87
|
+
// The developer's Send is taken while the main agent is busy: it goes the moment the main agent is free (Q96).
|
|
55
88
|
const canSendNow = !!b && b.state === "pending" && !recoveryBatch(b) && !w.archived && w.enable_tracking && !w.hold && !w.goneAgent &&
|
|
56
|
-
!w.
|
|
89
|
+
(!w.runtimeReason || !!mainWait(w)) && !openBatch && !prUnread;
|
|
57
90
|
const wait = (waitingOn: SendDecision["waitingOn"], reason: string, eta: string | null = null): SendDecision => ({ send: false, waitingOn, reason, eta, canSendNow });
|
|
58
91
|
if (!b || b.state !== "pending" || recoveryBatch(b)) return wait(null, "nothing queued");
|
|
59
92
|
if (w.archived) return wait("you", "the workspace is archived");
|
|
60
93
|
if (!w.enable_tracking) return wait("you", "Follow-up isn't following this workspace");
|
|
61
94
|
// The Done check never goes out on its own (it would wake an idle agent for bookkeeping).
|
|
62
95
|
if (b.tasks.some(t => t.kind === "completion")) return wait("you", "ready to send");
|
|
63
|
-
if (!w.enable_auto_sends) return wait("you",
|
|
96
|
+
if (!w.enable_auto_sends) return wait("you", AUTO_OFF_REASON);
|
|
64
97
|
if (w.hold) return wait("you", "paused until you resume");
|
|
65
98
|
if (w.goneAgent) return wait("you", "the main agent's conversation is gone");
|
|
66
|
-
|
|
67
|
-
|
|
99
|
+
// Only the main agent's own work holds a repair (Q96 = A): a subagent or another agent at work never does.
|
|
100
|
+
const main = mainWait(w);
|
|
101
|
+
if (main) return wait("agent", MAIN_WAIT[main]);
|
|
68
102
|
if (w.runtimeReason) return wait("follow-up", w.runtimeReason);
|
|
69
103
|
if (openBatch) return wait("follow-up", "waits for the last message to finish");
|
|
70
104
|
if (w.dormant) return wait("you", "waits until the workspace is active again");
|
|
@@ -13,7 +13,7 @@ import { asksForReviewers, liveLine, needsYou, type NeedItem } from "./attention
|
|
|
13
13
|
import { HOME_GROUPS, homeCounts, prChip, trackedGroup, type HomeModel } from "./home";
|
|
14
14
|
import { freshPriorities, type Priority } from "./priorities";
|
|
15
15
|
import { agentCard, automaticHold, batchView, holdSuperseded } from "./status";
|
|
16
|
-
import { conditionId, isCapped, NO_PROGRESS_CAP, personHeld, sendDecision, stuckRepair } from "./send-decision";
|
|
16
|
+
import { conditionId, isCapped, mainWait, NO_PROGRESS_CAP, personHeld, sendDecision, stuckRepair } from "./send-decision";
|
|
17
17
|
import { messageStrip, obligationDelivery, repairRows } from "./task-rows";
|
|
18
18
|
import { followUpObligations } from "./follow-up";
|
|
19
19
|
import { PRESENCE, claimsWorking, taskStatus } from "./task-status";
|
|
@@ -32,7 +32,6 @@ import { GONE_REASON } from "./queue";
|
|
|
32
32
|
*/
|
|
33
33
|
export type Invariant = { id: string; why: string; check(w: Workspace, now: number): string | null };
|
|
34
34
|
|
|
35
|
-
const idle = (w: Workspace) => !w.runtimeBusy && !w.backgroundBusy;
|
|
36
35
|
const inFlight = (w: Workspace) => w.batches.some(b => ["sending", "sent"].includes(b.state));
|
|
37
36
|
const lines = (w: Workspace, now: number) => [liveLine(w, now).text, agentCard(w, now)?.line ?? "", batchView(w, now)?.line ?? "", ...needsYou(w, now).flatMap(i => [i.title, "blocker" in i ? i.blocker ?? "" : ""])];
|
|
38
37
|
|
|
@@ -170,7 +169,22 @@ export const INVARIANTS: Invariant[] = [
|
|
|
170
169
|
},
|
|
171
170
|
{
|
|
172
171
|
id: "waiting-on-agent-means-busy", why: "a queued batch may only blame the agent's turn while the agent is in one",
|
|
173
|
-
check: (w, now) => { const v = batchView(w, now); return v?.phase === "queued" && v.waitingOn === "agent" &&
|
|
172
|
+
check: (w, now) => { const v = batchView(w, now); return v?.phase === "queued" && v.waitingOn === "agent" && !mainWait(w) ? v.line : null; },
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
id: "a-repair-goes-to-a-free-main-agent",
|
|
176
|
+
why: "2026-11-18 (Q96 = A): a repair sat pending over two hours with Auto-send on and the main agent idle, because a subagent it started ran one task after another and every non-main agent's work held repairs; the card said nothing true. A repair waits only for the main agent itself (its turn, its own background job with Wait for background jobs on, a permission prompt, Session Guard, compaction), says what it waits for, and offers Send now while it does.",
|
|
177
|
+
check(w, now) {
|
|
178
|
+
const v = batchView(w, now);
|
|
179
|
+
if (v?.phase !== "queued" || v.kind !== "repairs") return null;
|
|
180
|
+
const d = sendDecision(w, now, { batch: v.batch });
|
|
181
|
+
if (d.waitingOn === "agent" && !mainWait(w)) return `"${d.reason}" while the main agent is free`;
|
|
182
|
+
// Send now is taken while the main agent is busy; only something else (an open message, unread PRs) refuses it.
|
|
183
|
+
if (d.waitingOn === "agent" && !d.canSendNow && sendDecision({ ...w, mainBusy: null, runtimeBusy: false, backgroundBusy: false, runtimeReason: null }, now, { batch: v.batch }).canSendNow)
|
|
184
|
+
return `waits on the main agent with no Send now: "${d.reason}"`;
|
|
185
|
+
if (!d.send && !d.reason.trim()) return "waits without saying why";
|
|
186
|
+
return null;
|
|
187
|
+
},
|
|
174
188
|
},
|
|
175
189
|
{
|
|
176
190
|
id: "on-it-means-sent", why: "2026-11-10 wks_4b27f268: \"Main agent is on it\" while the agent was idle and nothing had been sent",
|