paseo-follow-up 2.3.0-beta.3 → 2.3.0-beta.4
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/dismiss.tsx +115 -14
- package/client/header.tsx +3 -2
- package/client/needs-you.tsx +3 -2
- package/client/panel.tsx +6 -5
- package/client/settings-screens.ts +41 -0
- package/client/settings.tsx +26 -8
- package/client/theme.ts +12 -0
- package/client/updates.tsx +5 -5
- package/index.client.tsx +7 -4
- package/package.json +1 -1
- package/server/local-titles.ts +9 -12
- package/shared/chat.ts +5 -15
- package/shared/created.ts +13 -21
- package/shared/settings-nav.ts +14 -2
- package/shared/tool-result.ts +70 -0
package/client/dismiss.tsx
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { createContext, useContext, useEffect, useRef, useState, type ReactNode } from "react";
|
|
2
|
-
import { Platform, View, type StyleProp, type ViewProps, type ViewStyle } from "react-native";
|
|
1
|
+
import { createContext, useContext, useEffect, useRef, useState, useSyncExternalStore, type ReactNode } from "react";
|
|
2
|
+
import { AccessibilityInfo, Animated, Easing, Platform, View, type StyleProp, type ViewProps, type ViewStyle } from "react-native";
|
|
3
3
|
import { useRpc } from "@getpaseo/plugin/client";
|
|
4
4
|
import { Icon, useToast } from "@getpaseo/plugin/client/ui";
|
|
5
5
|
import { useQueryClient } from "@tanstack/react-query";
|
|
6
6
|
import { dismissRpc } from "../shared/contracts";
|
|
7
|
-
import { Pressable } from "./text";
|
|
8
|
-
import { focusRing, type Theme } from "./kit";
|
|
9
|
-
import {
|
|
7
|
+
import { Pressable, Text } from "./text";
|
|
8
|
+
import { focusRing, keyboardFocus, type Theme } from "./kit";
|
|
9
|
+
import { useReducedMotion } from "./motion";
|
|
10
|
+
import { isLight, readable, solidFor, tint, withAlpha } from "./theme";
|
|
10
11
|
import { liveBriefKey, overviewKey, workspaceKey } from "./keys";
|
|
11
12
|
import { hasToastHost, pushToast, runAction } from "./toast-store";
|
|
12
13
|
import type { InboxStore } from "./inbox-store";
|
|
@@ -21,12 +22,32 @@ import type { InboxStore } from "./inbox-store";
|
|
|
21
22
|
* On desktop it appears while the pointer is over its card or focus is inside it (RevealScope), and always on the card
|
|
22
23
|
* that is selected (Catch up's card, Home's detail pane: `DismissReveal` "always"). Hidden is opacity 0, never
|
|
23
24
|
* unmounted, so the card doesn't move when it appears and the keyboard and screen readers always reach it.
|
|
25
|
+
*
|
|
26
|
+
* Two clicks, in place (dismiss-takes-two-clicks-in-place): the first click (tap, Enter, Space, ⇧D in Catch up) arms the
|
|
27
|
+
* x: it turns into a small red-tinted "Dismiss" pill on the same spot (solid red under the pointer), growing leftward over what sits beside it, so the
|
|
28
|
+
* card never reflows. The second click on it dismisses. It disarms quietly on a click or tap anywhere else, Esc, focus
|
|
29
|
+
* leaving it, the pointer leaving its card (after a short grace), or DISMISS_ARM_MS untouched. Only one x is armed at a
|
|
30
|
+
* time, on every surface. No pop-up; Undo stays.
|
|
24
31
|
*/
|
|
25
32
|
|
|
26
33
|
/** As long as sign-off's Undo (6 s): the toast holds while the pointer or focus is on it. */
|
|
27
34
|
export const DISMISS_UNDO_MS = 6_000;
|
|
28
35
|
/** The x's tooltip and the second half of its accessibility label. */
|
|
29
36
|
export const DISMISS_HINT = "it no longer needs you, and the agent isn't messaged";
|
|
37
|
+
/** How long an armed x waits for its second click (paused while the pointer is on it). */
|
|
38
|
+
export const DISMISS_ARM_MS = 4_000;
|
|
39
|
+
/** How long the pointer may be off the armed x's card before it disarms (a wobble isn't leaving). */
|
|
40
|
+
export const DISMISS_LEAVE_GRACE_MS = 600;
|
|
41
|
+
/** What a screen reader hears when the x arms, and the armed x's tooltip. */
|
|
42
|
+
export const DISMISS_CONFIRM = "Press again to dismiss";
|
|
43
|
+
|
|
44
|
+
/** The one armed x, app-wide: arming another disarms this one. */
|
|
45
|
+
let armedX: object | null = null;
|
|
46
|
+
const armWatchers = new Set<() => void>();
|
|
47
|
+
const setArmed = (x: object | null) => { if (armedX === x) return; armedX = x; for (const f of armWatchers) f(); };
|
|
48
|
+
const watchArmed = (f: () => void) => { armWatchers.add(f); return () => { armWatchers.delete(f); }; };
|
|
49
|
+
/** Disarm whatever x is armed (a surface closing, a test resetting). */
|
|
50
|
+
export function disarmDismiss(): void { setArmed(null); }
|
|
30
51
|
|
|
31
52
|
export type DismissTarget = { workspaceId: string; key: string } | { agentId: string };
|
|
32
53
|
const targetKey = (t: DismissTarget) => "agentId" in t ? `agent:${t.agentId}` : `${t.workspaceId}:${t.key}`;
|
|
@@ -65,8 +86,12 @@ export function useDismiss(): (target: DismissTarget, options?: { onDismissed?:
|
|
|
65
86
|
/** "always": the card is the selected one (Catch up's card, Home's detail pane), so its x shows without hover. */
|
|
66
87
|
export const DismissReveal = createContext<"hover" | "always">("hover");
|
|
67
88
|
const Hovered = createContext<boolean>(false);
|
|
89
|
+
/** Whether the pointer is over the card (desktop web); null outside a RevealScope, where only the x itself knows. */
|
|
90
|
+
const PointerIn = createContext<boolean | null>(null);
|
|
68
91
|
|
|
69
|
-
type DomNode = {
|
|
92
|
+
type DomNode = { setAttribute?(k: string, v: string): void; contains?(other: unknown): boolean };
|
|
93
|
+
type Listen = { addEventListener?(type: string, f: (e: DomEvent) => void, capture?: boolean): void; removeEventListener?(type: string, f: (e: DomEvent) => void, capture?: boolean): void };
|
|
94
|
+
type DomEvent = { key?: string; target?: unknown; preventDefault?(): void; stopPropagation?(): void };
|
|
70
95
|
|
|
71
96
|
/**
|
|
72
97
|
* A card whose x shows while the pointer is over it or focus is inside it (desktop web). Native and phones draw the x
|
|
@@ -78,29 +103,105 @@ export function RevealScope({ children, style, ...rest }: { children: ReactNode;
|
|
|
78
103
|
// react-native-web forwards these to the DOM (as client/linked.tsx's hover does); React's onFocus/onBlur bubble, so
|
|
79
104
|
// focus anywhere inside the card counts. Native ignores them: the x is always shown there.
|
|
80
105
|
const web = Platform.OS === "web" ? { onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), onFocus: () => setFocused(true), onBlur: () => setFocused(false) } : {};
|
|
81
|
-
return <View style={style} {...rest} {...(web as object)}><Hovered.Provider value={hovered || focused}>{children}</Hovered.Provider></View>;
|
|
106
|
+
return <View style={style} {...rest} {...(web as object)}><PointerIn.Provider value={Platform.OS === "web" ? hovered : null}><Hovered.Provider value={hovered || focused}>{children}</Hovered.Provider></PointerIn.Provider></View>;
|
|
82
107
|
}
|
|
83
108
|
|
|
84
109
|
/**
|
|
85
110
|
* The small x. `label` names what it dismisses ("Dismiss Q3", "Dismiss #12 is approved"); the hint follows it. Quiet by
|
|
86
111
|
* design: the muted foreground at 14 px (16 on phones), no fill until hovered, never the size or colour of an action.
|
|
112
|
+
* Armed (the first click), it is a red "Dismiss" pill in the same place; the second click calls `onPress`.
|
|
87
113
|
*/
|
|
88
114
|
export function DismissX({ theme, compact, label, onPress, disabled = false }: { theme: Theme; compact: boolean; label: string; onPress: () => void; disabled?: boolean }) {
|
|
89
115
|
const c = theme.colors;
|
|
90
116
|
const reveal = useContext(DismissReveal);
|
|
91
117
|
const hovered = useContext(Hovered);
|
|
118
|
+
const pointerIn = useContext(PointerIn);
|
|
92
119
|
const [focused, setFocused] = useState(false);
|
|
120
|
+
const [over, setOver] = useState(false);
|
|
121
|
+
// Keyboard focus (focus-visible) holds the timeout too: someone who armed it with Enter and is hearing "Press again
|
|
122
|
+
// to dismiss" shouldn't lose it to a timer. A mouse click also focuses; that doesn't count.
|
|
123
|
+
const [keyed, setKeyed] = useState(false);
|
|
124
|
+
const reduced = useReducedMotion();
|
|
125
|
+
const fade = useRef(new Animated.Value(1)).current;
|
|
126
|
+
const me = useRef({}).current;
|
|
127
|
+
const armed = useSyncExternalStore(watchArmed, () => armedX === me, () => false);
|
|
128
|
+
const disarm = () => { if (armedX === me) setArmed(null); };
|
|
93
129
|
const touch = compact || Platform.OS !== "web";
|
|
94
|
-
const shown = touch || reveal === "always" || hovered || focused;
|
|
130
|
+
const shown = touch || reveal === "always" || hovered || focused || armed;
|
|
95
131
|
const tip = useRef<View>(null);
|
|
96
|
-
useEffect(() => { if (Platform.OS === "web") (tip.current as unknown as DomNode | null)?.setAttribute?.("title", `Dismiss: ${DISMISS_HINT}`); }, []);
|
|
132
|
+
useEffect(() => { if (Platform.OS === "web") (tip.current as unknown as DomNode | null)?.setAttribute?.("title", armed ? DISMISS_CONFIRM : `Dismiss: ${DISMISS_HINT}`); }, [armed]);
|
|
133
|
+
// Gone (dismissed, the card moved on) or disabled: never leave an armed x behind.
|
|
134
|
+
useEffect(() => () => disarm(), []);
|
|
135
|
+
useEffect(() => { if (disabled) disarm(); }, [disabled, armed]);
|
|
136
|
+
// The quiet timeout, paused while the pointer rests on the pill (someone about to click it).
|
|
137
|
+
useEffect(() => { if (!armed || over || keyed) return; const t = setTimeout(disarm, DISMISS_ARM_MS); return () => clearTimeout(t); }, [armed, over, keyed]);
|
|
138
|
+
// The pill fades in (140 ms, ease-out, opacity only) from the x; reduced motion swaps at once. Disarming is instant,
|
|
139
|
+
// and the second press never waits on it.
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (!armed) return;
|
|
142
|
+
if (reduced) { fade.setValue(1); return; }
|
|
143
|
+
fade.setValue(0);
|
|
144
|
+
Animated.timing(fade, { toValue: 1, duration: 140, easing: Easing.out(Easing.cubic), useNativeDriver: Platform.OS !== "web" }).start();
|
|
145
|
+
}, [armed, reduced]);
|
|
146
|
+
// The pointer leaving the card (it was in, now it isn't) disarms after a grace; coming back keeps it armed.
|
|
147
|
+
const wasIn = useRef(pointerIn);
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
const left = wasIn.current === true && pointerIn === false;
|
|
150
|
+
wasIn.current = pointerIn;
|
|
151
|
+
if (!armed || !left) return;
|
|
152
|
+
const t = setTimeout(disarm, DISMISS_LEAVE_GRACE_MS);
|
|
153
|
+
return () => clearTimeout(t);
|
|
154
|
+
}, [armed, pointerIn]);
|
|
155
|
+
// Web: a click or tap anywhere but this x, or Esc, disarms. Esc is taken (capture, before Catch up's keys and the
|
|
156
|
+
// host's interrupt): pressing it here only disarms.
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
if (!armed) return;
|
|
159
|
+
const g = globalThis as unknown as Listen & { document?: Listen };
|
|
160
|
+
const doc = g.document;
|
|
161
|
+
if (typeof doc?.addEventListener !== "function" || typeof g.addEventListener !== "function") return;
|
|
162
|
+
const onDown = (e: DomEvent) => { if (!(tip.current as unknown as DomNode | null)?.contains?.(e.target)) disarm(); };
|
|
163
|
+
const onKey = (e: DomEvent) => { if (e.key !== "Escape") return; e.preventDefault?.(); e.stopPropagation?.(); disarm(); };
|
|
164
|
+
doc.addEventListener("pointerdown", onDown, true);
|
|
165
|
+
g.addEventListener("keydown", onKey, true);
|
|
166
|
+
return () => { doc.removeEventListener?.("pointerdown", onDown, true); g.removeEventListener?.("keydown", onKey, true); };
|
|
167
|
+
}, [armed]);
|
|
168
|
+
const press = () => {
|
|
169
|
+
if (armed) { disarm(); onPress(); return; }
|
|
170
|
+
setArmed(me);
|
|
171
|
+
AccessibilityInfo.announceForAccessibility?.(DISMISS_CONFIRM);
|
|
172
|
+
};
|
|
97
173
|
// Phones: a real 40 px box (react-native-web ignores hitSlop) pulled in by 6 px each side, so it lays out as 28 px;
|
|
98
174
|
// native also gets 4 px of hitSlop, a 48 px target. The glyph stays small and muted.
|
|
99
175
|
const box = touch ? 40 : 22;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
176
|
+
// Armed: wider by the pill, and the extra width is taken back with a negative left margin, so it lays out exactly as
|
|
177
|
+
// the x did: nothing beside it moves, the pill draws over it (solid, so what's under it doesn't show through).
|
|
178
|
+
// Desktop's pill keeps a 3 px inset on the right. Phones: a 24 px pill in the same 40 px box, so the target stays and
|
|
179
|
+
// the weight doesn't outgrow the card's own age and chips.
|
|
180
|
+
const wide = touch ? 80 : 69;
|
|
181
|
+
const pull = touch ? -6 : 0;
|
|
182
|
+
return <Pressable ref={tip} accessibilityRole="button" accessibilityLabel={armed ? `${label}. ${DISMISS_CONFIRM}` : `${label}: ${DISMISS_HINT}`} disabled={disabled} onPress={press}
|
|
183
|
+
hitSlop={4} onFocus={() => { setFocused(true); setKeyed(Platform.OS === "web" && keyboardFocus()); }} onBlur={() => { setFocused(false); setKeyed(false); disarm(); }} onHoverIn={() => setOver(true)} onHoverOut={() => setOver(false)}
|
|
184
|
+
style={(state: { hovered?: boolean; pressed: boolean; focused?: boolean }) => armed
|
|
185
|
+
? { ...focusRing(state.focused, c), width: wide, height: box, margin: pull, marginLeft: pull - (wide - box), borderRadius: box / 2, alignItems: "stretch", justifyContent: "center", zIndex: 1 }
|
|
186
|
+
: { ...focusRing(state.focused, c), width: box, height: box, margin: pull, borderRadius: box / 2, alignItems: "center", justifyContent: "center",
|
|
187
|
+
opacity: shown ? (disabled ? 0.4 : 1) : 0, backgroundColor: state.pressed ? c.surface2 : state.hovered ? withAlpha(c.foreground, 0.06) : "transparent" }}>
|
|
188
|
+
{state => {
|
|
189
|
+
const hot = state.pressed || !!(state as { hovered?: boolean }).hovered;
|
|
190
|
+
// Web screen readers: react-native-web's announceForAccessibility is a no-op, so a polite live region (always
|
|
191
|
+
// mounted, empty until armed) says it. Native announces through AccessibilityInfo above.
|
|
192
|
+
const live = Platform.OS === "web" ? <Text accessibilityLiveRegion="polite" style={{ position: "absolute", width: 1, height: 1, overflow: "hidden", opacity: 0 }}>{armed ? DISMISS_CONFIRM : ""}</Text> : null;
|
|
193
|
+
if (!armed) return <>{live}<Icon name="X" size={touch ? 16 : 14} color={hot ? c.foreground : c.foregroundMuted} /></>;
|
|
194
|
+
// Armed at rest: a danger tint with danger ink and a hairline, over the page ground so what it covers doesn't show
|
|
195
|
+
// through. It goes solid (white on deepened danger) only under the pointer or finger, the moment it acts. Red,
|
|
196
|
+
// quietly: Dismiss is undoable, and a solid red pill at rest read as a new blocker on an amber card.
|
|
197
|
+
const ink = isLight(c) ? solidFor(c.statusDanger) : readable(c.statusDanger, c);
|
|
198
|
+
return <>{live}<Animated.View style={{ opacity: fade, height: touch ? 24 : 22, marginLeft: touch ? 6 : 0, marginRight: touch ? 6 : 3, borderRadius: touch ? 12 : 11, overflow: "hidden", backgroundColor: c.surface0 }}>
|
|
199
|
+
<View style={{ flex: 1, borderRadius: touch ? 12 : 11, borderWidth: 1, alignItems: "center", justifyContent: "center",
|
|
200
|
+
borderColor: hot ? "transparent" : withAlpha(c.statusDanger, 0.35),
|
|
201
|
+
backgroundColor: hot ? solidFor(c.statusDanger, state.pressed ? 0.82 : 1) : tint(c.statusDanger, c) }}>
|
|
202
|
+
<Text numberOfLines={1} style={{ color: hot ? "#ffffff" : ink, fontSize: 12, lineHeight: 14, fontWeight: "600" }}>Dismiss</Text>
|
|
203
|
+
</View>
|
|
204
|
+
</Animated.View></>;
|
|
205
|
+
}}
|
|
105
206
|
</Pressable>;
|
|
106
207
|
}
|
package/client/header.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import type { SettingsCategory } from "../shared/settings-nav";
|
|
2
3
|
import { View } from "react-native";
|
|
3
4
|
import { Pressable, Text } from "./text";
|
|
4
5
|
import { Icon } from "@getpaseo/plugin/client/ui";
|
|
@@ -47,7 +48,7 @@ function LiveGlyph({ icon, colors }: { icon: LiveIcon; colors: Colors }) {
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
export function WorkspaceHeader({ workspace: w, theme, compact, now, onSettings, onRefresh, refreshing, onAuto, autoPending, notice, onOpenPr, resize, hideTitle = false, onHome, more }: {
|
|
50
|
-
workspace: Workspace; theme: Theme; compact: boolean; now: number; onSettings: () => void; onRefresh: () => void; refreshing: boolean; onAuto: (next: boolean) => void; autoPending: boolean; notice: string | null; onOpenPr?: (key: string) => void;
|
|
51
|
+
workspace: Workspace; theme: Theme; compact: boolean; now: number; onSettings: (category?: SettingsCategory) => void; onRefresh: () => void; refreshing: boolean; onAuto: (next: boolean) => void; autoPending: boolean; notice: string | null; onOpenPr?: (key: string) => void;
|
|
51
52
|
/** Expand to the larger view, or collapse back to the panel. Absent where the panel is already as wide as it gets. */
|
|
52
53
|
resize?: { icon: "Maximize2" | "Minimize2"; label: string; onPress: () => void } | null;
|
|
53
54
|
/** The larger view's screen bar already names the workspace. */
|
|
@@ -67,7 +68,7 @@ export function WorkspaceHeader({ workspace: w, theme, compact, now, onSettings,
|
|
|
67
68
|
const controls = <View style={{ flexDirection: "row", alignItems: "center", gap: 2, marginVertical: compact ? -12 : -4, marginRight: compact ? -10 : -4 }}>
|
|
68
69
|
{resize && <IconButton icon={resize.icon} label={resize.label} onPress={resize.onPress} theme={theme} compact={compact} />}
|
|
69
70
|
{more}
|
|
70
|
-
<IconButton icon="Settings" label="Follow-up settings" onPress={onSettings} theme={theme} compact={compact} />
|
|
71
|
+
<IconButton icon="Settings" label="Follow-up settings" onPress={() => onSettings()} theme={theme} compact={compact} />
|
|
71
72
|
</View>;
|
|
72
73
|
const tail = <>
|
|
73
74
|
<View style={{ flexDirection: "row", gap: 6, marginTop: 2 }}>
|
package/client/needs-you.tsx
CHANGED
|
@@ -180,7 +180,8 @@ export function NeedsYouList({ workspace: w, theme, compact, actions, now = Date
|
|
|
180
180
|
</View>
|
|
181
181
|
<View style={item.kind === "reviewers" ? { alignSelf: "flex-start" } : undefined}>{pair ?? button}</View>
|
|
182
182
|
{/* Top right, a step away from the action so a thumb aimed at it doesn't land here. */}
|
|
183
|
-
|
|
183
|
+
{/* Flush (Catch up's bordered card): no pull to the edge, so the armed Dismiss pill keeps clear of the border. */}
|
|
184
|
+
<View style={{ alignSelf: "flex-start", marginTop: -4, marginRight: flush ? 0 : -6, marginLeft: 2 }}>{x}</View>
|
|
184
185
|
</RevealScope>
|
|
185
186
|
</CardRow>;
|
|
186
187
|
return <CardRow key={item.key} theme={theme} compact={compact} first={index === 0 && flush} style={flush ? { paddingHorizontal: 0 } : undefined}>
|
|
@@ -198,7 +199,7 @@ export function NeedsYouList({ workspace: w, theme, compact, actions, now = Date
|
|
|
198
199
|
</View>}
|
|
199
200
|
{notice}
|
|
200
201
|
</View>
|
|
201
|
-
<View style={{ marginTop: -3, marginRight: -5 }}>{x}</View>
|
|
202
|
+
<View style={{ marginTop: -3, marginRight: flush ? 2 : -5 }}>{x}</View>
|
|
202
203
|
</RevealScope>
|
|
203
204
|
</CardRow>;
|
|
204
205
|
})}
|
package/client/panel.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect, useState, type ReactNode } from "react";
|
|
2
|
+
import type { SettingsCategory } from "../shared/settings-nav";
|
|
2
3
|
import { recoveryActions } from "./recovery-actions";
|
|
3
4
|
import { View } from "react-native";
|
|
4
5
|
import { Text } from "./text";
|
|
@@ -42,7 +43,7 @@ import { ToastHost, useQuestionOpener } from "./toasts";
|
|
|
42
43
|
|
|
43
44
|
export { overviewKey, workspaceKey };
|
|
44
45
|
|
|
45
|
-
export type PanelLinks = { openSettings: () => void; openOverview: () => void; openLarge?: (workspaceId: string) => void };
|
|
46
|
+
export type PanelLinks = { openSettings: (category?: SettingsCategory) => void; openOverview: () => void; openLarge?: (workspaceId: string) => void };
|
|
46
47
|
type PanelProps = PluginWorkspacePanelProps & PanelLinks & { inbox?: InboxStore; live?: LiveStore; briefDeps?: BriefDeps; sources?: HomeSources };
|
|
47
48
|
|
|
48
49
|
/**
|
|
@@ -127,19 +128,19 @@ function NothingYet({ theme, layout, loadError, openOverview, openSettings }: Pa
|
|
|
127
128
|
</View>)}
|
|
128
129
|
</View>
|
|
129
130
|
{loadError && <Text accessibilityRole="alert" style={[tp.meta, { color: c.statusDanger }]}>{loadError}</Text>}
|
|
130
|
-
<View style={{ flexDirection: "row" }}><Button theme={theme} compact kind="secondary" icon="Settings" title="Project settings" accessibilityHint="Choose which projects Follow-up tracks" onPress={openSettings} /></View>
|
|
131
|
+
<View style={{ flexDirection: "row" }}><Button theme={theme} compact kind="secondary" icon="Settings" title="Project settings" accessibilityHint="Choose which projects Follow-up tracks" onPress={() => openSettings("following")} /></View>
|
|
131
132
|
</ScrollView>
|
|
132
133
|
</View>;
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
/** The panel's top bar: back to Home, and settings. No other workspace's counts. */
|
|
136
|
-
export function PanelTop({ theme, compact, openOverview, openSettings }: { theme: Theme; compact: boolean; openOverview: () => void; openSettings?: () => void }) {
|
|
137
|
+
export function PanelTop({ theme, compact, openOverview, openSettings }: { theme: Theme; compact: boolean; openOverview: () => void; openSettings?: (category?: SettingsCategory) => void }) {
|
|
137
138
|
const c = theme.colors;
|
|
138
139
|
return <View style={{ flexDirection: "row", alignItems: "center", gap: 6, paddingHorizontal: compact ? 12 : 8, paddingVertical: 6, borderBottomWidth: 1, borderBottomColor: c.border }}>
|
|
139
140
|
<Button theme={theme} compact={compact} kind="ghost" icon="House" title="Home" accessibilityHint="Opens Follow-up Home with every workspace" onPress={openOverview} />
|
|
140
141
|
<View style={{ flex: 1 }} />
|
|
141
142
|
{openSettings && <VersionMark theme={theme} touch={compact} openSettings={openSettings} />}
|
|
142
|
-
{openSettings && <IconButton icon="Settings" label="Follow-up settings" onPress={openSettings} theme={theme} compact={compact} />}
|
|
143
|
+
{openSettings && <IconButton icon="Settings" label="Follow-up settings" onPress={() => openSettings()} theme={theme} compact={compact} />}
|
|
143
144
|
</View>;
|
|
144
145
|
}
|
|
145
146
|
|
|
@@ -342,7 +343,7 @@ const folds = z.object({ open: z.array(z.string()) });
|
|
|
342
343
|
export const WIDE_MIN = 820;
|
|
343
344
|
|
|
344
345
|
export function WorkspaceView({ theme, layout, workspace: w, navigation, loadError, openSettings, openOverview, folds: { isOpen, toggle }, resize, large = false, top, ask, sources }: PluginHostProps & {
|
|
345
|
-
navigation?: PluginWorkspacePanelProps["navigation"]; workspace: Workspace; loadError?: string | null; openSettings: () => void; openOverview: () => void; top?: ReactNode; /** The main agent's open brief and its card, for the Needs you block. */ ask?: { brief: Brief; card: ReactNode } | null;
|
|
346
|
+
navigation?: PluginWorkspacePanelProps["navigation"]; workspace: Workspace; loadError?: string | null; openSettings: (category?: SettingsCategory) => void; openOverview: () => void; top?: ReactNode; /** The main agent's open brief and its card, for the Needs you block. */ ask?: { brief: Brief; card: ReactNode } | null;
|
|
346
347
|
folds: Folds; resize: { icon: "Maximize2" | "Minimize2"; label: string; onPress: () => void } | null; large?: boolean;
|
|
347
348
|
/** Home's sources: the header's More menu (the row menu). Absent in the larger view. */
|
|
348
349
|
sources?: HomeSources;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createElement, type ComponentType } from "react";
|
|
2
|
+
import type { PluginClientContext, PluginSurfaceProps } from "@getpaseo/plugin/client";
|
|
3
|
+
import { FOLLOW_UP_ICON } from "./follow-up-icon";
|
|
4
|
+
import { SETTINGS_CATEGORIES, deviceStorage, isCategory, readCategory, writeCategory, type KeyValue, type SettingsCategory } from "../shared/settings-nav";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Where Follow-up's settings live in Paseo's Settings (`settings-link-lands-on-its-category`).
|
|
8
|
+
*
|
|
9
|
+
* Paseo 0.16 draws a plugin's settings screens as one native tab strip on the plugin's page (the app's
|
|
10
|
+
* plugins/settings/index.tsx `SettingsTabs`, unchanged in 0.17.0-beta.1), so there each category is its own screen
|
|
11
|
+
* and Follow-up draws no tabs of its own. Paseo 0.15 lists every settings screen as its own row in the plugin's •••
|
|
12
|
+
* menu, so there it keeps one screen, "Follow-up", with its own tabs (`FollowSettings` without a category).
|
|
13
|
+
*
|
|
14
|
+
* General keeps the old screen id, so a saved link or restored route to it lands on the first tab. Every link into
|
|
15
|
+
* settings goes through `open(category)`: it remembers the category and opens the screen that shows it; with no
|
|
16
|
+
* category it reopens the last one this device showed.
|
|
17
|
+
*/
|
|
18
|
+
export const SETTINGS_SCREEN = "projects";
|
|
19
|
+
const screenId = (category: SettingsCategory) => category === "general" ? SETTINGS_SCREEN : category;
|
|
20
|
+
|
|
21
|
+
/** The 0.16 app's client API (feeds, sidebar views): fixed for the app's lifetime. */
|
|
22
|
+
export const hasNativeSettingsTabs = (client: object) => {
|
|
23
|
+
const c = client as { subscribe?: unknown; addSidebarView?: unknown };
|
|
24
|
+
return typeof c.subscribe === "function" && typeof c.addSidebarView === "function";
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type SettingsScreenComponent = ComponentType<PluginSurfaceProps & { category?: SettingsCategory }>;
|
|
28
|
+
|
|
29
|
+
export function createSettings(client: Pick<PluginClientContext, "addSettingsScreen" | "openSettings">, Screen: SettingsScreenComponent, store: KeyValue = deviceStorage) {
|
|
30
|
+
const native = hasNativeSettingsTabs(client);
|
|
31
|
+
const removers = native
|
|
32
|
+
? SETTINGS_CATEGORIES.map(cat => client.addSettingsScreen({ id: screenId(cat.id), title: cat.title, icon: cat.icon,
|
|
33
|
+
Component: (props: PluginSurfaceProps) => createElement(Screen, { ...props, category: cat.id }) }))
|
|
34
|
+
: [client.addSettingsScreen({ id: SETTINGS_SCREEN, title: "Follow-up", icon: FOLLOW_UP_ICON, Component: (props: PluginSurfaceProps) => createElement(Screen, props) })];
|
|
35
|
+
/** `category` may be anything a caller passes (a press event too): only a known category counts. */
|
|
36
|
+
const open = (category?: unknown) => {
|
|
37
|
+
if (isCategory(category)) writeCategory(category, store);
|
|
38
|
+
client.openSettings(native ? screenId(readCategory(store)) : SETTINGS_SCREEN);
|
|
39
|
+
};
|
|
40
|
+
return { native, open, remove: () => { for (const r of removers) r(); } };
|
|
41
|
+
}
|
package/client/settings.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
2
|
import { useViewSync, useViewVersion } from "./view-store";
|
|
3
3
|
import { ActivityIndicator, TextInput, View } from "react-native";
|
|
4
4
|
import { Pressable, Text } from "./text";
|
|
@@ -226,16 +226,22 @@ function useSummaries(): Partial<Record<SettingsCategory, string | null>> {
|
|
|
226
226
|
* on this device. Phone: the category list, drilling in with a back row. Only the open category mounts, so only its
|
|
227
227
|
* data loads.
|
|
228
228
|
*/
|
|
229
|
+
const REVIEWERS_INFO = "Who Add reviewers asks on a PR: a list per repository, or the default for every repository without one. A login is a GitHub user (octocat) or a team (org/team). Teammates each keep their own lists.";
|
|
230
|
+
|
|
229
231
|
/** Settings → General → Help → Report a bug. */
|
|
230
232
|
export const REPORT_HINT = "Or an idea or feedback. An agent writes it up and shows you the issue before filing it.";
|
|
231
233
|
|
|
232
|
-
export function FollowSettings({ theme, layout, openSetup, openReport }: PluginSurfaceProps & { openSetup?: (resume?: boolean) => void; openReport?: () => void
|
|
234
|
+
export function FollowSettings({ theme, layout, openSetup, openReport, category: only }: PluginSurfaceProps & { openSetup?: (resume?: boolean) => void; openReport?: () => void;
|
|
235
|
+
/** Paseo 0.16: this screen is one category, and Paseo's own tabs switch between them (client/settings-screens.ts). */
|
|
236
|
+
category?: SettingsCategory }) {
|
|
233
237
|
const compact = layout.compact;
|
|
234
238
|
const c = theme.colors; const t = text(c, compact);
|
|
235
239
|
// The category comes from device storage on every render, so the first paint is the localStorage cache and the
|
|
236
240
|
// device document takes over when it loads, never the default in between.
|
|
237
241
|
useViewSync(); useViewVersion();
|
|
238
|
-
const category = readCategory();
|
|
242
|
+
const category = only ?? readCategory();
|
|
243
|
+
// A category screen remembers itself, so "Follow-up: settings" and the gear reopen the tab last shown on this device.
|
|
244
|
+
useEffect(() => { if (only && readCategory() !== only) writeCategory(only); }, [only]);
|
|
239
245
|
// The phone reopens in the last category, like desktop; before any pick it starts on the list. Until the developer
|
|
240
246
|
// drills in or out, that follows storage too (the phone's document loads after the first paint).
|
|
241
247
|
const [chosen, setDrilled] = useState<boolean | null>(null);
|
|
@@ -248,14 +254,28 @@ export function FollowSettings({ theme, layout, openSetup, openReport }: PluginS
|
|
|
248
254
|
const setup = openSetup ? { entry, open: () => openSetup(entry.resume) } : undefined;
|
|
249
255
|
const content = category === "general" ? <GeneralCategory theme={theme} compact={compact} setup={setup} openReport={openReport} />
|
|
250
256
|
: category === "following" ? <FollowingCategory theme={theme} compact={compact} />
|
|
251
|
-
|
|
252
|
-
|
|
257
|
+
// Under Paseo's tabs, Reviewers is a titled section like every other category, its explanation in the info tip.
|
|
258
|
+
: category === "reviewers" ? only ? <SettingsSection title="Reviewer lists" info={REVIEWERS_INFO}><ReviewerSettings theme={theme} compact={compact} /></SettingsSection>
|
|
259
|
+
: <View style={{ gap: 8 }}>
|
|
260
|
+
<Text style={t.meta}>{REVIEWERS_INFO}</Text>
|
|
253
261
|
<ReviewerSettings theme={theme} compact={compact} />
|
|
254
262
|
</View>
|
|
255
263
|
: category === "agents" ? <AgentsCategory theme={theme} compact={compact} />
|
|
256
264
|
: <DisplaySections theme={theme} />;
|
|
257
265
|
// Phones: the shared gutter and the bottom inset (the gesture bar), like every other Follow-up surface.
|
|
258
266
|
const page = { padding: compact ? space(true).gutter : 24, gap: 18, maxWidth: 720, width: "100%" as const, alignSelf: "center" as const, paddingBottom: 40 };
|
|
267
|
+
const line = summaries[category];
|
|
268
|
+
// General's status card and the Agents card header say it already; their lines are for the phone list.
|
|
269
|
+
// Reviewers' card says its own state, so under Paseo's tabs it has no line of its own.
|
|
270
|
+
const lead = line && category !== "general" && category !== "agents" && !(only && category === "reviewers") ? <Text style={[t.meta, !only && !compact ? { marginTop: -6 } : null]}>{line}</Text> : null;
|
|
271
|
+
// One category under Paseo's own tabs: no tabs, list or back row of Follow-up's own, and no column or gutter of its
|
|
272
|
+
// own either. Paseo's plugin page scrolls and sets the width, so the category lines up with its tabs. The line sits
|
|
273
|
+
// on the section titles' inset at a readable measure, and a section's worth of space parts the last card from
|
|
274
|
+
// Paseo's own Details below.
|
|
275
|
+
if (only) return <View style={{ gap: 18, paddingTop: 12, paddingBottom: 40 }}>
|
|
276
|
+
{lead && <View style={{ paddingHorizontal: 5, maxWidth: 680 }}>{lead}</View>}
|
|
277
|
+
{content}
|
|
278
|
+
</View>;
|
|
259
279
|
// The host's header sits right above: no extra top space on a phone.
|
|
260
280
|
if (compact) return <ScrollView style={{ flex: 1, backgroundColor: c.surface0 }} contentContainerStyle={{ ...page, paddingTop: 4, ...bottomInset(true, 28) }}>
|
|
261
281
|
{drilled ? <>
|
|
@@ -263,11 +283,9 @@ export function FollowSettings({ theme, layout, openSetup, openReport }: PluginS
|
|
|
263
283
|
{content}
|
|
264
284
|
</> : <CategoryList summaries={summaries} theme={theme} onOpen={id => { pick(id); setDrilled(true); }} />}
|
|
265
285
|
</ScrollView>;
|
|
266
|
-
const line = summaries[category];
|
|
267
286
|
return <ScrollView style={{ flex: 1, backgroundColor: c.surface0 }} stickyHeaderIndices={[0]} contentContainerStyle={{ ...page, paddingTop: 0 }}>
|
|
268
287
|
<View style={{ paddingTop: 24, backgroundColor: c.surface0 }}><CategoryTabs value={category} onChange={pick} theme={theme} /></View>
|
|
269
|
-
{
|
|
270
|
-
{line && category !== "general" && category !== "agents" ? <Text style={[t.meta, { marginTop: -6 }]}>{line}</Text> : null}
|
|
288
|
+
{lead}
|
|
271
289
|
{content}
|
|
272
290
|
</ScrollView>;
|
|
273
291
|
}
|
package/client/theme.ts
CHANGED
|
@@ -41,6 +41,18 @@ export function readable(color: string, colors: Colors): string {
|
|
|
41
41
|
return color;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* A status hue as a solid fill under white text: darkened until white reads on it (4.5:1), then by `shade` (hover
|
|
46
|
+
* 0.9, pressed 0.82). Dark hosts' danger red is a light text red; as a fill it is deepened, light hosts' red already passes.
|
|
47
|
+
*/
|
|
48
|
+
export function solidFor(color: string, shade = 1): string {
|
|
49
|
+
const rgb = channels(color);
|
|
50
|
+
if (!rgb) return color;
|
|
51
|
+
let k = 1;
|
|
52
|
+
while (k > 0.3 && 1.05 / (luminance(rgb.map(v => v * k)) + 0.05) < 4.5) k -= 0.02;
|
|
53
|
+
return `rgb(${rgb.map(v => Math.round(v * k * shade)).join(", ")})`;
|
|
54
|
+
}
|
|
55
|
+
|
|
44
56
|
export function withAlpha(color: string, alpha: number): string {
|
|
45
57
|
const rgb = channels(color);
|
|
46
58
|
return rgb ? `rgba(${rgb.join(", ")}, ${alpha})` : color;
|
package/client/updates.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
|
7
7
|
import { dismissUpdateNoticeRpc, installUpdateRpc, retryMoveRpc, setUpdatesRpc, updatesRpc } from "../shared/contracts";
|
|
8
8
|
import { moveLine } from "../shared/plugin-move";
|
|
9
9
|
import { MODE_HINT, MODE_LABEL, UPDATE_MODES, WHATS_NEW_LABEL, channelHint, checkedText, copyCommand, statusCopy, versionMark, whatsNewHint, type StatusAction, type UpdateMode, type UpdatesChange, type UpdatesView } from "../shared/updates";
|
|
10
|
-
import {
|
|
10
|
+
import type { SettingsCategory } from "../shared/settings-nav";
|
|
11
11
|
import type { Channel } from "../shared/version";
|
|
12
12
|
import { Button, errorText, space, text, useNow, type Theme } from "./kit";
|
|
13
13
|
import { Spinner } from "./motion";
|
|
@@ -28,7 +28,7 @@ export function useUpdates(check?: "settings") {
|
|
|
28
28
|
|
|
29
29
|
const toneColor = (tone: "success" | "warning" | "muted", c: Theme["colors"]) => tone === "success" ? c.statusSuccess : tone === "warning" ? c.statusWarning : c.foregroundMuted;
|
|
30
30
|
/** Home's top line: an update to install (Tell me mode) or a rollback. One slot; the rollback wins. */
|
|
31
|
-
export function UpdateNotice({ theme, compact, openSettings }: { theme: Theme; compact: boolean; openSettings: () => void }) {
|
|
31
|
+
export function UpdateNotice({ theme, compact, openSettings }: { theme: Theme; compact: boolean; openSettings: (category?: SettingsCategory) => void }) {
|
|
32
32
|
const c = theme.colors; const t = text(c);
|
|
33
33
|
const query = useUpdates(); const cache = useQueryClient(); const toast = useToast();
|
|
34
34
|
const dismiss = useRpc(dismissUpdateNoticeRpc); const install = useRpc(installUpdateRpc);
|
|
@@ -53,7 +53,7 @@ export function UpdateNotice({ theme, compact, openSettings }: { theme: Theme; c
|
|
|
53
53
|
</Pressable>
|
|
54
54
|
</View>
|
|
55
55
|
<View style={{ flexDirection: "row", gap: 8, paddingLeft: 25 }}>
|
|
56
|
-
{rolled ? <Button title="Details" theme={theme} compact={compact} onPress={() =>
|
|
56
|
+
{rolled ? <Button title="Details" theme={theme} compact={compact} onPress={() => openSettings("general")} />
|
|
57
57
|
: confirm ? <>
|
|
58
58
|
<Button title="Install now" theme={theme} compact={compact} loading={run.isPending} onPress={() => run.mutate(() => install({ version: n.version, anyway: true }))} />
|
|
59
59
|
<Button title="Cancel" kind="ghost" theme={theme} compact={compact} onPress={() => setConfirm(false)} />
|
|
@@ -212,7 +212,7 @@ export function UpdatesStep({ theme, compact }: { theme: Theme; compact: boolean
|
|
|
212
212
|
* accessibility label still says it. Loading takes no width; a failed read shows nothing. `touch`: a 44pt box
|
|
213
213
|
* (react-native-web ignores hitSlop).
|
|
214
214
|
*/
|
|
215
|
-
export function VersionMark({ theme, touch, openSettings }: { theme: Theme; touch: boolean; openSettings: () => void }) {
|
|
215
|
+
export function VersionMark({ theme, touch, openSettings }: { theme: Theme; touch: boolean; openSettings: (category?: SettingsCategory) => void }) {
|
|
216
216
|
const c = theme.colors; const t = text(c, touch);
|
|
217
217
|
const query = useUpdates();
|
|
218
218
|
if (!query.data) return null;
|
|
@@ -220,7 +220,7 @@ export function VersionMark({ theme, touch, openSettings }: { theme: Theme; touc
|
|
|
220
220
|
const style = touch ? t.meta : t.small;
|
|
221
221
|
const box = touch ? { minHeight: 44, paddingHorizontal: 10, justifyContent: "center" as const } : { paddingHorizontal: 4, paddingVertical: 4 };
|
|
222
222
|
return <Pressable accessibilityRole="button" accessibilityLabel={mark.label} accessibilityHint="Opens Follow-up settings, General" hitSlop={touch ? undefined : 8}
|
|
223
|
-
onPress={() =>
|
|
223
|
+
onPress={() => openSettings("general")} style={[box, { flexShrink: 1, minWidth: 0 }]}>
|
|
224
224
|
{state => { const hover = !!(state as { hovered?: boolean }).hovered || state.pressed; const line = hover ? { color: c.foreground, textDecorationLine: "underline" as const } : null;
|
|
225
225
|
return <Text numberOfLines={1} style={[style, line]}>{mark.version}</Text>; }}
|
|
226
226
|
</Pressable>;
|
package/index.client.tsx
CHANGED
|
@@ -26,7 +26,8 @@ import { inboxSidebarView, sidebarViewHost } from "./client/sidebar-view";
|
|
|
26
26
|
import { OVERSEER_KEY } from "./client/home-list";
|
|
27
27
|
import { contributeBrief } from "./client/brief";
|
|
28
28
|
import { clientTimeZoneRpc, setOnboardingRpc } from "./shared/contracts";
|
|
29
|
-
import {
|
|
29
|
+
import { createSettings } from "./client/settings-screens";
|
|
30
|
+
import type { SettingsCategory } from "./shared/settings-nav";
|
|
30
31
|
import { openReportSheet, ReportSheetHost, setReportFallback } from "./client/report-issue";
|
|
31
32
|
import { openRename, RenameHost } from "./client/rename";
|
|
32
33
|
import { setReportError } from "./client/toast-store";
|
|
@@ -54,7 +55,6 @@ export default function contribute(host: PluginClientContext) {
|
|
|
54
55
|
.catch(() => { if (attempt < 4) setTimeout(() => reportTimeZone(attempt + 1), [5_000, 30_000, 120_000, 600_000][attempt]); });
|
|
55
56
|
};
|
|
56
57
|
reportTimeZone();
|
|
57
|
-
const openSettings = (category?: string) => { if (isCategory(category)) writeCategory(category); client.openSettings("projects"); };
|
|
58
58
|
const openOverview = () => client.openScreen({ screenId: OVERVIEW });
|
|
59
59
|
const openLog = () => client.openScreen({ screenId: OVERVIEW, params: { view: "log" } });
|
|
60
60
|
const openCatchUp = () => client.openScreen({ screenId: OVERVIEW, params: { view: "catchup", at: "0", n: String(Date.now()) } });
|
|
@@ -67,7 +67,10 @@ export default function contribute(host: PluginClientContext) {
|
|
|
67
67
|
setReportFallback(() => client.openScreen({ screenId: OVERVIEW }));
|
|
68
68
|
setReportError((message, at) => openReportSheet({ kind: "bug", error: message, at }));
|
|
69
69
|
const reportHost = (props: PluginSurfaceProps | PluginWorkspacePanelProps) => <><ReportSheetHost theme={props.theme} layout={props.layout} openAgent={props.navigation ? agentId => props.navigation!.openAgent({ agentId }) : undefined} /><RenameHost theme={props.theme} compact={props.layout.compact} /></>;
|
|
70
|
-
const Settings = (props: PluginSurfaceProps) => <><FollowSettings {...props} openSetup={openSetup} openReport={() => openReportSheet()} />{reportHost(props)}</>;
|
|
70
|
+
const Settings = (props: PluginSurfaceProps & { category?: SettingsCategory }) => <><FollowSettings {...props} openSetup={openSetup} openReport={() => openReportSheet()} />{reportHost(props)}</>;
|
|
71
|
+
// Paseo 0.16: one settings screen per category (its own tabs); 0.15: one screen with Follow-up's tabs (client/settings-screens.ts).
|
|
72
|
+
const settings = createSettings(client, Settings);
|
|
73
|
+
const openSettings = settings.open;
|
|
71
74
|
const store = createLiveStore(client);
|
|
72
75
|
const inbox = createInboxStore(host);
|
|
73
76
|
// A brief's x (client/dismiss.tsx) updates the inbox rows at once, like Sign off.
|
|
@@ -107,7 +110,7 @@ export default function contribute(host: PluginClientContext) {
|
|
|
107
110
|
client.addScreen({ id: OVERVIEW, title: "Follow-up", Component: Overview }),
|
|
108
111
|
client.addScreen({ id: LARGE_SCREEN, title: params => store.get(params.workspaceId ?? "")?.title ?? "Follow-up", Component: Large }),
|
|
109
112
|
...LEGACY_SETTINGS_SCREENS.map(id => client.addScreen({ id, title: "Follow-up settings", Component: Settings })),
|
|
110
|
-
|
|
113
|
+
settings.remove,
|
|
111
114
|
client.addWorkspacePanel({ id: PANEL, title: "Follow-up", icon: FOLLOW_UP_ICON, locations: ["workspace", "explorer"], Component: Panel }),
|
|
112
115
|
client.addCommandCenterItem({ id: "open-follow-up", title: "Follow-up: open for this workspace", icon: FOLLOW_UP_ICON, keywords: ["PR", "stack", "repairs", "done", "archive"], context: "workspace", onSelect({ openPanel }) { openPanel(PANEL, { location: location() }); } }),
|
|
113
116
|
client.addCommandCenterItem({ id: "open-follow-up-large", title: "Follow-up: open the larger view", icon: "Maximize2", keywords: ["expand", "full screen", "maximize", "PR", "stack"], context: "workspace", onSelect({ workspace, openScreen }) { openScreen({ screenId: LARGE_SCREEN, params: { workspaceId: workspace.id } }); } }),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paseo-follow-up",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.3.0-beta.
|
|
4
|
+
"version": "2.3.0-beta.4",
|
|
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/local-titles.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { constants } from "node:fs";
|
|
2
2
|
import { open } from "node:fs/promises";
|
|
3
3
|
import { isClaudeArtifact } from "../shared/spec";
|
|
4
|
+
import { toolResult } from "../shared/tool-result";
|
|
4
5
|
import { receiptTitle, rememberTitle, shortTitle, type TitleIndex } from "../shared/local-titles";
|
|
5
6
|
|
|
6
7
|
export const TITLE_READ_BYTES = 8192;
|
|
@@ -16,12 +17,8 @@ export async function readTitleHtml(path: string): Promise<string | null> {
|
|
|
16
17
|
} finally { await file.close(); }
|
|
17
18
|
} catch { return null; }
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (Array.isArray(output)) return output.map(resultText).join("\n");
|
|
22
|
-
if (output && typeof output === "object") return resultText((output as { text?: unknown }).text);
|
|
23
|
-
return "";
|
|
24
|
-
}
|
|
20
|
+
/** A tool result's text, in every shape Paseo sends (shared/tool-result.ts). */
|
|
21
|
+
export const resultText = (output: unknown): string => toolResult(output).text;
|
|
25
22
|
export function artifactPublishUrl(output: unknown): string | null {
|
|
26
23
|
const url = /^(?:Published \S.*? at|Created a new Artifact at) (https:\/\/claude\.ai\/(?:code\/)?artifact\/[\w-]+)(?=[\s(.,]|$)/.exec(resultText(output).trimStart())?.[1];
|
|
27
24
|
return url && isClaudeArtifact(url) ? url : null;
|
|
@@ -32,8 +29,9 @@ export async function receiptTitles(entries: readonly { item: unknown }[], readH
|
|
|
32
29
|
const titles: TitleIndex = new Map();
|
|
33
30
|
for (const entry of entries) {
|
|
34
31
|
const v = object(entry.item), detail = object(v.detail), input = object(detail.input);
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
const result = toolResult(detail.output);
|
|
33
|
+
if (v.type !== "tool_call" || v.status !== "completed" || v.error || result.isError) continue;
|
|
34
|
+
const output = result.text;
|
|
37
35
|
if (v.name === "Artifact") {
|
|
38
36
|
const action = input.action ?? "publish";
|
|
39
37
|
if (input.asset === true || !["publish", "read"].includes(String(action))) continue;
|
|
@@ -42,15 +40,14 @@ export async function receiptTitles(entries: readonly { item: unknown }[], readH
|
|
|
42
40
|
let html: string | null = null;
|
|
43
41
|
if (!shortTitle(input.title) && action === "publish" && typeof input.file_path === "string") html = await readHtml(input.file_path).catch(() => null);
|
|
44
42
|
// Read returns raw HTML or a title-labelled summary; structured read.result is preserved by Paseo too.
|
|
45
|
-
const read = object(object
|
|
43
|
+
const read = object(result.object?.read);
|
|
46
44
|
if (action === "read") html = typeof read.result === "string" ? read.result : output;
|
|
47
|
-
const named = action === "read" ? shortTitle(object
|
|
45
|
+
const named = action === "read" ? shortTitle(result.object?.title) ?? shortTitle(/^(?:Title|Artifact title):\s*(.+)$/im.exec(output)?.[1]) : null;
|
|
48
46
|
rememberTitle(titles, url, receiptTitle(named ? { ...input, title: named } : input, html));
|
|
49
47
|
}
|
|
50
48
|
if (v.name === "mcp__claude_ai_Claude_Docs__batch") {
|
|
51
49
|
// Each successful create result carries its URL; pair by operation index rather than guessing from prose.
|
|
52
|
-
|
|
53
|
-
try { if (output) parsed = JSON.parse(output); } catch { /* structured output may already be present */ }
|
|
50
|
+
const parsed = result.value;
|
|
54
51
|
const operations = Array.isArray(input.batch) ? input.batch : Array.isArray(input.operations) ? input.operations : [];
|
|
55
52
|
const results = Array.isArray(parsed) ? parsed : object(parsed).results ?? object(parsed).batch;
|
|
56
53
|
if (!Array.isArray(results)) continue;
|
package/shared/chat.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { onBehalfOf } from "./actor";
|
|
2
2
|
import { BRIDGE_TOOL, BRIDGE_SHELL_CALL, splitBatchText, isRecoveryText } from "./legacy";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
+
import { toolResult } from "./tool-result";
|
|
4
5
|
|
|
5
6
|
/** Follow-up's own messages and tool calls, recognised in agent chats so they render as compact rows. */
|
|
6
7
|
export const FOLLOW_TOOLS = ["workspace_status", "sync_workspace", "enroll_workspace", "register_pr", "exclude_stack", "update_obligation", "acknowledge_batch", "declare_done", "ask_question", "record_answer", "withdraw_question", "set_spec"] as const;
|
|
@@ -51,18 +52,7 @@ export type ToolRow = z.infer<typeof toolRowSchema>;
|
|
|
51
52
|
function record(value: unknown): value is Record<string, unknown> {
|
|
52
53
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
53
54
|
}
|
|
54
|
-
/**
|
|
55
|
-
export function readText(value: unknown): string | undefined {
|
|
56
|
-
if (value === null || value === undefined) return "";
|
|
57
|
-
if (typeof value === "string") return value;
|
|
58
|
-
if (Array.isArray(value)) {
|
|
59
|
-
const parts = value.map(part => typeof part === "string" ? part : record(part) && typeof part.text === "string" ? part.text : undefined);
|
|
60
|
-
return parts.every(p => p !== undefined) ? parts.join("\n") : undefined;
|
|
61
|
-
}
|
|
62
|
-
if (!record(value)) return undefined;
|
|
63
|
-
const key = ["output", "content", "text", "message", "result"].find(name => name in value);
|
|
64
|
-
return key ? readText(value[key]) : undefined;
|
|
65
|
-
}
|
|
55
|
+
/** The JSON object in a result's text (toolResult's text: Claude's { output }, MCP content, or a plain string). */
|
|
66
56
|
function json(text: string | undefined): Record<string, unknown> | null {
|
|
67
57
|
if (!text) return null;
|
|
68
58
|
const parse = (body: string) => { try { const value = JSON.parse(body); return record(value) ? value : null; } catch { return null; } };
|
|
@@ -184,14 +174,14 @@ export function followTimelineItem(item: TimelineToolCall, ledger: MomentLedger)
|
|
|
184
174
|
let output: string | undefined;
|
|
185
175
|
if (tool) {
|
|
186
176
|
if (record(detail) && record(detail.input)) input = detail.input;
|
|
187
|
-
output = record(detail) && "output" in detail ?
|
|
177
|
+
output = record(detail) && "output" in detail ? toolResult(detail.output).text : undefined;
|
|
188
178
|
} else if (record(detail) && detail.type === "shell" && typeof detail.command === "string") {
|
|
189
179
|
const call = followShellCall(detail.command);
|
|
190
180
|
if (!call) return undefined;
|
|
191
|
-
tool = call.tool; input = call.input; output =
|
|
181
|
+
tool = call.tool; input = call.input; output = toolResult(detail.output).text || undefined;
|
|
192
182
|
} else return undefined;
|
|
193
183
|
if (TOOL_PRESENTATION[tool] !== "moment" || item.status !== "completed") return undefined;
|
|
194
|
-
if (record(detail) &&
|
|
184
|
+
if (record(detail) && toolResult(detail.output).isError) return undefined;
|
|
195
185
|
const row = toolRow(tool, "completed", input, output);
|
|
196
186
|
if (tool !== "declare_done") return row;
|
|
197
187
|
if (!row.done) return undefined;
|
package/shared/created.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { modelName } from "./agent-settings";
|
|
3
3
|
import { PRESENCE, type TaskAgentState } from "./task-status";
|
|
4
|
+
import { toolResult } from "./tool-result";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* The chat card for an agent or workspace another agent creates (Paseo's create_agent / create_workspace tool calls).
|
|
@@ -42,21 +43,10 @@ export function createdKind(name: string): "agent" | "workspace" | null {
|
|
|
42
43
|
return m ? m[1] as "agent" | "workspace" : null;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
/** An
|
|
46
|
-
function resultObject(output: unknown): Record<string, unknown> | null {
|
|
47
|
-
if (record(output) && Array.isArray(output.content)) {
|
|
48
|
-
const text = output.content.map(c => record(c) && typeof c.text === "string" ? c.text : "").join("");
|
|
49
|
-
return resultObject(text);
|
|
50
|
-
}
|
|
51
|
-
if (typeof output === "string") { try { const v: unknown = JSON.parse(output); return record(v) ? v : null; } catch { return null; } }
|
|
52
|
-
return record(output) ? output : null;
|
|
53
|
-
}
|
|
54
|
-
|
|
46
|
+
/** An error's words: Paseo's tool_result error ({ content }), { message }, or an MCP error result's text. */
|
|
55
47
|
const errorText = (v: unknown): string | null => {
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
if (Array.isArray(v)) return str(v.map(c => record(c) && typeof c.text === "string" ? c.text : "").join(" "));
|
|
59
|
-
return null;
|
|
48
|
+
if (record(v) && !Array.isArray(v.content) && !("output" in v)) return str(v.message) ?? str(v.error) ?? (v.content !== undefined ? errorText(v.content) : null);
|
|
49
|
+
return str(toolResult(v).text);
|
|
60
50
|
};
|
|
61
51
|
|
|
62
52
|
/** "claude/claude-opus-5-5" → { provider: "claude", model: "Opus 5.5" }; a bare provider has no model. */
|
|
@@ -75,7 +65,8 @@ export function createdCard(item: ToolCallLike): CreatedCard | null {
|
|
|
75
65
|
const detail = record(item.detail) ? item.detail : {};
|
|
76
66
|
const input = record(detail.input) ? detail.input : {};
|
|
77
67
|
const output = "output" in detail ? detail.output : undefined;
|
|
78
|
-
const
|
|
68
|
+
const result = toolResult(output);
|
|
69
|
+
const failed = item.status === "failed" || result.isError;
|
|
79
70
|
const { provider, model } = kind === "agent" ? providerModel(input.provider, input.model) : { provider: null, model: null };
|
|
80
71
|
const base = {
|
|
81
72
|
kind, title: str(input.title) ?? (kind === "workspace" ? str(input.branchName) ?? str(input.worktreeSlug) : null), model, provider,
|
|
@@ -84,13 +75,14 @@ export function createdCard(item: ToolCallLike): CreatedCard | null {
|
|
|
84
75
|
};
|
|
85
76
|
if (failed) return { ...base, phase: "failed", id: null, workspaceId: null, error: errorText(item.error) ?? errorText(output) ?? "The call failed" };
|
|
86
77
|
if (item.status === "running") return { ...base, phase: "starting", id: null, workspaceId: null, error: null };
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const
|
|
78
|
+
// Every shape Paseo sends (shared/tool-result.ts): Claude's { output }, Codex's MCP envelope, a JSON string.
|
|
79
|
+
const data = result.object;
|
|
80
|
+
if (!data) return null;
|
|
81
|
+
const nested = record(data.workspace) ? data.workspace : null;
|
|
82
|
+
const id = kind === "agent" ? str(data.agentId) ?? str(data.id) : str(data.workspaceId) ?? str(nested?.id) ?? str(data.id);
|
|
91
83
|
if (!id) return null;
|
|
92
|
-
return { ...base, phase: "created", id, title: base.title ?? (kind === "workspace" ? str(nested?.name) ?? str(
|
|
93
|
-
workspaceId: kind === "agent" ? str(
|
|
84
|
+
return { ...base, phase: "created", id, title: base.title ?? (kind === "workspace" ? str(nested?.name) ?? str(data.title) ?? str(data.name) : null),
|
|
85
|
+
workspaceId: kind === "agent" ? str(data.workspaceId) : id, error: null };
|
|
94
86
|
}
|
|
95
87
|
|
|
96
88
|
/** Live facts the card reads (follow.created-items), from the engine's directory snapshot. Missing: not known yet. */
|
package/shared/settings-nav.ts
CHANGED
|
@@ -32,8 +32,20 @@ const memory = new Map<string, string>();
|
|
|
32
32
|
let backend: KeyValue | null = null;
|
|
33
33
|
const viewListeners = new Set<() => void>();
|
|
34
34
|
let viewVersion = 0;
|
|
35
|
+
/**
|
|
36
|
+
* Writes made while the document is still loading (`writes-while-loading-reach-the-document`): a surface opened at
|
|
37
|
+
* start-up (a settings tab straight from a link, a fold) writes before the document arrives, and the document's older
|
|
38
|
+
* value must not win over it. They are replayed into the document when it arrives. A value merely cached from an
|
|
39
|
+
* earlier session is not one of them, so the document still wins over that.
|
|
40
|
+
*/
|
|
41
|
+
const pending = new Map<string, string>();
|
|
35
42
|
/** Swap in (or out, with null) the device document behind deviceStorage; re-renders whatever reads view state. */
|
|
36
|
-
export function setDeviceBackend(next: KeyValue | null) {
|
|
43
|
+
export function setDeviceBackend(next: KeyValue | null) {
|
|
44
|
+
backend = next;
|
|
45
|
+
if (next) { status = "ready"; for (const [key, value] of pending) next.set(key, value); }
|
|
46
|
+
pending.clear();
|
|
47
|
+
viewChanged();
|
|
48
|
+
}
|
|
37
49
|
/** none: this host keeps no device document (0.15). loading: expected, not loaded yet. ready / failed. */
|
|
38
50
|
export type ViewStatus = "none" | "loading" | "ready" | "failed";
|
|
39
51
|
let status: ViewStatus = "none";
|
|
@@ -48,7 +60,7 @@ const local = {
|
|
|
48
60
|
};
|
|
49
61
|
export const deviceStorage: KeyValue = {
|
|
50
62
|
get(key) { return backend?.get(key) ?? local.get(key); },
|
|
51
|
-
set(key, value) { local.set(key, value); backend
|
|
63
|
+
set(key, value) { local.set(key, value); if (backend) backend.set(key, value); else if (status === "loading") pending.set(key, value); viewChanged(); },
|
|
52
64
|
};
|
|
53
65
|
/** The localStorage cache alone: what a device migrates into its document once. */
|
|
54
66
|
export const localViewStorage: KeyValue = local;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one reader of a tool call's result as Paseo hands it to plugins (`tool_call` item `detail.output`). Every
|
|
3
|
+
* Follow-up reader of a tool result goes through `toolResult`, never `detail.output` directly
|
|
4
|
+
* (`every-tool-result-reads-through-one-normalizer`, tests/tool-result.test.ts). Paseo sends one of:
|
|
5
|
+
*
|
|
6
|
+
* - Claude: `{ output: X, files? }` (Paseo's Claude provider, `buildToolOutput`): X is the parsed JSON of the result's
|
|
7
|
+
* text when it parses, else the text itself.
|
|
8
|
+
* - Codex: the raw MCP result `{ content: [{ type: "text", text }], structuredContent?, isError?, _meta? }`. Paseo's own
|
|
9
|
+
* tools put a summary in front of the JSON in that text ("availableModes_count=3\n…\n\n{…}"); structuredContent
|
|
10
|
+
* holds the object.
|
|
11
|
+
* - A plain string (other providers, shell output, transcripts) or the object itself.
|
|
12
|
+
*/
|
|
13
|
+
export type ToolResult = {
|
|
14
|
+
/** The result as text: the string itself, the MCP text blocks joined, or the object as JSON. "" when there's none. */
|
|
15
|
+
text: string;
|
|
16
|
+
/** The result as data: structuredContent, else the parsed JSON (whole text, else its trailing JSON object), else the object itself. */
|
|
17
|
+
value: unknown;
|
|
18
|
+
/** `value` when it's a plain object. */
|
|
19
|
+
object: Record<string, unknown> | null;
|
|
20
|
+
/** An MCP error result (`isError: true`), at any wrapper depth. */
|
|
21
|
+
isError: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const record = (v: unknown): v is Record<string, unknown> => !!v && typeof v === "object" && !Array.isArray(v);
|
|
25
|
+
const CLAUDE_WRAPPER_KEYS = new Set(["output", "files"]);
|
|
26
|
+
const MAX_DEPTH = 8;
|
|
27
|
+
|
|
28
|
+
/** JSON text, or text whose JSON value starts on its own line after a preamble ("key=value" lines, a sentence). */
|
|
29
|
+
function parseJson(text: string): unknown {
|
|
30
|
+
const body = text.trim();
|
|
31
|
+
if (!body) return undefined;
|
|
32
|
+
try { return JSON.parse(body); } catch { /* not whole JSON */ }
|
|
33
|
+
const at = body.search(/(?:^|\n)\s*[[{]/);
|
|
34
|
+
if (at < 0) return undefined;
|
|
35
|
+
const tail = body.slice(at).trim();
|
|
36
|
+
try { return JSON.parse(tail); } catch { return undefined; }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const blockText = (blocks: unknown[]): string =>
|
|
40
|
+
blocks.map(b => typeof b === "string" ? b : record(b) && typeof b.text === "string" ? b.text : "").filter(Boolean).join("\n");
|
|
41
|
+
|
|
42
|
+
function read(output: unknown, depth: number): ToolResult {
|
|
43
|
+
if (output === null || output === undefined) return { text: "", value: undefined, object: null, isError: false };
|
|
44
|
+
if (typeof output === "string") {
|
|
45
|
+
const value = parseJson(output);
|
|
46
|
+
return { text: output, value, object: record(value) ? value : null, isError: false };
|
|
47
|
+
}
|
|
48
|
+
if (Array.isArray(output)) {
|
|
49
|
+
// Bare content blocks.
|
|
50
|
+
const text = blockText(output);
|
|
51
|
+
const value = parseJson(text);
|
|
52
|
+
return { text, value, object: record(value) ? value : null, isError: false };
|
|
53
|
+
}
|
|
54
|
+
if (!record(output)) return { text: String(output), value: output, object: null, isError: false };
|
|
55
|
+
if (depth < MAX_DEPTH && "output" in output && Object.keys(output).every(k => CLAUDE_WRAPPER_KEYS.has(k))) return read(output.output, depth + 1);
|
|
56
|
+
if (Array.isArray(output.content)) {
|
|
57
|
+
const text = blockText(output.content);
|
|
58
|
+
const isError = output.isError === true || output.is_error === true;
|
|
59
|
+
const structured = record(output.structuredContent) ? output.structuredContent : undefined;
|
|
60
|
+
const value = structured ?? parseJson(text);
|
|
61
|
+
return { text, value, object: record(value) ? value : null, isError };
|
|
62
|
+
}
|
|
63
|
+
// The object itself (Claude's wrapper already peeled, or a provider that hands the result as data).
|
|
64
|
+
const text = typeof output.text === "string" ? output.text : JSON.stringify(output, null, 2);
|
|
65
|
+
return { text, value: output, object: output, isError: output.isError === true || output.is_error === true };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function toolResult(output: unknown): ToolResult {
|
|
69
|
+
return read(output, 0);
|
|
70
|
+
}
|