paseo-follow-up 2.6.0-beta.5 → 2.6.0-beta.7

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/field.tsx CHANGED
@@ -1,17 +1,46 @@
1
1
  // Every text field in Follow-up (`the-keyboard-never-covers-a-field`, tests/keyboard-field.test.ts): the SDK's
2
2
  // TextInput, so Paseo still positions it inside its sheets, plus a report to the nearest KeyboardRoom
3
3
  // (client/keyboard.tsx) when it gains or loses focus, so the room keeps it above a phone's keyboard.
4
- import { forwardRef, useCallback, useRef } from "react";
5
- import type { TextInput as NativeTextInput, TextInputProps } from "react-native";
4
+ // A one-line field's placeholder always fits its line (`a-placeholder-never-wraps`, invariant 153,
5
+ // shared/placeholder-fit.ts): Android's EditText wraps a one-line field's hint and the field clips the second line,
6
+ // so the field measures its own text room and draws the longest wording that fits.
7
+ import { forwardRef, useCallback, useRef, useState } from "react";
8
+ import { Platform, StyleSheet, useWindowDimensions, type LayoutChangeEvent, type TextInput as NativeTextInput, type TextInputProps } from "react-native";
6
9
  import { TextInput } from "@getpaseo/plugin/client/ui";
7
10
  import { useFieldRoom, type FocusedField } from "./keyboard";
11
+ import { drawnFontSize, estimateTextWidth, fitPlaceholder, fullPlaceholder, textRoom, type Placeholder } from "../shared/placeholder-fit";
8
12
 
9
13
  export type FieldRef = NativeTextInput;
14
+ export type FieldProps = Omit<TextInputProps, "placeholder"> & {
15
+ /** The hint, or its wordings preferred first ("Search or ask the Overseer", "Search or ask", "Search"). */
16
+ placeholder?: Placeholder;
17
+ };
10
18
 
11
- export const Field = forwardRef<NativeTextInput, TextInputProps>(function Field({ onFocus, onBlur, ...props }, ref) {
19
+ /** Android's EditText pads its text where the style sets no horizontal padding (Material: about 12 dp a side). */
20
+ const ANDROID_TEXT_PAD = 12;
21
+
22
+ type WebInput = { getBoundingClientRect?: () => unknown; ownerDocument?: { defaultView?: { getComputedStyle(n: unknown): Record<string, string> } } };
23
+ let canvas: { getContext(k: "2d"): { font: string; measureText(t: string): { width: number } } | null } | null = null;
24
+ /** The browser's own measure of `text` in this input's font, or null where there is none (native, tests). */
25
+ function webMeasure(node: unknown): ((text: string) => number) | null {
26
+ const input = node as WebInput | null;
27
+ const css = input?.ownerDocument?.defaultView?.getComputedStyle(input);
28
+ const doc = (globalThis as { document?: { createElement(t: string): unknown } }).document;
29
+ if (!css || !doc) return null;
30
+ canvas ??= doc.createElement("canvas") as typeof canvas;
31
+ const ctx = canvas?.getContext("2d");
32
+ if (!ctx) return null;
33
+ ctx.font = css.font || `${css.fontStyle} ${css.fontWeight} ${css.fontSize} ${css.fontFamily}`;
34
+ const spacing = parseFloat(css.letterSpacing) || 0;
35
+ return text => ctx.measureText(text).width + spacing * [...text].length + 1;
36
+ }
37
+
38
+ export const Field = forwardRef<NativeTextInput, FieldProps>(function Field({ onFocus, onBlur, onLayout, placeholder, accessibilityLabel, ...props }, ref) {
12
39
  const own = useRef<NativeTextInput | null>(null);
13
40
  const { room, scroll } = useFieldRoom();
14
41
  const me = useRef<FocusedField | null>(null);
42
+ const [width, setWidth] = useState<number | null>(null);
43
+ const { fontScale } = useWindowDimensions();
15
44
  const setRef = useCallback((input: NativeTextInput | null) => {
16
45
  own.current = input;
17
46
  if (typeof ref === "function") ref(input); else if (ref) ref.current = input;
@@ -29,5 +58,26 @@ export const Field = forwardRef<NativeTextInput, TextInputProps>(function Field(
29
58
  if (me.current) room?.blur(me.current);
30
59
  onBlur?.(e);
31
60
  };
32
- return <TextInput {...props} ref={setRef} onFocus={focus} onBlur={blur} />;
61
+ // Only a one-line field with a hint measures itself; a multi-line field's hint wraps as its text does.
62
+ const fits = placeholder !== undefined && !props.multiline;
63
+ const layout = (e: LayoutChangeEvent) => {
64
+ const w = Math.round(e.nativeEvent.layout.width);
65
+ if (fits && w !== width) setWidth(w);
66
+ onLayout?.(e);
67
+ };
68
+ const full = placeholder === undefined ? undefined : fullPlaceholder(placeholder);
69
+ // Before its width is known a phone field shows its shortest wording, so Android never draws one frame wrapped.
70
+ let shown = fits && width === null && Platform.OS !== "web" ? fitPlaceholder(placeholder, null, () => 0, "shortest") : full;
71
+ if (fits && width !== null) {
72
+ const style = (StyleSheet.flatten(props.style) ?? {}) as Record<string, unknown>;
73
+ const web = Platform.OS === "web" ? webMeasure(own.current) : null;
74
+ const size = drawnFontSize(style, Platform.OS === "web" ? 1 : fontScale, props);
75
+ const spacing = typeof style.letterSpacing === "number" ? style.letterSpacing : 0;
76
+ const measure = web ?? ((t: string) => estimateTextWidth(t, size, spacing));
77
+ shown = fitPlaceholder(placeholder, textRoom(width, style, Platform.OS === "android" ? ANDROID_TEXT_PAD : 0), measure);
78
+ }
79
+ // A one-line field is named by its full wording whatever the width shows, so a screen reader hears one name.
80
+ const label = accessibilityLabel ?? (fits ? full : undefined);
81
+ return <TextInput {...props} placeholder={shown} accessibilityLabel={label} numberOfLines={props.multiline ? props.numberOfLines : 1}
82
+ ref={setRef} onFocus={focus} onBlur={blur} onLayout={fits || onLayout ? layout : undefined} />;
33
83
  });
@@ -8,6 +8,7 @@ import { Icon, ScrollView, useToast } from "@getpaseo/plugin/client/ui";
8
8
  import { homeCounts, type HomeGroupId, type HomeModel } from "../shared/home";
9
9
  import { layoutHint, filterHome, homeSearchDocs, indexDocs, defaultActive, omniboxResults, overseerProvider, workspaceProvider, type OmniboxItem, type OmniboxProvider } from "../shared/search";
10
10
  import { LayoutCapture, type LayoutKey } from "../shared/layout-swap";
11
+ import { fullPlaceholder, type Placeholder } from "../shared/placeholder-fit";
11
12
  import { DEFAULT_SORT, isMenuSort, MENU_SORTS, SORT_HINT, SORT_LABEL, type SortMode } from "../shared/sort";
12
13
  import { GROUPING_LABEL, GROUPINGS, homeViewFiltered, SHOW_ITEMS, SHOW_LABEL, TITLE_LABEL, TITLE_SOURCES, type HomeView } from "../shared/home-arrange";
13
14
  import { PRIORITY_SOURCE_LABEL } from "../shared/priorities";
@@ -146,7 +147,9 @@ export function QueryField({ theme, value, onChange, placeholder, icon, dense, i
146
147
  autoFocus?: boolean;
147
148
  /** Esc's own action (a section search closes); without it Esc clears, then leaves the field. */
148
149
  onEscape?: () => void;
149
- theme: Theme; value: string; onChange: (q: string) => void; placeholder: string; icon: string; dense: boolean;
150
+ theme: Theme; value: string; onChange: (q: string) => void; icon: string; dense: boolean;
151
+ /** Its wordings, preferred first: the field shows the longest that fits its one line (invariant 153). */
152
+ placeholder: Placeholder;
150
153
  /** The key chip at the field's end (web, desktop width): "/" or the search-from-anywhere key; false for none. */
151
154
  /** The chip's hover title (web): what each key does. */
152
155
  slashTitle?: string;
@@ -179,7 +182,7 @@ export function QueryField({ theme, value, onChange, placeholder, icon, dense, i
179
182
  borderWidth: 1, borderColor: focused ? withAlpha(c.foreground, 0.35) : c.border, backgroundColor: c.surface1 }}>
180
183
  <Icon name={icon as never} size={dense ? 16 : 13} color={c.foregroundMuted} />
181
184
  <Field ref={inputRef} onLayout={onLayout} value={value} onChangeText={q => { onLayoutQuery?.(capture.current.change(q)); onChange(q); }} placeholder={placeholder} placeholderTextColor={c.foregroundMuted}
182
- accessibilityLabel={placeholder} autoFocus={autoFocus} autoCorrect={false} autoCapitalize="none" spellCheck={false} returnKeyType="go"
185
+ accessibilityLabel={fullPlaceholder(placeholder)} autoFocus={autoFocus} autoCorrect={false} autoCapitalize="none" spellCheck={false} returnKeyType="go"
183
186
  {...(listKeys || onLayout ? { dataSet: { ...(listKeys ? { listKeys: "1" } : {}), ...(onLayout ? { followUpSearch: "1" } : {}) } } as object : {})}
184
187
  onFocus={() => setFocused(true)} onBlur={() => setFocused(false)}
185
188
  onSubmitEditing={onSubmit}
@@ -195,7 +198,7 @@ export function QueryField({ theme, value, onChange, placeholder, icon, dense, i
195
198
  style={{ flex: 1, minWidth: 0, color: c.foreground, fontSize: dense ? 15 : 13, paddingVertical: 0, ...(Platform.OS === "web" ? { outlineStyle: "none" } as object : {}) }} />
196
199
  {trailing}
197
200
  {count !== undefined ? !!count && <Text accessibilityLiveRegion="polite" style={{ color: c.foregroundMuted, fontSize: dense ? 13 : 12, fontVariant: ["tabular-nums"] }}>{count}</Text>
198
- : !!value && <Pressable accessibilityRole="button" accessibilityLabel={`Clear ${placeholder.toLowerCase()}`} hitSlop={dense ? 14 : 8} onPress={() => { onChange(""); inputRef.current?.focus(); }}>
201
+ : !!value && <Pressable accessibilityRole="button" accessibilityLabel={`Clear ${fullPlaceholder(placeholder).toLowerCase()}`} hitSlop={dense ? 14 : 8} onPress={() => { onChange(""); inputRef.current?.focus(); }}>
199
202
  <Icon name="X" size={dense ? 16 : 13} color={c.foregroundMuted} />
200
203
  </Pressable>}
201
204
  {slashHint && !value && !focused && !dense && Platform.OS === "web" && <Text accessibilityElementsHidden importantForAccessibility="no"
@@ -204,6 +207,11 @@ export function QueryField({ theme, value, onChange, placeholder, icon, dense, i
204
207
  </View>;
205
208
  }
206
209
 
210
+ /** Home's search wordings, longest first: a phone's half-width field shows the longest that fits (invariant 153). */
211
+ export const searchPlaceholder = (askOn: boolean, dense: boolean): readonly string[] => askOn
212
+ ? [dense ? "Search or ask the Overseer" : "Search, or ask the Overseer", "Search or ask", "Search"]
213
+ : ["Search workspaces, branches, PRs", "Search workspaces", "Search"];
214
+
207
215
  /**
208
216
  * Home's search. Its chip names the search-from-anywhere key when one is set (it works here too), else "/"; plain "/"
209
217
  * focuses it on Home either way (useSlashToFocus).
@@ -211,7 +219,7 @@ export function QueryField({ theme, value, onChange, placeholder, icon, dense, i
211
219
  /** `onEnter`: the active result, or null when the query is empty (Home then opens its selection). */
212
220
  export function SearchField({ theme, omnibox, dense, onEnter, anywhereKey }: { theme: Theme; omnibox: Omnibox; dense: boolean; onEnter: (item: OmniboxItem | null) => void; anywhereKey?: string | null }) {
213
221
  const { query, setQuery, move, inputRef, askOn } = omnibox;
214
- const placeholder = askOn ? dense ? "Search or ask the Overseer" : "Search, or ask the Overseer" : "Search workspaces, branches, PRs";
222
+ const placeholder = searchPlaceholder(askOn, dense);
215
223
  // The bar stays one line: a paste or drop lands here, and Home draws the thumbnails on their own line under it.
216
224
  if (askOn) return <ImageField model={omnibox.images} theme={theme} compact={dense} row={false} attach="inline" style={{ flex: 1, minWidth: 0 }}><QueryField theme={theme} onLayoutQuery={omnibox.setPhysical} value={query} onChange={setQuery} placeholder={placeholder} icon="Search" dense={dense} inputRef={inputRef} onLayout={omnibox.onSearchLayout} slashHint={anywhereKey || "/"}
217
225
  trailing={<AttachImageButton model={omnibox.images} theme={theme} compact={dense} label="Add image for the Overseer" />}
@@ -245,7 +253,7 @@ export function useListFilter(model: HomeModel, sources: HomeSources): ListFilte
245
253
  }
246
254
  /** "Filter workspaces": a filter icon and no key binding, so it never reads as Paseo's own Search (the Command Center, ⌘K). */
247
255
  export function FilterField({ theme, filter, dense }: { theme: Theme; filter: ListFilter; dense: boolean }) {
248
- return <QueryField theme={theme} onLayoutQuery={filter.setPhysical} value={filter.query} onChange={filter.setQuery} placeholder="Filter workspaces" icon="ListFilter" dense={dense} inputRef={filter.inputRef} slashHint={false} listKeys />;
256
+ return <QueryField theme={theme} onLayoutQuery={filter.setPhysical} value={filter.query} onChange={filter.setQuery} placeholder={["Filter workspaces", "Filter"]} icon="ListFilter" dense={dense} inputRef={filter.inputRef} slashHint={false} listKeys />;
249
257
  }
250
258
 
251
259
  /** Kept outside the textbox: never changes the query or adds a decision to the search flow. */
@@ -398,11 +406,15 @@ export function StatusStrip({ theme, model, filter, onFilter, touch, dense }: {
398
406
  const chips = <>
399
407
  {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))}
400
408
  {counts.later > 0 && chip("later", "Later", counts.later, filter === "later", () => onFilter(filter === "later" ? null : "later"))}
401
- {counts.archivable > 0 && <Text style={{ color: c.statusSuccess, fontSize: 12, paddingHorizontal: 6 }}>{counts.archivable} to archive</Text>}
409
+ {/* On a phone it sits in the chips' 44 row (a box, not a lineHeight, which a large font would scale), so a wrapped line keeps the strip's rhythm. */}
410
+ {counts.archivable > 0 && (touch
411
+ ? <View testID="strip-archivable" style={{ minHeight: 44, justifyContent: "center" }}><Text style={{ color: c.statusSuccess, fontSize: 12, paddingHorizontal: 6 }}>{counts.archivable} to archive</Text></View>
412
+ : <Text style={{ color: c.statusSuccess, fontSize: 12, paddingHorizontal: 6 }}>{counts.archivable} to archive</Text>)}
402
413
  </>;
403
- // Phones: only groups that have something, on one line that scrolls sideways instead of wrapping.
404
- if (touch) return <ScrollView horizontal showsHorizontalScrollIndicator={false} accessibilityRole="toolbar" accessibilityLabel="Status"
405
- contentContainerStyle={{ flexDirection: "row", alignItems: "center", gap: 4, paddingHorizontal: 12, paddingVertical: 2 }}>{chips}</ScrollView>;
414
+ // Phones: only groups that have something, wrapping onto a second line when a narrow screen or a large font needs it
415
+ // (nothing-hides-past-the-edge: a sideways scroller cut its last chip at the edge with nothing saying more was there).
416
+ if (touch) return <View accessibilityRole="toolbar" accessibilityLabel="Status"
417
+ style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", columnGap: 8, paddingHorizontal: 12, paddingVertical: 2 }}>{chips}</View>;
406
418
  return <View accessibilityRole="toolbar" accessibilityLabel="Status" style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", columnGap: dense ? 0 : 2, rowGap: 2, paddingHorizontal: dense ? 4 : 10 }}>
407
419
  {chips}
408
420
  </View>;
package/client/pill.tsx CHANGED
@@ -5,7 +5,7 @@ import { View } from "react-native";
5
5
  import { Pressable, Text } from "./text";
6
6
  import { useQuery } from "@tanstack/react-query";
7
7
  import { useRpc, type PluginButtonContentProps, type PluginButtonIconProps, type PluginButtonRegistration, type PluginClientContext } from "@getpaseo/plugin/client";
8
- import { Icon, ScrollView } from "@getpaseo/plugin/client/ui";
8
+ import { Icon } from "@getpaseo/plugin/client/ui";
9
9
  import { browserStatusRpc } from "../shared/contracts";
10
10
  import { activeNeeds, needsYou, type NeedItem } from "../shared/attention";
11
11
  import { briefQuestionIds, echoedItems, HEADLINE_ICON, todoLine, HEADLINE_TONE, pillState, todoLabel, withoutBriefQuestions, type PillState } from "../shared/headline";
@@ -214,18 +214,11 @@ export function PillPopover(props: PluginButtonContentProps & { deps: Deps }) {
214
214
  <Button theme={props.theme} compact={touch} grow={touch} icon="ArrowRight" title="Sign off & next"
215
215
  onPress={() => done(() => { void deps.inbox.signOff([agentId]); deps.openNext(agentId); })} />
216
216
  </View>
217
- {touch
218
- // Phones: one row that scrolls sideways, never a second line of chips.
219
- ? <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
220
- <Text style={t.meta}>Later</Text>
221
- <ScrollView horizontal showsHorizontalScrollIndicator={false} style={{ flex: 1 }} contentContainerStyle={{ gap: 6, paddingRight: 8 }}>
222
- {laterChoices(new Date()).map(([id, title]) => <Chip key={id} title={title.replace(/^In 1 hour$/, "1 hour")} theme={props.theme} compact onPress={() => done(() => void deps.inbox.snooze([agentId], snoozeUntil(id, new Date())))} />)}
223
- </ScrollView>
224
- </View>
225
- : <View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 6 }}>
226
- <Text style={[t.meta, { marginRight: 2 }]}>Later</Text>
227
- {laterChoices(new Date()).map(([id, title]) => <Chip key={id} title={title} theme={props.theme} compact={touch} onPress={() => done(() => void deps.inbox.snooze([agentId], snoozeUntil(id, new Date())))} />)}
228
- </View>}
217
+ {/* Later's choices wrap onto a second line where they don't fit (nothing-hides-past-the-edge), phones included. */}
218
+ <View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: touch ? 8 : 6 }}>
219
+ <Text style={[t.meta, { marginRight: 2 }]}>Later</Text>
220
+ {laterChoices(new Date()).map(([id, title]) => <Chip key={id} title={touch ? title.replace(/^In 1 hour$/, "1 hour") : title} theme={props.theme} compact={touch} onPress={() => done(() => void deps.inbox.snooze([agentId], snoozeUntil(id, new Date())))} />)}
221
+ </View>
229
222
  </View>}
230
223
 
231
224
  {/* 3. The workspace's own items, only when there are some. */}
@@ -4,7 +4,7 @@ import { Pressable, Text } from "./text";
4
4
  import { openExternalUrl, useRpc, type PluginHostProps } from "@getpaseo/plugin/client";
5
5
  import { Icon, Modal, ScrollView } from "@getpaseo/plugin/client/ui";
6
6
  import { reportLinkRpc, reportSendRpc, reportTargetsRpc } from "../shared/contracts";
7
- import { NEW_AGENT, NEW_WORKSPACE, PICKER_MAX, defaultChoice, pickerScrolls, newAgentLines, pickerRows, targetLines, type PickerRow, type SendTargets } from "../shared/report-send";
7
+ import { ABOUT_LINE, NEW_AGENT, NEW_WORKSPACE, PICKER_MAX, reportAbout, defaultChoice, pickerScrolls, newAgentLines, pickerRows, targetLines, type PickerRow, type SendTargets } from "../shared/report-send";
8
8
  import { errorText } from "../shared/errors";
9
9
  import { BRAND_ICONS } from "./brand-icons";
10
10
  import { Button, SubmitScope, text } from "./kit";
@@ -19,7 +19,9 @@ import { Field } from "./field";
19
19
  * interviews them, dry-runs follow_report_issue and shows the exact issue before filing it.
20
20
  */
21
21
  export type ReportKind = "bug" | "feature" | "feedback";
22
- export type ReportRequest = { kind?: ReportKind; error?: string | null; at?: number; agentId?: string; workspaceId?: string };
22
+ export type ReportRequest = { kind?: ReportKind; error?: string | null; at?: number; agentId?: string; workspaceId?: string;
23
+ /** The workspace the report is about (the row menu's Report a bug…) and its title, for the About line. */
24
+ about?: string; aboutTitle?: string };
23
25
 
24
26
  const slot = createHostSlot<ReportRequest>();
25
27
  /**
@@ -78,13 +80,16 @@ export function ReportSheet({ request, theme, layout, openAgent, onClose }: { re
78
80
  const [choosing, setChoosing] = useState(false);
79
81
  const [phase, setPhase] = useState<Phase>({ kind: "edit" });
80
82
  const [targets, setTargets] = useState<SendTargets | null>(null);
83
+ const [aboutRemoved, setAboutRemoved] = useState(false);
84
+ const about = reportAbout(request, kind, aboutRemoved);
85
+ const aboutName = request.aboutTitle || "this workspace";
81
86
  const readTargets = useRpc(reportTargetsRpc); const send = useRpc(reportSendRpc); const link = useRpc(reportLinkRpc);
82
87
  useEffect(() => {
83
88
  let live = true;
84
89
  readTargets({ workspaceId: request.workspaceId, agentId: request.agentId }).then(r => { if (live) setTargets(r); }).catch(() => { if (live) setTargets({ agents: [], defaultId: null, newAgentWorkspace: null }); });
85
90
  return () => { live = false; };
86
91
  }, [request.workspaceId, request.agentId]);
87
- const chosen = picked ?? (targets ? defaultChoice(targets) : null);
92
+ const chosen = picked ?? (targets ? defaultChoice(targets, about) : null);
88
93
  const rows = targets ? pickerRows(targets) : { pinned: [], agents: [] };
89
94
  const chosenRow = [...rows.pinned, ...rows.agents].find(r => r.id === chosen) ?? null;
90
95
  const nowhere = !!targets && !targets.agents.length && !targets.newAgentWorkspace && !targets.newWorkspace;
@@ -94,7 +99,7 @@ export function ReportSheet({ request, theme, layout, openAgent, onClose }: { re
94
99
  if (empty || phase.kind === "sending" || !chosen) return;
95
100
  setPhase({ kind: "sending" });
96
101
  try {
97
- const r = await send({ kind, text: words, error, ...(chosen === NEW_AGENT ? { newAgentWorkspaceId: targets!.newAgentWorkspace!.id } : chosen === NEW_WORKSPACE ? { newWorkspaceProjectId: targets!.newWorkspace!.projectId } : { agentId: chosen }) });
102
+ const r = await send({ kind, text: words, error, ...(about ? { workspaceId: about } : {}), ...(chosen === NEW_AGENT ? { newAgentWorkspaceId: targets!.newAgentWorkspace!.id } : chosen === NEW_WORKSPACE ? { newWorkspaceProjectId: targets!.newWorkspace!.projectId } : { agentId: chosen }) });
98
103
  setPhase({ kind: "sent", ...r });
99
104
  } catch (e) { setPhase({ kind: "failed", message: errorText(e) }); }
100
105
  };
@@ -139,6 +144,18 @@ export function ReportSheet({ request, theme, layout, openAgent, onClose }: { re
139
144
  </View>
140
145
  <Pressable accessibilityRole="button" accessibilityLabel="Remove the error" hitSlop={8} onPress={() => setError(null)}><Icon name="X" size={14} color={c.foregroundMuted} /></Pressable>
141
146
  </View>}
147
+ {about ? <View style={{ flexDirection: "row", gap: 8, alignItems: "flex-start", backgroundColor: c.surface2, borderRadius: 8, padding: 10 }}>
148
+ <Icon name="Folder" size={14} color={c.foregroundMuted} />
149
+ <View style={{ flex: 1, minWidth: 0 }}>
150
+ <Text numberOfLines={1} style={t.body}>About {aboutName}</Text>
151
+ <Text style={t.meta}>{ABOUT_LINE}</Text>
152
+ </View>
153
+ <Pressable accessibilityRole="button" accessibilityLabel={`Don't include ${aboutName}`} hitSlop={compact ? 14 : 8} onPress={() => setAboutRemoved(true)}
154
+ style={{ minWidth: compact ? 28 : 16, minHeight: compact ? 28 : 16, alignItems: "center", justifyContent: "center" }}><Icon name="X" size={14} color={c.foregroundMuted} /></Pressable>
155
+ </View> : request.about && kind === "bug" && aboutRemoved ? <Pressable accessibilityRole="button" onPress={() => setAboutRemoved(false)} hitSlop={8}
156
+ style={{ flexDirection: "row", alignItems: "center", gap: 6, alignSelf: "flex-start", minHeight: compact ? 44 : 0 }}>
157
+ <Icon name="Plus" size={14} color={c.foregroundMuted} /><Text style={t.meta}>Include {aboutName}</Text>
158
+ </Pressable> : null}
142
159
  <Field value={words} onChangeText={setWords} multiline autoFocus={!compact} placeholder={placeholder} placeholderTextColor={c.foregroundMuted} accessibilityLabel="Describe it"
143
160
  style={{ minHeight: compact ? 132 : 112, borderWidth: 1, borderColor: c.border, borderRadius: 8, backgroundColor: c.surface0, paddingHorizontal: 12, paddingVertical: 10, color: c.foreground, fontSize: compact ? 14 : 13, lineHeight: compact ? 20 : 18, textAlignVertical: "top" }} />
144
161
  {nowhere ? <View style={{ flexDirection: "row", gap: 10, padding: 12, borderRadius: 8, backgroundColor: c.surface2 }}>
@@ -9,6 +9,7 @@ import { rowMenu, type LaterChoice, type RowMenuItem } from "../shared/row-menu"
9
9
  import type { Workstream } from "../shared/home";
10
10
  import { aboutKey } from "./about";
11
11
  import { openRename } from "./rename";
12
+ import { openReportSheet } from "./report-issue";
12
13
  import { bindToast, runAction } from "./toast-store";
13
14
  import type { HomeSources } from "./home-data";
14
15
 
@@ -97,6 +98,7 @@ export function useRowMenu(host: RowMenuHost) {
97
98
  case "unpin": return runAction({ label: "Unpin", run: async () => { await deps().setPinned!(workspaceId, false); }, success: `Unpinned ${s.title}`, failure: `Couldn't unpin ${s.title}` }, `pin:${workspaceId}`);
98
99
  case "copy_branch": return runAction({ label: "Copy branch", run: () => copyText(arg), success: "Branch name copied", failure: "Couldn't copy here" });
99
100
  case "rewrite_summary": return runAction({ label: "Rewrite summary", run: async () => cache.setQueryData(aboutKey(workspaceId), await about({ workspaceId, open: true, refresh: true })), success: "Summary rewritten" }, `about:${workspaceId}`);
101
+ case "report": return runAction({ label: "Report a bug", run: async () => openReportSheet({ kind: "bug", workspaceId, about: workspaceId, aboutTitle: s.title }), success: null });
100
102
  case "rename_ai": return runAction({ label: "Rename title with AI", run: async () => openRename({ workspaceId, title: s.title }), success: null });
101
103
  case "make_main": return runAction({ label: "Make main agent", run: async () => { await control({ workspaceId, mainAgentId: arg }); after(); }, success: `${s.agent ?? "That agent"} is now the main agent` }, `main:${workspaceId}`);
102
104
  case "stop_following": return runAction({ label: "Stop following", run: async () => { await setFollow({ workspace: { workspaceId, follow: false } }); after(); }, success: `Stopped following ${s.title}` }, `follow:${workspaceId}`);
package/index.server.ts CHANGED
@@ -152,6 +152,7 @@ import { updatesViewSchema, type UpdatesView } from "./shared/updates";
152
152
  import { PLUGIN_NAME, releaseNotesViewSchema, type ReleaseNote, type ReleaseNotesView } from "./shared/changelog";
153
153
  import { BRIEF_KIND, BRIEF_VERSION, prState, prStates, validateNeedsYou, type NeedsYouRecord } from "./shared/brief";
154
154
  import { foldedAsk } from "./shared/needs-block";
155
+ import { ARCHIVED_NEEDS_YOU_NOTE, paseoShowsLive } from "./shared/reopen";
155
156
  import { ImageStore } from "./server/image-store";
156
157
  import type { ImageRef, ImageUpload } from "./shared/images";
157
158
  import { imageSupport, trustHarnessImageProviders } from "./server/image-support";
@@ -513,6 +514,8 @@ export default function contribute(server: PluginServerContext) {
513
514
  };
514
515
  // Hooks run in the background; an inbox failure never blocks the rest of Follow-up.
515
516
  const inboxHook = (work: () => Promise<void>) => void (async () => { await ready; if (!stopped && !loadError) { await work(); feeds.inbox(); } })().catch(error => { inboxError = error instanceof Error ? error.message : String(error); });
517
+ // A workspace the engine reopened (Paseo shows it live again) shows its main agent's Needs-you row again (invariant 111).
518
+ engine.reopened = agentIds => { for (const id of agentIds) inboxHook(async () => { await inbox.reopen(id); }); };
516
519
  let unlock: (() => Promise<void>) | null = null;
517
520
  let stopped = false;
518
521
  /** Each agent's latest started turn, so a turn end can tell it was already replaced (holdOnTurnEnd). */
@@ -711,9 +714,26 @@ export default function contribute(server: PluginServerContext) {
711
714
  void (async () => { await ready; if (stopped || loadError) return; void inbox.refreshDirectory().catch(() => undefined); if (governor.allowsExtras()) void usage.refresh(); await inbox.start().catch(error => { inboxError = error instanceof Error ? error.message : String(error); }); void inboxLoop(); })();
712
715
  const changed = (w: Workspace) => { w.completion = null; w.declaration = null; w.updatedAt = new Date().toISOString(); };
713
716
 
717
+ /**
718
+ * Archived is Paseo's state, never a latch (invariant 111, shared/reopen.ts): a main agent calling a tool from a
719
+ * workspace Follow-up reads as archived reopens it when Paseo shows it live (the agent itself unarchived: a prompt
720
+ * did it). True when the workspace is (now) followed; false when Paseo still has it archived.
721
+ */
722
+ const reopenForCaller = async (agent: { id: string; workspaceId?: string | null; archivedAt?: string | null }): Promise<boolean> => {
723
+ const record = (await store.snapshot()).workspaces.find(w => w.id === agent.workspaceId);
724
+ if (!record?.archived || !record.enable_tracking || record.mainAgentId !== agent.id) return !record?.archived;
725
+ const rows = await gateway.directory.read().catch(() => null);
726
+ if (!paseoShowsLive(record.id, rows?.workspaces.find(row => row.id === record.id), agent)) return false;
727
+ await store.mutateWorkspace(record.id, w => { if (w.archived) { w.archived = false; w.updatedAt = new Date().toISOString(); } });
728
+ await inbox.reopen(agent.id).catch(() => false);
729
+ feeds.inbox();
730
+ void engine.nudge(record.id);
731
+ return true;
732
+ };
714
733
  const callerWorkspaceId = async (agentId: string, paseo: PluginHandlerContext["paseo"], allowHandoff = true) => {
715
734
  const agent = (await paseo.agents.ref(agentId).refresh())?.agent;
716
735
  if (!agent?.workspaceId) throw new Error(`Cannot locate the caller's workspace: expected agent in a recorded workspace, received agent ${agentId}.`);
736
+ await reopenForCaller(agent);
717
737
  const record = (await store.snapshot()).workspaces.find(w => w.id === agent.workspaceId);
718
738
  if (record?.contributorAgentIds?.includes(agentId) && !record.batches.some(b => b.recipientAgentId === agentId && !b.settledAt && b.tasks.every(t => t.kind === "inventory")) && (!await isWorkspaceRoot(agent, async id => (await paseo.agents.ref(id).refresh())?.agent) || isRecovery(agent.labels))) throw new Error("PR registration requires an available root agent in this tracked workspace.");
719
739
  if (allowHandoff) {
@@ -853,7 +873,8 @@ export default function contribute(server: PluginServerContext) {
853
873
  const workspace = await paseo.workspaces.ref(agent.workspaceId).refresh();
854
874
  if (!workspace) throw new Error("Workspace is unavailable.");
855
875
  return store.mutate(state => {
856
- const w = agentWorkspace(state, agentId, "write", agent.workspaceId!);
876
+ // enroll_workspace states a new goal: it follows the workspace again even while Paseo has it archived.
877
+ const w = agentWorkspace(state, agentId, "write", agent.workspaceId!, "owner", true);
857
878
  if (w) {
858
879
  if (w.goal !== goal) changed(w);
859
880
  w.goal = goal; w.title = workspace.name; w.archived = false;
@@ -1938,6 +1959,9 @@ export default function contribute(server: PluginServerContext) {
1938
1959
  github: githubApi(), updates: () => updatesView(), call: (method, input) => rpcBridge.call(method, input ?? {}), snapshot: () => store.snapshot(),
1939
1960
  resources: () => governor.current(), serverInfo: () => withDaemon(async client => (client as ServerInfoClient).getLastServerInfoMessage?.() as never), logs: logRing,
1940
1961
  toolTransport: () => toolTransport, startedAt,
1962
+ // A report about one workspace: its agents from the directory (metadata only, wakes nothing); archived ones count, never rows.
1963
+ agents: async workspaceId => ((await gateway.directory.read().catch(() => null))?.agents ?? []).map(r => r.agent).filter(a => a.workspaceId === workspaceId && !a.background)
1964
+ .map(a => ({ id: a.id, title: a.title ?? null, provider: a.provider, status: a.status, archived: !!a.archivedAt, lastActivityAt: a.lastUserMessageAt ?? a.createdAt })),
1941
1965
  });
1942
1966
  const agentActions = new AgentActions({ timeZone: () => clientTimeZone, autoSendsHeld: () => !governor.allowsBackground(), store, prActions: actions, engine, inbox, priorities: priorityStore, about, agentSettings, wait: { status: currentWait }, prWorkflows: () => prWorkflowView(), rpc: rpcBridge, display: displayBridge, report: { run: (caller, args) => reportKit.reporter.run(caller, args) }, agentTitle: async id => (await api?.agents.ref(id).refresh().catch(() => null))?.agent?.title ?? null,
1943
1967
  pins: {
@@ -2104,8 +2128,12 @@ export default function contribute(server: PluginServerContext) {
2104
2128
  if (!/^[\w-]+$/.test(agentId)) throw new Error("Unsupported agent identity.");
2105
2129
  const agent = (await paseo.agents.ref(agentId).refresh())?.agent;
2106
2130
  if (!agent?.workspaceId) throw new Error("Cannot locate the caller's workspace.");
2131
+ // Invariant 111: the main agent's ask from a workspace Follow-up read as archived reopens it when Paseo shows it
2132
+ // live; where Paseo still has it archived, the ask still reaches Needs you and the reply says so.
2133
+ const followed = !isRecovery(agent.labels) && await reopenForCaller(agent);
2107
2134
  const saved = await store.snapshot();
2108
2135
  const tracked = saved.workspaces.find(w => w.id === agent.workspaceId && w.enable_tracking && !w.archived);
2136
+ const stillArchived = !followed && saved.workspaces.some(w => w.id === agent.workspaceId && w.enable_tracking && w.archived && w.mainAgentId === agentId);
2109
2137
  // F2: root agents only. Contributors and recovery sessions report to the main agent; subagents to their parent.
2110
2138
  if (isRecovery(agent.labels) || tracked && tracked.mainAgentId !== agentId) throw new Error("needs_you is for the workspace's main agent. Report to the main agent instead.");
2111
2139
  if (!await isWorkspaceRoot(agent, async id => (await paseo.agents.ref(id).refresh())?.agent)) throw new Error("needs_you is for root agents. Report to your parent agent instead.");
@@ -2135,7 +2163,7 @@ export default function contribute(server: PluginServerContext) {
2135
2163
  const { questions: _refs, ...rest } = call;
2136
2164
  call = { ...rest, ...(linked.decisions.length ? { decisions: linked.decisions } : {}) };
2137
2165
  if (!linked.decisions.length) delete call.decisions;
2138
- } else if (call.questions?.length) throw new Error("questions point at a tracked workspace's open questions, and this workspace isn't tracked.");
2166
+ } else if (call.questions?.length) throw new Error(stillArchived ? "questions point at a tracked workspace's open questions, and Paseo has this workspace archived. Leave questions out and state the ask in ask and decisions; ask the developer to unarchive the workspace." : "questions point at a tracked workspace's open questions, and this workspace isn't tracked.");
2139
2167
  // dismissing-anything-in-needs-you-sends-the-agent-nothing: an ask the developer dismissed, stated again with nothing
2140
2168
  // new to decide, isn't flagged again: the turn ends quiet, and the call says why.
2141
2169
  const gone = await inbox.dismissedAsk(agentId);
@@ -2146,8 +2174,11 @@ export default function contribute(server: PluginServerContext) {
2146
2174
  const temporary = `${needsYouPath(agentId)}.${randomUUID()}`;
2147
2175
  await writeFile(temporary, JSON.stringify(record), { mode: 0o600 });
2148
2176
  await rename(temporary, needsYouPath(agentId));
2177
+ // The caller is running, so its Needs-you row is live: an archived (gone) row would hide the brief this turn makes.
2178
+ if (!restated && call.kind !== "done") { await inbox.reopen(agentId).catch(() => false); feeds.inbox(); }
2149
2179
  return { ok: true as const, briefId: `brief:${turn?.turnId ?? record.at}`,
2150
2180
  ...(restated ? { note: DISMISSED_ASK_NOTE }
2181
+ : stillArchived && call.kind !== "done" ? { note: ARCHIVED_NEEDS_YOU_NOTE }
2151
2182
  : dismissed.length ? { note: `The developer dismissed ${dismissed.join(", ")}: ${dismissed.length === 1 ? "it no longer matters, so it was" : "they no longer matter, so they were"} left off the card. Don't raise ${dismissed.length === 1 ? "it" : "them"} again.` } : {}) };
2152
2183
  });
2153
2184
  // Replies once the answer is recorded; the send runs after (Inbox.briefAction), so a dormant agent's slow resume never
@@ -2284,14 +2315,15 @@ export default function contribute(server: PluginServerContext) {
2284
2315
  server.on("agent.turn_started", async event => { await ready; if (stopped || loadError || !overseer) return; await overseer.turnStarted(event.agent.id).catch(() => undefined); }),
2285
2316
  // A newer main-agent turn supersedes the failed turn's automatic hold (shared/status.ts holdSuperseded).
2286
2317
  // A turn writes only the workspace it is about (server/turn-events.ts, a-send-never-clones-the-whole-state): a
2287
- // superseded hold lifts, the owned workspace's Done ends, and a dormant workspace becomes active again.
2318
+ // superseded hold lifts, the owned workspace's Done ends, the main agent's archived workspace reopens (invariant
2319
+ // 111), and a dormant workspace becomes active again.
2288
2320
  server.on("agent.turn_started", async event => {
2289
2321
  if (event.turnId) startedTurns.set(event.agent.id, event.turnId);
2290
2322
  await ready;
2291
2323
  if (stopped || loadError) return;
2292
- const { lifted, owned, woken } = await turnStarted(store, event.agent, event.turnId ?? null);
2324
+ const { lifted, owned, woken, reopened } = await turnStarted(store, event.agent, event.turnId ?? null);
2293
2325
  if (owned) gateway.markDirty(event.agent.id);
2294
- for (const id of new Set([...lifted, ...(woken ? [woken] : [])])) void engine.nudge(id);
2326
+ for (const id of new Set([...lifted, ...(woken ? [woken] : []), ...(reopened ? [reopened] : [])])) void engine.nudge(id);
2295
2327
  }),
2296
2328
  server.on("agent.turn_ended", async (event, { paseo }) => { seen(paseo); inboxHook(() => inbox.turnEnded(event.agent, event.outcome, event.turnId)); }),
2297
2329
  server.on("agent.permission_requested", async (event, { paseo }) => { seen(paseo); inboxHook(async () => { await inbox.permissionRequested(event.agent, event.request); await writeBriefState(); }); }),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "paseo-follow-up",
3
3
  "private": false,
4
- "version": "2.6.0-beta.5",
4
+ "version": "2.6.0-beta.7",
5
5
  "description": "Every agent, one inbox. Follow-up brings what all your coding agents need from you into one ranked list, and follows their work through merge, deploy and after.",
6
6
  "type": "module",
7
7
  "files": [
@@ -33,6 +33,7 @@ import { DEFAULT_SORT, MENU_SORTS } from "../shared/sort";
33
33
  import { DEFAULT_HOME_VIEW, GROUPINGS, parseHomeView, SHOW_ITEMS } from "../shared/home-arrange";
34
34
  import { SCALE } from "../shared/scale";
35
35
  import { boundDone, newestFirst, pageInput } from "../shared/paged";
36
+ import { boundReply } from "./bounded-reply";
36
37
  import { dispatchInputSchema } from "../shared/dispatch";
37
38
  import type { DispatchInput, DispatchPlan } from "./dispatch";
38
39
 
@@ -210,7 +211,8 @@ export const TOOL_INPUT = {
210
211
  display_settings: z.strictObject({}),
211
212
  make_main_agent: z.strictObject({ agentId: id.optional(), reason: z.string().trim().min(1).max(200).optional(), requested: z.enum(["developer", "self"]).optional(), ...confirm }),
212
213
  set_display: z.strictObject({ values: z.record(z.string(), z.union([z.boolean(), z.string(), z.number(), z.record(z.string(), z.unknown())])).optional(), ...confirm }),
213
- report_issue: reportInputSchema,
214
+ // workspace_id is the shared module's subject (followUpReportConfig): it reads and strips it before its own schema.
215
+ report_issue: reportInputSchema.extend({ workspace_id: id.optional() }),
214
216
  ...Object.fromEntries(RPC_TOOLS.map(t => [t.name, t.input])),
215
217
  } as unknown as Record<AgentTool, z.ZodType>;
216
218
 
@@ -240,8 +242,15 @@ export class AgentActions {
240
242
  private now: () => number;
241
243
  constructor(private d: AgentActionDeps) { this.reviewersFor = d.reviewersFor ?? configuredReviewers; this.now = d.now ?? Date.now; }
242
244
 
243
- /** Runs one tool for a verified root agent. The caller's identity is checked by the RPC before this. */
245
+ /**
246
+ * Runs one tool for a verified root agent. The caller's identity is checked by the RPC before this. Every reply goes
247
+ * through `boundReply`: a stored workspace inside it comes as workspace_status's summary (invariant 63, TOOL_BUDGET).
248
+ */
244
249
  async run(caller: string, tool: AgentTool, raw: unknown): Promise<unknown> {
250
+ return boundReply(await this.dispatch(caller, tool, raw));
251
+ }
252
+
253
+ private async dispatch(caller: string, tool: AgentTool, raw: unknown): Promise<unknown> {
245
254
  const parsed = TOOL_INPUT[tool].safeParse(raw ?? {});
246
255
  if (!parsed.success) throw new Error(`${tool}: ${parsed.error.issues.map(i => `${i.path.join(".") || "arguments"} ${i.message}`).join("; ")}`);
247
256
  const args = parsed.data as Record<string, any>;
@@ -162,7 +162,7 @@ export const RPC_TOOLS: readonly RpcTool[] = [
162
162
  // Report an issue's Send: to an agent, a new agent in a workspace, or a new workspace (server/report-send.ts). The dry
163
163
  // run shows the targets the sheet offers; an agent reporting for itself files with report_issue instead.
164
164
  { name: "report_send", rpc: "follow.report-issue-send", kind: "planned", before: { rpc: "follow.report-issue-targets", input: () => ({}) },
165
- input: z.strictObject({ kind: reportKindSchema.optional(), text: z.string().max(8000).optional(), error: z.string().max(2000).nullable().optional(), agentId: id.optional(), newAgentWorkspaceId: id.optional(), newWorkspaceProjectId: id.optional(), ...confirm }),
165
+ input: z.strictObject({ kind: reportKindSchema.optional(), text: z.string().max(8000).optional(), error: z.string().max(2000).nullable().optional(), agentId: id.optional(), newAgentWorkspaceId: id.optional(), newWorkspaceProjectId: id.optional(), workspaceId: id.nullable().optional(), ...confirm }),
166
166
  guard: (a, caller) => {
167
167
  if (a.confirm) return null;
168
168
  if (!a.kind || a.text === undefined) return "report_send: give kind (bug, feature or feedback) and text (the developer's words).";
@@ -0,0 +1,42 @@
1
+ import { compact } from "./mcp.mjs";
2
+ import { agentView } from "../shared/history";
3
+ import { TOOL_BUDGET } from "../shared/paged";
4
+ import type { Workspace } from "../shared/model";
5
+
6
+ /**
7
+ * An agent tool's answer stays under TOOL_BUDGET (invariant 63). A stored workspace record grows with use: every PR it
8
+ * ever had, every task and question, every batch. A reply that carries one whole (a planned action's confirm returns the
9
+ * workspace it changed) gets it as workspace_status's summary instead (`agentView`, then `compact`): live work whole
10
+ * while it fits, finished items as the newest few and a count with how to page them, fitted to the room the rest of the
11
+ * reply leaves. AgentActions.run passes every action's reply through here; tests/bounded-tools.test.ts scans every tool.
12
+ */
13
+ export const isWorkspaceRecord = (x: unknown): x is Workspace => {
14
+ const w = x as Partial<Workspace> | null;
15
+ return !!w && typeof w === "object" && typeof w.id === "string" && Array.isArray(w.prs) && Array.isArray(w.obligations) && Array.isArray(w.questions) && Array.isArray(w.batches);
16
+ };
17
+
18
+ const PLACEHOLDER = Symbol("workspace");
19
+
20
+ /** Replace each workspace record (to depth 4) with `swap(w)`; the same object back when there is none. */
21
+ function replace(value: unknown, swap: (w: Workspace) => unknown, depth = 0): unknown {
22
+ if (isWorkspaceRecord(value)) return swap(value);
23
+ if (depth >= 4 || !value || typeof value !== "object") return value;
24
+ if (Array.isArray(value)) {
25
+ const out = value.map(v => replace(v, swap, depth + 1));
26
+ return out.some((v, i) => v !== value[i]) ? out : value;
27
+ }
28
+ let changed = false;
29
+ const out: Record<string, unknown> = {};
30
+ for (const [k, v] of Object.entries(value)) { out[k] = replace(v, swap, depth + 1); if (out[k] !== v) changed = true; }
31
+ return changed ? out : value;
32
+ }
33
+
34
+ export function boundReply(reply: unknown, budget = TOOL_BUDGET): unknown {
35
+ let count = 0;
36
+ const shell = replace(reply, () => { count++; return PLACEHOLDER; });
37
+ if (!count) return reply;
38
+ const rest = JSON.stringify(shell, (_k, v) => v === PLACEHOLDER ? {} : v)?.length ?? 0;
39
+ const room = Math.max(2_000, Math.floor((budget - rest) / count));
40
+ const summary = (w: Workspace) => compact("workspace_status", {}, agentView(w, { budget: room }, undefined, v => compact("workspace_status", {}, v)));
41
+ return replace(reply, summary);
42
+ }
package/server/daemon.ts CHANGED
@@ -36,6 +36,7 @@ import { traceDaemon } from "./request-trace";
36
36
  import type { TurnTimeline } from "./turn-timeline";
37
37
  import { PASEO_UNREACHABLE, deliveryReceipt } from "../shared/queue";
38
38
  import type { Delivered } from "./message-queue";
39
+ import { paseoShowsLive } from "../shared/reopen";
39
40
  type RecoveryAgentOptions = Partial<PluginBeforeRequests["agent.create"]["config"]> & { workspaceId: string; labels: Record<string, string>; idempotencyKey: string; env: Record<string, string>; /** Paseo 0.16 (features.backgroundAgents): no tab, no notification, no sidebar row. */ background?: boolean };
40
41
 
41
42
  /**
@@ -495,6 +496,17 @@ export class PaseoGateway implements Gateway {
495
496
  /** Settings → Agents → Wait for background jobs (index.server.ts sets it). Unset or unreadable: on (Unknown is not off). */
496
497
  waitForJobs?: () => Promise<boolean>;
497
498
  private async waitsForJobs(): Promise<boolean> { try { return (await this.waitForJobs?.()) ?? true; } catch { return true; } }
499
+ /**
500
+ * The archived workspaces Paseo shows live again (paseoShowsLive): listed, or with their main agent unarchived. From
501
+ * the directory's rows only (no daemon request beyond its due re-read), so the engine's pass over archived workspaces
502
+ * costs nothing per workspace. Invariant 111.
503
+ */
504
+ async reopenable(ws: readonly Workspace[]): Promise<string[]> {
505
+ if (!ws.length) return [];
506
+ const rows = await this.directory.read();
507
+ const index = agentIndex(rows.agents);
508
+ return ws.filter(w => paseoShowsLive(w.id, rows.workspaces.find(row => row.id === w.id), index.byId.get(w.mainAgentId))).map(w => w.id);
509
+ }
498
510
  async observe(w: Workspace, fresh = false): Promise<Runtime> {
499
511
  const [rows, compacting, pauses] = await Promise.all([this.directory.read(fresh ? { fresh: "agents" } : {}), this.compacting(w.mainAgentId), this.guard.read()]);
500
512
  const { agents, workspaces } = rows;
@@ -505,7 +517,10 @@ export class PaseoGateway implements Gateway {
505
517
  if (taskIds.length) this.directory.lookup(taskIds);
506
518
  const taskAgents = taskIds.length ? taskAgentStates(taskIds, this.directory.withArchived(taskIds, taskIds.flatMap(id => index.byId.get(id) ?? []))) : {};
507
519
  const workspace = workspaces.find(row => row.id === w.id);
508
- if (!workspace || workspace.archivingAt) return { taskAgents, busy: false, reason: "Workspace is archived", archived: true };
520
+ if (workspace?.archivingAt) return { taskAgents, busy: false, reason: "Workspace is archived", archived: true };
521
+ // An archived workspace record whose main agent Paseo unarchived (the developer prompted it) is live again
522
+ // (paseoShowsLive, invariant 111); only Paseo's list of unarchived agents is read for it.
523
+ if (!workspace && !paseoShowsLive(w.id, workspace, index.byId.get(w.mainAgentId))) return { taskAgents, busy: false, reason: "Workspace is archived", archived: true };
509
524
  const a = index.byId.get(w.mainAgentId) ?? await this.connect(client => this.directory.live(client, w.mainAgentId));
510
525
  if (!a || a.archivedAt || a.workspaceId !== w.id) return { taskAgents, busy: false, reason: "Main agent is unavailable or moved to another workspace", archived: false };
511
526
  const recoveryIds = new Set(w.batches.filter(b => b.tasks.every(t => t.kind === "inventory")).flatMap(b => [b.recipientAgentId, ...b.recoveryHandoffs.map(h => h.fromAgentId)]));
@@ -515,7 +530,7 @@ export class PaseoGateway implements Gateway {
515
530
  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) });
516
531
  const guardedInterruptionId = this.guard.ownsInterruption(pauses, w.mainAgentId, w.interruption)?.id;
517
532
  const context = { guardedInterruptionId, mainTurnId: turnIdOf(a.activeTurn), mainTitle: a.title?.trim() || null };
518
- 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 };
533
+ 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 };
519
534
  if (compacting) return { taskAgents, busy: true, mainBusy: "compacting", reason: "Smart Session is compacting the main agent", archived: false };
520
535
  const mainLoaded = isLoaded(a), mainRecent = recentlyUsed(a, this.windowMs, this.now());
521
536
  if (conversationGone(a.lastError)) return { taskAgents, busy: false, reason: a.lastError ?? "Conversation not found", archived: false, gone: a.lastError ?? "Conversation not found", mainLoaded, mainRecent };
@@ -232,7 +232,9 @@ export class DaemonDirectory {
232
232
  // Lifecycle events. Each patches what it knows; anything it can't know (titles, message times) waits for the
233
233
  // next due re-read.
234
234
  turnStarted(agent: HookAgent, turnId: string | null): void {
235
- this.patch(agent.id, a => { a.status = "running"; a.activeTurn = { id: turnId }; if (agent.title) a.title = agent.title; });
235
+ // A turn runs only on an agent Paseo unarchived (a prompt unarchives it, with no event of its own).
236
+ this.archived.delete(agent.id);
237
+ this.patch(agent.id, a => { a.status = "running"; a.activeTurn = { id: turnId }; a.archivedAt = null; if (agent.title) a.title = agent.title; });
236
238
  this.dirty = true;
237
239
  }
238
240
  turnEnded(agent: HookAgent, outcome: { kind: string }): void {