paseo-follow-up 2.6.0-beta.10 → 2.6.0-beta.11
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/THIRD_PARTY_NOTICES.md +4 -0
- package/client/agent-card.tsx +130 -27
- package/client/agents.tsx +21 -1
- package/client/chat-seen.tsx +56 -0
- package/client/chat.tsx +2 -2
- package/client/composers.ts +40 -0
- package/client/draft-text.ts +39 -0
- package/client/grow.ts +46 -0
- package/client/home-view.ts +10 -2
- package/client/home.tsx +28 -11
- package/client/image-attach.tsx +24 -6
- package/client/live.tsx +3 -0
- package/client/messages.tsx +5 -2
- package/client/needs-you.tsx +1 -0
- package/client/new.tsx +7 -14
- package/client/now-lines.tsx +2 -2
- package/client/on-screen.tsx +1 -1
- package/client/panel.tsx +2 -2
- package/client/reply-draft.ts +93 -0
- package/client/settings.tsx +2 -1
- package/client/sidebar-view.tsx +7 -4
- package/client/turn-view.tsx +90 -20
- package/client/visibility.ts +6 -0
- package/client/your-questions.tsx +57 -16
- package/index.server.ts +64 -11
- package/package.json +6 -5
- package/server/agent-actions.ts +15 -5
- package/server/agent-hook.mjs +60 -12
- package/server/agent-parity.ts +6 -2
- package/server/agent-settings.ts +15 -0
- package/server/context-requests.ts +45 -2
- package/server/daemon.ts +20 -3
- package/server/engine.ts +90 -0
- package/server/hook-source.ts +378 -13
- package/server/mcp-source.ts +53 -5
- package/server/mcp.mjs +33 -4
- package/server/obligations.ts +2 -3
- package/server/outside-answers.ts +132 -0
- package/server/outside-runs/index.ts +75 -0
- package/server/outside-runs/progress.ts +150 -0
- package/server/outside-runs/turn-print.ts +21 -0
- package/server/questions.ts +3 -2
- package/server/report-issue/github.ts +40 -2
- package/server/report-issue/index.ts +65 -9
- package/server/rpc-timing.ts +15 -4
- package/server/scopes.ts +26 -4
- package/server/transcript.ts +5 -4
- package/server/turn-end.ts +27 -6
- package/shared/agent-settings.ts +10 -2
- package/shared/agent-text.d.mts +6 -0
- package/shared/agent-text.mjs +20 -1
- package/shared/attention.ts +20 -2
- package/shared/catch-up.ts +5 -2
- package/shared/chat.ts +10 -4
- package/shared/contracts.ts +13 -6
- package/shared/display.ts +49 -16
- package/shared/grow.ts +15 -0
- package/shared/headline.ts +17 -1
- package/shared/home.ts +25 -8
- package/shared/message-sender.ts +1 -1
- package/shared/model.ts +8 -0
- package/shared/now.ts +38 -1
- package/shared/outside-run.ts +144 -0
- package/shared/peek.ts +1 -1
- package/shared/progress-run.d.mts +32 -0
- package/shared/progress-run.mjs +243 -0
- package/shared/questions.ts +7 -1
- package/shared/reply-draft.ts +38 -0
- package/shared/settings-nav.ts +1 -1
- package/shared/status-invariants.ts +6 -3
- package/shared/task-dup.ts +25 -0
- package/shared/task-rows.ts +20 -3
- package/shared/turn-checks.d.mts +10 -0
- package/shared/turn-checks.mjs +55 -2
- package/shared/turn-clamp.ts +8 -0
- package/shared/turn.ts +41 -13
- package/shared/workspace-layout.ts +4 -4
- package/shared/your-questions.ts +87 -5
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -8,6 +8,10 @@ options, a recommendation and Copy) and the activity log are adapted from
|
|
|
8
8
|
[Progress](https://github.com/stevecastaneda/paseo-plugins/tree/main/progress) (`@stevecastaneda/paseo-progress`
|
|
9
9
|
1.14.0) by Steve Castaneda.
|
|
10
10
|
|
|
11
|
+
Follow-up's reader of a Progress run (`shared/progress-run.mjs`, docs/outside-runs.md) ports parts of Progress 1.17.1
|
|
12
|
+
under the same license: the run file's line format and event checks, the latest-run and per-workspace rules
|
|
13
|
+
(`latestRun`, `workspaceView`, `folderRunLeftBehind`), the stuck rule and the answer message (`answerMessage`).
|
|
14
|
+
|
|
11
15
|
```
|
|
12
16
|
MIT License
|
|
13
17
|
|
package/client/agent-card.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { View } from "react-native";
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { View, type NativeScrollEvent, type NativeSyntheticEvent, type ScrollView as NativeScrollView } from "react-native";
|
|
3
|
+
import { Icon, ScrollView } from "@getpaseo/plugin/client/ui";
|
|
3
4
|
import { usePaseo } from "@getpaseo/plugin/client";
|
|
4
|
-
import { Text } from "./text";
|
|
5
|
+
import { Pressable, Text } from "./text";
|
|
5
6
|
import type { InboxStore } from "./inbox-store";
|
|
6
7
|
import { useInbox } from "./inbox";
|
|
7
8
|
import { AgentLines } from "./now-lines";
|
|
@@ -13,11 +14,13 @@ import { useMarkTimelineOnScreen } from "./on-screen";
|
|
|
13
14
|
import { Spinner } from "./motion";
|
|
14
15
|
import { PrLinksProvider } from "./rich-text";
|
|
15
16
|
import { prLinksByNumber } from "../shared/presentation";
|
|
16
|
-
import { raised, runningColor } from "./theme";
|
|
17
|
+
import { raised, runningColor, type Colors } from "./theme";
|
|
17
18
|
import type { Theme } from "./kit";
|
|
18
19
|
import type { Workspace } from "../shared/model";
|
|
19
20
|
import type { InboxRow } from "../shared/inbox";
|
|
20
|
-
import { turnSource } from "../shared/turn";
|
|
21
|
+
import { MAX_TURNS, turnSource, type Turn } from "../shared/turn";
|
|
22
|
+
import { useChatBeside } from "./composers";
|
|
23
|
+
import { IconButton } from "./kit";
|
|
21
24
|
|
|
22
25
|
/** Where the workspace view is mounted. Only two things differ by place: the head's own controls and the reply box. */
|
|
23
26
|
export type ViewPlace = "home" | "panel" | "tab";
|
|
@@ -25,15 +28,15 @@ export type ViewPlace = "home" | "panel" | "tab";
|
|
|
25
28
|
const NO_INBOX = { subscribe: () => () => undefined, version: () => 0, rows: () => [] } as unknown as InboxStore;
|
|
26
29
|
const NO_ROWS: readonly InboxRow[] = [];
|
|
27
30
|
|
|
28
|
-
export const STEPS_HINT = "
|
|
31
|
+
export const STEPS_HINT = "The agent's chat: live while it's awake, or its saved chat while it's asleep, so it isn't woken.";
|
|
29
32
|
const HOME_REPLY_HINT = " Sending clears Needs you; Sign off & next moves on without a reply.";
|
|
30
33
|
|
|
31
34
|
/**
|
|
32
|
-
* The agent card (docs/client.md#the-workspace-view): one row per agent (client/now-lines.tsx), then
|
|
35
|
+
* The agent card (docs/client.md#the-workspace-view): one row per agent (client/now-lines.tsx), then the Chat section (the
|
|
33
36
|
* peek's rows, client/turn-view.tsx: the developer's messages, the agent's replies, steps grouped) and the reply box
|
|
34
37
|
* right under them, so reading and replying are one place. A row switches the steps and the box to its agent; Cmd/Ctrl
|
|
35
|
-
* opens its chat.
|
|
36
|
-
* it (invariant 1). Its fold (the arrow on the
|
|
38
|
+
* opens its chat. The Chat section reads live while shown and an unloaded agent's saved transcript otherwise, never waking
|
|
39
|
+
* it (invariant 1). Its fold (the arrow on the Chat section line) folds the steps and the box; the rows stay.
|
|
37
40
|
*
|
|
38
41
|
* The side panel (`place` "panel") sits beside the workspace's chat, so it never draws the reply box and its Recent
|
|
39
42
|
* steps start folded; the developer's own fold choice wins everywhere (invariant 132). Home's pane and the main tab mark
|
|
@@ -46,7 +49,7 @@ export function AgentCard({ workspace: w, inbox, theme, compact, steps, now, pla
|
|
|
46
49
|
openAgent?: (agentId: string) => void;
|
|
47
50
|
/** After a reply went out (Home refreshes its inbox rows). */
|
|
48
51
|
onSent?: () => void;
|
|
49
|
-
/** Draw the reply box under
|
|
52
|
+
/** Draw the reply box under the Chat section: never in the side panel, and not on a phone's Home, whose dock has it. */
|
|
50
53
|
reply: boolean;
|
|
51
54
|
}) {
|
|
52
55
|
const c = theme.colors;
|
|
@@ -57,57 +60,157 @@ export function AgentCard({ workspace: w, inbox, theme, compact, steps, now, pla
|
|
|
57
60
|
const name = selected === w.mainAgentId ? "the main agent" : rows.find(r => r.agentId === selected)?.title?.trim() || w.taskAgents?.[selected]?.title?.trim() || "the agent";
|
|
58
61
|
const pick = (agentId: string, chat: boolean) => { if (chat && openAgent) openAgent(agentId); else setSelected(agentId); };
|
|
59
62
|
const [hintOpen, setHintOpen] = useState(false);
|
|
63
|
+
// Beside that same agent's chat (the side panel next to Paseo's agent view), Chat would repeat what's on screen, so
|
|
64
|
+
// the card keeps its agent rows and leaves Chat out (a-chat-beside-isn-t-repeated). Another agent's Chat still shows.
|
|
65
|
+
const beside = useChatBeside(place === "panel" ? selected : null);
|
|
60
66
|
return <View style={[{ marginHorizontal: compact ? 16 : 12, marginTop: 12, borderRadius: 8, overflow: hintOpen ? "visible" : "hidden", zIndex: hintOpen ? 30 : undefined, backgroundColor: c.surface0 }, raised(c)]}>
|
|
61
67
|
<AgentLines workspace={w} inbox={inbox} theme={theme} compact={compact} now={now} openAgent={openAgent} peek={place === "panel"} bare selected={selected} onSelect={pick} />
|
|
62
|
-
<View style={{ borderTopWidth: 1, borderTopColor: c.border }}>
|
|
63
|
-
<RecentSteps agentId={selected} name={name} theme={theme} compact={compact} steps={steps} place={place} reply={reply} prs={w.prs} onSent={onSent} onHint={setHintOpen} />
|
|
64
|
-
</View>
|
|
68
|
+
{!beside && <View style={{ borderTopWidth: 1, borderTopColor: c.border }}>
|
|
69
|
+
<RecentSteps agentId={selected} name={name} theme={theme} compact={compact} steps={steps} place={place} reply={reply} prs={w.prs} onSent={onSent} onHint={setHintOpen} openAgent={openAgent} />
|
|
70
|
+
</View>}
|
|
65
71
|
</View>;
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
/**
|
|
69
|
-
*
|
|
75
|
+
* The Chat section for one agent, with its fold, its ? hint and (when `reply`) the reply box under it: the agent card's
|
|
70
76
|
* lower half, and on its own in Home's pane for a row with no workspace and for the Overseer. Never wakes the agent.
|
|
71
77
|
*/
|
|
72
|
-
export function RecentSteps({ agentId, name, theme, compact, steps, place, reply, prs = [], onSent, onHint, empty }: {
|
|
78
|
+
export function RecentSteps({ agentId, name, theme, compact, steps, place, reply, prs = [], onSent, onHint, empty, openAgent }: {
|
|
73
79
|
agentId: string | null; name: string; theme: Theme; compact: boolean; steps: number; place: ViewPlace; reply: boolean;
|
|
74
80
|
prs?: Workspace["prs"]; onSent?: () => void;
|
|
75
81
|
/** The ? hint opened or closed (the card lets it draw past its edge). */
|
|
76
82
|
onHint?: (open: boolean) => void;
|
|
77
83
|
/** What an empty turn says; the default points at the reply box or the chat. */
|
|
78
84
|
empty?: string;
|
|
85
|
+
/** Opens the agent's own chat tab (the header's button); the one way the surface already navigates. */
|
|
86
|
+
openAgent?: (agentId: string) => void;
|
|
79
87
|
}) {
|
|
80
88
|
const c = theme.colors;
|
|
81
89
|
const fold = useFold(PANEL_FOLDS.steps, place !== "panel");
|
|
82
90
|
const open = fold.open;
|
|
83
91
|
useMarkTimelineOnScreen(place !== "panel" && open ? agentId : null);
|
|
84
|
-
|
|
92
|
+
// How many turns back it reads (Show earlier messages), per agent for the app session, so a remount keeps it.
|
|
93
|
+
const [turns, setTurns] = useState(() => readBack(agentId));
|
|
94
|
+
useEffect(() => { setTurns(readBack(agentId)); }, [agentId]);
|
|
95
|
+
const turn = useTurn(agentId, open, turns);
|
|
96
|
+
const earlier = () => { if (!agentId) return; const next = Math.min(MAX_TURNS, turns + 1); turnsBack.set(agentId, next); setTurns(next); };
|
|
85
97
|
const paseo = usePaseo();
|
|
86
98
|
const [hintOpen, setHintOpen] = useState(false);
|
|
87
99
|
const help = useHint(next => { setHintOpen(next); onHint?.(next); });
|
|
88
|
-
|
|
100
|
+
// A failed refresh keeps the rows it has and says so in the caption; with nothing read yet, the error takes their place.
|
|
101
|
+
const stale = !!turn.error && !!turn.turn;
|
|
102
|
+
const caption = stale ? "couldn't refresh" : turn.running ? "live" : turnSource(turn);
|
|
89
103
|
const hint = STEPS_HINT + (place === "home" && reply ? HOME_REPLY_HINT : "");
|
|
90
104
|
return <View style={{ zIndex: hintOpen ? 30 : undefined }}>
|
|
91
105
|
<View style={{ zIndex: hintOpen ? 30 : undefined, flexDirection: "row", alignItems: "center" }}>
|
|
92
|
-
<FoldButton open={open} onToggle={fold.toggle} label={caption ? `
|
|
106
|
+
<FoldButton open={open} onToggle={fold.toggle} label={caption ? `Chat, ${caption}` : "Chat"} theme={theme} chevron="end"
|
|
93
107
|
style={(hovered, pressed) => ({ flex: 1, minWidth: 0, flexDirection: "row", alignItems: "center", gap: 7, paddingHorizontal: compact ? 14 : 12, paddingVertical: 8, minHeight: compact ? 44 : undefined, backgroundColor: pressed ? c.surface2 : hovered ? c.surface1 : "transparent" })}>
|
|
94
|
-
<Text numberOfLines={1} style={{ flexShrink: 0, color: c.foreground, fontSize: compact ? 13 : 12, fontWeight: "600" }}>
|
|
108
|
+
<Text numberOfLines={1} style={{ flexShrink: 0, color: c.foreground, fontSize: compact ? 13 : 12, fontWeight: "600" }}>Chat</Text>
|
|
95
109
|
<HintIcon hint={help} text={hint} theme={theme} compact={compact} />
|
|
96
110
|
<View style={{ flex: 1, minWidth: 0, flexDirection: "row", justifyContent: "flex-end", alignItems: "center", gap: 5 }}>
|
|
97
|
-
{turn.running && <View style={{ width: 6, height: 6, borderRadius: 3, backgroundColor: runningColor(c) }} />}
|
|
111
|
+
{turn.running && !stale && <View style={{ width: 6, height: 6, borderRadius: 3, backgroundColor: runningColor(c) }} />}
|
|
98
112
|
{!!caption && <Text numberOfLines={1} style={{ flexShrink: 1, color: c.foregroundMuted, fontSize: 12 }}>{caption}</Text>}
|
|
99
113
|
</View>
|
|
100
114
|
</FoldButton>
|
|
115
|
+
{openAgent && agentId && <View style={{ paddingRight: compact ? 4 : 6 }}>
|
|
116
|
+
<IconButton icon="Maximize2" label={`Open ${name}'s chat`} theme={theme} compact={compact} tooltip onPress={() => openAgent(agentId)} />
|
|
117
|
+
</View>}
|
|
101
118
|
<HintBubble hint={help} text={hint} theme={theme} />
|
|
102
119
|
</View>
|
|
103
|
-
{open && <View style={{ paddingHorizontal: compact ? 14 : 12, paddingBottom: reply ? 0 : 12
|
|
104
|
-
{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
: turn.turn.empty ? <Text style={{ color: c.foregroundMuted, fontSize: 12, lineHeight: 17 }}>{empty ?? (reply ? "No messages yet. Write to the agent below, or open its chat." : "No messages yet. Open its chat to write to it.")}</Text>
|
|
108
|
-
: <PrLinksProvider prs={prLinksByNumber(prs)}><TurnView turn={turn.turn} theme={theme} maxRows={steps} /></PrLinksProvider>}
|
|
120
|
+
{open && <View style={{ paddingHorizontal: compact ? 14 : 12, paddingBottom: reply ? 0 : 12 }}>
|
|
121
|
+
<StepsBody key={agentId ?? ""} height={stepsHeight(steps, compact)} theme={theme} compact={compact} turn={turn.turn} error={turn.turn ? null : turn.error} waiting={!!agentId && !turn.turn && !turn.error}
|
|
122
|
+
empty={empty ?? (reply ? "No messages yet. Write to the agent below, or open its chat." : "No messages yet. Open its chat to write to it.")}
|
|
123
|
+
prs={prs} turns={turns} onEarlier={earlier} />
|
|
109
124
|
</View>}
|
|
110
|
-
{open && reply && agentId && <ReplyBox theme={theme} compact={compact} agentName={name} hint={null} placeholder={`Reply to ${name}`} target={{ kind: "agent", agentId }}
|
|
125
|
+
{open && reply && agentId && <ReplyBox theme={theme} compact={compact} agentName={name} hint={null} placeholder={`Reply to ${name}`} target={{ kind: "agent", agentId }} draft={agentId}
|
|
111
126
|
onSend={async (text, images) => { await paseo.agents.ref(agentId).send(text, images?.length ? { images } : undefined); onSent?.(); }} />}
|
|
112
127
|
</View>;
|
|
113
128
|
}
|
|
129
|
+
|
|
130
|
+
/** Turns read back per agent this app session (Show earlier messages), so a remount or a fold keeps the scroll-back. */
|
|
131
|
+
const turnsBack = new Map<string, number>();
|
|
132
|
+
const readBack = (agentId: string | null) => (agentId && turnsBack.get(agentId)) || 1;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The steps' fixed height: from the layout tier's row count (shared/workspace-layout.ts), so it never jumps with what
|
|
136
|
+
* it holds; the rows scroll inside it. A phone gets a little more, its rows wrap sooner.
|
|
137
|
+
*/
|
|
138
|
+
export function stepsHeight(rows: number, compact: boolean): number {
|
|
139
|
+
return Math.round(Math.min(460, Math.max(compact ? 300 : 260, rows * 50)));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Within this many pixels of the end counts as reading the newest step: new rows keep it pinned. */
|
|
143
|
+
const PIN_SLACK = 24;
|
|
144
|
+
/** A quick read draws nothing; the spinner shows only after this, so a cached or fast read never flashes it. */
|
|
145
|
+
const SPINNER_DELAY_MS = 300;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The Chat section's body (invariant 135): one fixed-height scroll, the same for a live turn and a saved one. It opens at the
|
|
149
|
+
* newest step and stays there as steps arrive, unless the developer scrolled up: then a Latest button takes them
|
|
150
|
+
* down. Show earlier messages at the top reads one more turn back (saved transcript or live tail, never waking), and
|
|
151
|
+
* keeps what was on screen where it was.
|
|
152
|
+
*/
|
|
153
|
+
function StepsBody({ height, theme, compact, turn, error, waiting, empty, prs, turns, onEarlier }: {
|
|
154
|
+
height: number; theme: Theme; compact: boolean; turn: Turn | null; error: string | null; waiting: boolean; empty: string;
|
|
155
|
+
prs: Workspace["prs"]; turns: number; onEarlier: () => void;
|
|
156
|
+
}) {
|
|
157
|
+
const c = theme.colors;
|
|
158
|
+
const ref = useRef<NativeScrollView | null>(null);
|
|
159
|
+
const m = useRef({ y: 0, view: 0, content: 0, pinned: true, anchor: null as null | { content: number; y: number } });
|
|
160
|
+
const [fresh, setFresh] = useState(false);
|
|
161
|
+
const [spin, setSpin] = useState(false);
|
|
162
|
+
// Scrolled off the top: a hairline marks the edge, so a line cut there reads as more above, not a glitch.
|
|
163
|
+
const [under, setUnder] = useState(false);
|
|
164
|
+
useEffect(() => { if (!waiting) { setSpin(false); return; } const t = setTimeout(() => setSpin(true), SPINNER_DELAY_MS); return () => clearTimeout(t); }, [waiting]);
|
|
165
|
+
// A read back lands as a new turn object with more rows; until then the control says it's reading.
|
|
166
|
+
const [asked, setAsked] = useState<Turn | null>(null);
|
|
167
|
+
const loadingEarlier = !!asked && asked === turn;
|
|
168
|
+
useEffect(() => { if (asked && asked !== turn) setAsked(null); }, [turn, asked]);
|
|
169
|
+
const onScroll = (e: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
170
|
+
const { contentOffset, layoutMeasurement, contentSize } = e.nativeEvent;
|
|
171
|
+
m.current.y = contentOffset.y; m.current.view = layoutMeasurement.height; m.current.content = contentSize.height;
|
|
172
|
+
m.current.pinned = contentOffset.y + layoutMeasurement.height >= contentSize.height - PIN_SLACK;
|
|
173
|
+
if (m.current.pinned && fresh) setFresh(false);
|
|
174
|
+
if ((contentOffset.y > 2) !== under) setUnder(contentOffset.y > 2);
|
|
175
|
+
};
|
|
176
|
+
const onContent = (_w: number, h: number) => {
|
|
177
|
+
const before = m.current.content; m.current.content = h;
|
|
178
|
+
const anchor = m.current.anchor;
|
|
179
|
+
if (anchor && h > anchor.content) { m.current.anchor = null; ref.current?.scrollTo({ y: anchor.y + (h - anchor.content), animated: false }); return; }
|
|
180
|
+
if (m.current.pinned) ref.current?.scrollToEnd({ animated: false });
|
|
181
|
+
else if (h > before + 1) setFresh(true);
|
|
182
|
+
};
|
|
183
|
+
const toEnd = () => { m.current.pinned = true; setFresh(false); ref.current?.scrollToEnd({ animated: true }); };
|
|
184
|
+
const earlier = () => { m.current.anchor = { content: m.current.content, y: m.current.y }; m.current.pinned = false; setAsked(turn); onEarlier(); };
|
|
185
|
+
const note = (text: string) => <View style={{ height, justifyContent: "center" }}><Text style={{ color: c.foregroundMuted, fontSize: 12, lineHeight: 17 }}>{text}</Text></View>;
|
|
186
|
+
if (error) return note(`Couldn't read the steps: ${error}`);
|
|
187
|
+
if (!turn) return <View style={{ height, justifyContent: "center", alignItems: "flex-start" }}>{spin && <Spinner color={c.foregroundMuted} size={12} label="Reading the agent's steps" />}</View>;
|
|
188
|
+
if (turn.empty) return note(empty);
|
|
189
|
+
const more = !!turn.older && turns < MAX_TURNS;
|
|
190
|
+
return <View style={{ height }}>
|
|
191
|
+
<ScrollView ref={ref} style={{ flex: 1 }} contentContainerStyle={{ paddingTop: more ? 0 : 4, paddingBottom: 8, gap: 8 }} onScroll={onScroll} scrollEventThrottle={32}
|
|
192
|
+
onContentSizeChange={onContent} onLayout={e => { m.current.view = e.nativeEvent.layout.height; if (m.current.pinned) ref.current?.scrollToEnd({ animated: false }); }}
|
|
193
|
+
showsVerticalScrollIndicator nestedScrollEnabled {...({ dataSet: { followSteps: "" } } as object)}>
|
|
194
|
+
{more && <EarlierButton c={c} compact={compact} loading={loadingEarlier} onPress={earlier} />}
|
|
195
|
+
<PrLinksProvider prs={prLinksByNumber(prs)}><TurnView turn={turn} theme={theme} compact={compact} full /></PrLinksProvider>
|
|
196
|
+
</ScrollView>
|
|
197
|
+
{under && <View pointerEvents="none" style={{ position: "absolute", left: 0, right: 0, top: 0, height: 1, backgroundColor: c.border }} />}
|
|
198
|
+
{fresh && <View pointerEvents="box-none" style={{ position: "absolute", left: 0, right: 0, bottom: 10, alignItems: "center" }}>
|
|
199
|
+
<Pressable accessibilityRole="button" accessibilityLabel="Go to the latest steps" onPress={toEnd}
|
|
200
|
+
style={state => ({ flexDirection: "row", alignItems: "center", gap: 5, minHeight: compact ? 36 : 28, paddingHorizontal: 12, borderRadius: 999, borderWidth: 1, borderColor: c.border,
|
|
201
|
+
backgroundColor: (state as { hovered?: boolean }).hovered || state.pressed ? c.surface2 : c.surface1, ...raised(c) })}>
|
|
202
|
+
<Icon name="ArrowDown" size={13} color={c.foreground} />
|
|
203
|
+
<Text style={{ color: c.foreground, fontSize: 12, fontWeight: "500" }}>Latest</Text>
|
|
204
|
+
</Pressable>
|
|
205
|
+
</View>}
|
|
206
|
+
</View>;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function EarlierButton({ c, compact, loading, onPress }: { c: Colors; compact: boolean; loading: boolean; onPress: () => void }) {
|
|
210
|
+
return <Pressable accessibilityRole="button" accessibilityLabel="Show earlier messages" disabled={loading} onPress={onPress}
|
|
211
|
+
style={state => ({ flexDirection: "row", alignItems: "center", justifyContent: "center", gap: 6, minHeight: compact ? 40 : 30, borderRadius: 6,
|
|
212
|
+
backgroundColor: (state as { hovered?: boolean }).hovered || state.pressed ? c.surface1 : "transparent" })}>
|
|
213
|
+
{loading ? <Spinner color={c.foregroundMuted} size={12} label="Reading earlier messages" /> : <Icon name="ChevronUp" size={13} color={c.foregroundMuted} />}
|
|
214
|
+
<Text style={{ color: c.foregroundMuted, fontSize: 12, fontWeight: "500" }}>{loading ? "Reading earlier messages" : "Show earlier messages"}</Text>
|
|
215
|
+
</Pressable>;
|
|
216
|
+
}
|
package/client/agents.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
|
|
|
4
4
|
import { useRpc } from "@getpaseo/plugin/client";
|
|
5
5
|
import { SettingsAction, SettingsCard, SettingsSection, SettingsSelect, SettingsSwitch, useToast } from "@getpaseo/plugin/client/ui";
|
|
6
6
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
7
|
-
import { agentSettingsRpc, setAgentSettingRpc, setWaitRpc } from "../shared/contracts";
|
|
7
|
+
import { agentSettingsRpc, setAgentSettingRpc, setOutsideRunsRpc, setWaitRpc } from "../shared/contracts";
|
|
8
8
|
import { WAIT_HOST_NOTE, WAIT_NOT_ATTACHED, waitNote, waitSwitchCopy } from "../shared/wait";
|
|
9
9
|
import { hasSame, isJobRole, type AgentRole, type AgentSettingsView, type SavedRole } from "../shared/agent-settings";
|
|
10
10
|
import { NO_PROMPT_MODE, SETTINGS_ORDER, isReset, resetEntry } from "../shared/job-rows";
|
|
@@ -78,6 +78,26 @@ export function WaitSettings({ theme }: Pick<PluginSurfaceProps, "theme">) {
|
|
|
78
78
|
</SettingsSection>;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Settings → Agents → Show Progress runs (docs/outside-runs.md): one switch, on by default, shown only once a Progress
|
|
83
|
+
* file was seen on this host. Shares the Agents screen's query. An unknown format says Follow-up stopped reading it.
|
|
84
|
+
*/
|
|
85
|
+
export function OutsideRunsSettings() {
|
|
86
|
+
const read = useRpc(agentSettingsRpc); const write = useRpc(setOutsideRunsRpc); const cache = useQueryClient(); const toast = useToast();
|
|
87
|
+
const query = useQuery({ queryKey: key, queryFn: () => read({ catalog: true }), staleTime: 5 * 60_000 });
|
|
88
|
+
const change = useMutation({
|
|
89
|
+
mutationFn: (progress: boolean) => write({ progress }),
|
|
90
|
+
onSuccess: value => { cache.setQueryData(key, value); toast.show(`Show Progress runs: ${value.outsideRuns?.enabled ? "on" : "off"}`, { variant: "success" }); },
|
|
91
|
+
onError: error => toast.error(errorText(error)),
|
|
92
|
+
});
|
|
93
|
+
const status = query.data?.outsideRuns;
|
|
94
|
+
if (!status?.seen) return null;
|
|
95
|
+
const hint = status.unknownFormat ? "Progress's file format changed, so Follow-up stopped reading it." : "Progress's tickets, questions and stuck items on the agent line and in Needs you. Progress itself is never changed.";
|
|
96
|
+
return <SettingsSection title="Other plugins">
|
|
97
|
+
<SettingsCard><SettingsSwitch label="Show Progress runs" hint={hint} value={status.enabled} disabled={change.isPending} onValueChange={value => change.mutate(value)} /></SettingsCard>
|
|
98
|
+
</SettingsSection>;
|
|
99
|
+
}
|
|
100
|
+
|
|
81
101
|
/** A row's More in Settings: permissions (Paseo agents), limits and schedule (jobs), and Reset to defaults. */
|
|
82
102
|
function RoleMore({ r, save, busy, theme, compact, invalid }: { r: Role; save: (entry: SavedRole | null) => void; busy: boolean; theme: Theme; compact: boolean; invalid: boolean }) {
|
|
83
103
|
const c = theme.colors; const t = text(c);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useEffect, useMemo, useSyncExternalStore } from "react";
|
|
2
|
+
import * as sdk from "@getpaseo/plugin/client";
|
|
3
|
+
import type { ContextRequest } from "../shared/catch-up";
|
|
4
|
+
import { askingNow, landedOnScreen, unreadAnswer } from "../shared/your-questions";
|
|
5
|
+
import { useContextStore } from "./more-context";
|
|
6
|
+
import { appVisible, onVisibilityChange } from "./visibility";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A chat question's answer that lands while its agent's chat is on screen counts as read at once (shared/your-questions.ts
|
|
10
|
+
* `landedOnScreen`; 2026-11-28, Tom on #387). The chat on screen is Paseo's focused agent: the `{ focused: true }`
|
|
11
|
+
* composer is the very object `{ agentId }` resolves to for that agent (Paseo's composer source caches one per state),
|
|
12
|
+
* so comparing the two names it without a new host API. The window must be visible too. Hosts without composers
|
|
13
|
+
* (Paseo 0.15) don't say, and D3 holds: unread until the developer writes again in that chat.
|
|
14
|
+
*
|
|
15
|
+
* Mounted by the workspace header's Follow-up icon, which is on screen whenever that workspace's chats are.
|
|
16
|
+
*/
|
|
17
|
+
type Selector = { agentId: string } | { focused: true };
|
|
18
|
+
const host = sdk as unknown as Partial<{ useComposers(selector: Selector): readonly unknown[] }>;
|
|
19
|
+
/** Fixed for the app's lifetime, so the hooks below run on every render or on none. */
|
|
20
|
+
export const knowsFocusedChat = typeof host.useComposers === "function";
|
|
21
|
+
|
|
22
|
+
/** Each chat row's state as this client last saw it; one per client (the panel and Home run in one app). */
|
|
23
|
+
const lastSeen = new Map<string, ContextRequest["state"]>();
|
|
24
|
+
const sent = new Set<string>();
|
|
25
|
+
|
|
26
|
+
const useWindowVisible = () => useSyncExternalStore(onVisibilityChange, appVisible, appVisible);
|
|
27
|
+
|
|
28
|
+
export function ChatAnswersSeen({ workspaceId }: { workspaceId: string }) {
|
|
29
|
+
return knowsFocusedChat ? <Watch workspaceId={workspaceId} /> : null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function Watch({ workspaceId }: { workspaceId: string }) {
|
|
33
|
+
const { requests } = useContextStore();
|
|
34
|
+
const focused = host.useComposers!({ focused: true })[0] ?? null;
|
|
35
|
+
const visible = useWindowVisible();
|
|
36
|
+
// Only agents with a chat question asking, or answered and unread: the rest have nothing to land.
|
|
37
|
+
const agents = useMemo(() => [...new Set(requests.filter(r => r.workspaceId === workspaceId && r.via === "chat" && r.askedOf && (askingNow(r) || unreadAnswer(r))).map(r => r.askedOf!))], [requests, workspaceId]);
|
|
38
|
+
return <>{agents.map(a => <AgentSeen key={a} agentId={a} focused={visible ? focused : null} requests={requests} />)}</>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function AgentSeen({ agentId, focused, requests }: { agentId: string; focused: unknown; requests: ContextRequest[] }) {
|
|
42
|
+
const { source } = useContextStore();
|
|
43
|
+
const mine = host.useComposers!({ agentId })[0] ?? null;
|
|
44
|
+
const onScreen = !!mine && mine === focused;
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
for (const r of requests) {
|
|
47
|
+
if (r.via !== "chat" || r.askedOf !== agentId) continue;
|
|
48
|
+
const was = lastSeen.get(r.id);
|
|
49
|
+
lastSeen.set(r.id, r.state);
|
|
50
|
+
if (!landedOnScreen(was, r, onScreen) || sent.has(r.id) || !source?.questionAction) continue;
|
|
51
|
+
sent.add(r.id);
|
|
52
|
+
void source.questionAction({ id: r.id, action: "seen" }).catch(() => { sent.delete(r.id); });
|
|
53
|
+
}
|
|
54
|
+
}, [requests, agentId, onScreen, source]);
|
|
55
|
+
return null;
|
|
56
|
+
}
|
package/client/chat.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { Platform, View } from "react-native";
|
|
|
3
3
|
import { Pressable, Text } from "./text";
|
|
4
4
|
import type { PluginClientContext, PluginTimelineItemProps } from "@getpaseo/plugin/client";
|
|
5
5
|
import { Icon, ScrollView } from "@getpaseo/plugin/client/ui";
|
|
6
|
-
import { answerCardSchema, answerCardWhose, batchCardSchema, createMomentLedger, followTimelineItem, parseBatchPrompt, toolRowSchema, type AnswerCard, type BatchCard, type ToolRow } from "../shared/chat";
|
|
6
|
+
import { FOLLOW_TOOL_ICON, answerCardSchema, answerCardWhose, batchCardSchema, createMomentLedger, followTimelineItem, parseBatchPrompt, toolRowSchema, type AnswerCard, type BatchCard, type ToolRow } from "../shared/chat";
|
|
7
7
|
import { parseAnswerMessage, parseAnswersMessage } from "../shared/questions";
|
|
8
8
|
import { envelopeParts } from "../shared/queue";
|
|
9
9
|
import { CREATED_KIND, CREATED_VERSION, createdCard } from "../shared/created";
|
|
@@ -17,7 +17,7 @@ const mono = () => (Platform.OS === "ios" ? "Menlo" : "monospace");
|
|
|
17
17
|
const TOOL_KIND = "tool-row";
|
|
18
18
|
const BATCH_KIND = "batch-card";
|
|
19
19
|
const ANSWER_KIND = "answer-card";
|
|
20
|
-
const TOOL_ICON
|
|
20
|
+
const TOOL_ICON = FOLLOW_TOOL_ICON;
|
|
21
21
|
|
|
22
22
|
/** Expandable full text below a row, scrolling on its own so long output never moves the chat. */
|
|
23
23
|
function Expanded({ text, color, border }: { text: string; color: string; border: string }) {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as pluginClient from "@getpaseo/plugin/client";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Paseo's composers through its public plugin API (`useComposers`, 0.16+): the reply draft's shared words
|
|
5
|
+
* (client/draft-text.ts) and whether an agent's chat is beside a surface that isn't told (`useChatBeside`).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** The slice of Paseo's composer Follow-up uses (`PluginComposer`). */
|
|
9
|
+
export type ComposerText = { prompt: string; setPrompt(text: string): void };
|
|
10
|
+
export type UseComposers = (selector: { agentId: string } | { focused: true }) => readonly ComposerText[];
|
|
11
|
+
|
|
12
|
+
/** Paseo 0.16+'s `useComposers`, or null on a host without it (0.15). */
|
|
13
|
+
export function hostComposers(client: unknown): UseComposers | null {
|
|
14
|
+
const hook = client && typeof client === "object" ? (client as { useComposers?: unknown }).useComposers : undefined;
|
|
15
|
+
return typeof hook === "function" ? hook as UseComposers : null;
|
|
16
|
+
}
|
|
17
|
+
export const useHostComposers = hostComposers(pluginClient);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The composer `selector` names, or null where Paseo can't give one: an older host, a surface outside a composers
|
|
21
|
+
* provider (the hook throws there, the same way on every render of a mount), an agent Paseo's composers don't cover.
|
|
22
|
+
*/
|
|
23
|
+
export function useComposer(selector: { agentId: string } | { focused: true }, use: UseComposers | null = useHostComposers): ComposerText | null {
|
|
24
|
+
if (!use) return null;
|
|
25
|
+
try { return use(selector)[0] ?? null; } catch { return null; }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Two reads of Paseo's composers name the same agent: Paseo hands out one handle per agent's composer state. */
|
|
29
|
+
export const sameComposer = (a: ComposerText | null, b: ComposerText | null): boolean => !!a && a === b;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Whether `agentId`'s chat is the one focused beside this surface (the workspace panel beside Paseo's agent view is
|
|
33
|
+
* not told which agent that is). True only when Paseo's focused composer is that agent's; false on a host without
|
|
34
|
+
* composers, for another agent, or for null.
|
|
35
|
+
*/
|
|
36
|
+
export function useChatBeside(agentId: string | null, use: UseComposers | null = useHostComposers): boolean {
|
|
37
|
+
const focused = useComposer({ focused: true }, use);
|
|
38
|
+
const mine = useComposer({ agentId: agentId ?? "" }, use);
|
|
39
|
+
return !!agentId && sameComposer(focused, mine);
|
|
40
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { DraftSync, ownText, setOwnText } from "./reply-draft";
|
|
3
|
+
import { useComposer, useHostComposers, type UseComposers } from "./composers";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The reply box's words for `agentId` (a-reply-draft-is-kept): the agent's composer draft when Paseo can reach it, so
|
|
7
|
+
* the box and the chat show one text, else this agent's own kept words. Null agent: plain local state.
|
|
8
|
+
* `set` is what typing calls; `clear` is a send. The box's own state is what it draws, so a keystroke is never lost to
|
|
9
|
+
* a write coming back late (DraftSync).
|
|
10
|
+
*/
|
|
11
|
+
export function useDraftText(agentId: string | null, use: UseComposers | null = useHostComposers): { value: string; set: (text: string) => void; clear: () => void; shared: boolean } {
|
|
12
|
+
const composer = useComposer({ agentId: agentId ?? "" }, use);
|
|
13
|
+
const composerRef = useRef(composer); composerRef.current = composer;
|
|
14
|
+
const read = () => !agentId ? "" : composer ? composer.prompt : ownText(agentId);
|
|
15
|
+
const [held, setHeld] = useState(() => ({ agentId, value: read() }));
|
|
16
|
+
const value = held.agentId === agentId ? held.value : read();
|
|
17
|
+
const valueRef = useRef(value); valueRef.current = value;
|
|
18
|
+
const sync = useRef<DraftSync | null>(null);
|
|
19
|
+
sync.current ??= new DraftSync(text => composerRef.current?.setPrompt(text));
|
|
20
|
+
// A new agent: a fresh sync, so its echoes never match another agent's words.
|
|
21
|
+
useEffect(() => { sync.current = new DraftSync(text => composerRef.current?.setPrompt(text)); if (held.agentId !== agentId) setHeld({ agentId, value: read() }); }, [agentId]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
22
|
+
// The composer changed: take an edit made there; ignore our own writes coming back.
|
|
23
|
+
const prompt = composer?.prompt;
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (prompt === undefined || !agentId) return;
|
|
26
|
+
const next = sync.current!.incoming(prompt, valueRef.current);
|
|
27
|
+
if (next === null) return;
|
|
28
|
+
setOwnText(agentId, next);
|
|
29
|
+
setHeld({ agentId, value: next });
|
|
30
|
+
}, [prompt, agentId]);
|
|
31
|
+
const set = useCallback((text: string) => {
|
|
32
|
+
setHeld({ agentId, value: text });
|
|
33
|
+
if (!agentId) return;
|
|
34
|
+
setOwnText(agentId, text);
|
|
35
|
+
if (composerRef.current) sync.current!.local(text);
|
|
36
|
+
}, [agentId]);
|
|
37
|
+
const clear = useCallback(() => set(""), [set]);
|
|
38
|
+
return { value, set, clear, shared: !!composer };
|
|
39
|
+
}
|
package/client/grow.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
+
import { Platform, type NativeSyntheticEvent, type TextInputContentSizeChangeEventData } from "react-native";
|
|
3
|
+
import { growHeight } from "../shared/grow";
|
|
4
|
+
|
|
5
|
+
type WebArea = { style?: { height: string }; scrollHeight?: number; offsetHeight?: number; addEventListener?(t: string, f: () => void): void; removeEventListener?(t: string, f: () => void): void; ownerDocument?: { addEventListener(t: string, f: () => void): void; removeEventListener(t: string, f: () => void): void } };
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A multi-line field that grows with its words (the-box-grows-with-the-words): from `min` up to `max`, then it scrolls
|
|
9
|
+
* inside. Web: react-native-web reports no content size for a textarea, so it is measured after each change (shrunk to
|
|
10
|
+
* fit, its scroll height read); native: `onContentSizeChange`. `resizable` (desktop web): the field also takes the
|
|
11
|
+
* browser's own drag handle, and a height the developer drags to is kept as the field's floor (and its ceiling, when
|
|
12
|
+
* dragged past `max`, up to `shared/grow.ts` HAND_MAX) for as long as `remember` names the same field.
|
|
13
|
+
*/
|
|
14
|
+
export function useGrowHeight(value: string, { min, max, pad = 0, resizable = false, remember }: { min: number; max: number; pad?: number; resizable?: boolean; remember?: string }) {
|
|
15
|
+
const ref = useRef<unknown>(null);
|
|
16
|
+
const [content, setContent] = useState(min);
|
|
17
|
+
const [hand, setHand] = useState<number | null>(() => (remember && chosen.get(remember)) || null);
|
|
18
|
+
const height = growHeight(content, min, max, hand);
|
|
19
|
+
useLayoutEffect(() => {
|
|
20
|
+
const el = ref.current as WebArea | null;
|
|
21
|
+
if (Platform.OS !== "web" || !el?.style || el.scrollHeight === undefined) return;
|
|
22
|
+
const was = el.style.height; el.style.height = "0px"; const h = el.scrollHeight; el.style.height = was;
|
|
23
|
+
setContent(h);
|
|
24
|
+
}, [value, min]);
|
|
25
|
+
// The browser's handle sets the textarea's height inline; a pointer released after it moved there is a choice.
|
|
26
|
+
const set = useRef(height); set.current = height;
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const el = ref.current as WebArea | null;
|
|
29
|
+
if (!resizable || Platform.OS !== "web" || !el?.addEventListener || !el.ownerDocument) return;
|
|
30
|
+
const doc = el.ownerDocument;
|
|
31
|
+
let down = false;
|
|
32
|
+
const start = () => { down = true; };
|
|
33
|
+
const end = () => {
|
|
34
|
+
if (!down) return; down = false;
|
|
35
|
+
const h = el.offsetHeight ?? 0;
|
|
36
|
+
if (h && Math.abs(h - set.current) > 2) { setHand(h); if (remember) chosen.set(remember, h); }
|
|
37
|
+
};
|
|
38
|
+
el.addEventListener("pointerdown", start); doc.addEventListener("pointerup", end);
|
|
39
|
+
return () => { el.removeEventListener?.("pointerdown", start); doc.removeEventListener("pointerup", end); };
|
|
40
|
+
}, [resizable, remember]);
|
|
41
|
+
const onContentSizeChange = (e: NativeSyntheticEvent<TextInputContentSizeChangeEventData>) => { if (Platform.OS !== "web") setContent(e.nativeEvent.contentSize.height + pad); };
|
|
42
|
+
return { ref, height, onContentSizeChange, resizeStyle: resizable && Platform.OS === "web" ? { resize: "vertical" } as object : Platform.OS === "web" ? { resize: "none" } as object : {} };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Heights dragged by hand this app session, per field. */
|
|
46
|
+
const chosen = new Map<string, number>();
|
package/client/home-view.ts
CHANGED
|
@@ -31,6 +31,8 @@ import type { ContextRequest } from "../shared/catch-up";
|
|
|
31
31
|
* the list opens in the right order before the setting arrives, and as the value the first device migrates.
|
|
32
32
|
*/
|
|
33
33
|
const SORT_KEY = "follow-up.home.sort";
|
|
34
|
+
/** This device's copy of the sidebar view's order (`sidebar_sort`); absent, it starts as Home's. */
|
|
35
|
+
const SIDEBAR_SORT_KEY = "follow-up.sidebar.sort";
|
|
34
36
|
/** This device's copy of the Display setting `home_view`, so the list opens arranged before the setting arrives. */
|
|
35
37
|
const VIEW_KEY = "follow-up.home.view";
|
|
36
38
|
const PRIORITY_POLL_MS = 60_000;
|
|
@@ -48,7 +50,10 @@ export function createHomeExtras(client: PluginClientContext) {
|
|
|
48
50
|
let sort: SortMode = isSortMode(saved) ? saved : DEFAULT_SORT;
|
|
49
51
|
let view: HomeView = (() => { try { const v = storage.get(VIEW_KEY); return v ? parseHomeView(JSON.parse(v)) : DEFAULT_HOME_VIEW; } catch { return DEFAULT_HOME_VIEW; } })();
|
|
50
52
|
const keepView = (next: HomeView) => { view = next; storage.set(VIEW_KEY, JSON.stringify(next)); };
|
|
51
|
-
const
|
|
53
|
+
const savedSidebar = storage.get(SIDEBAR_SORT_KEY);
|
|
54
|
+
let sidebarSort: SortMode = isSortMode(savedSidebar) ? savedSidebar : sort;
|
|
55
|
+
const sync = homeSortSync(client, () => sort, next => { sort = next; storage.set(SORT_KEY, next); }, { current: () => view, adopt: keepView },
|
|
56
|
+
{ current: () => sidebarSort, adopt: next => { sidebarSort = next; storage.set(SIDEBAR_SORT_KEY, next); } });
|
|
52
57
|
// The order's read joins the other modules' Display read at mount (sharedRead); a write never goes through it.
|
|
53
58
|
const writeSort = sync.write, readSort = () => sharedRead("settings.display.read", () => client.rpc(displayRpc.read, {})).then(doc => sync.apply(doc as { status: string; values?: unknown }));
|
|
54
59
|
// Ranker runs this client started ("Re-rank now"), resolved when the feed says the run is over.
|
|
@@ -231,8 +236,11 @@ export function createHomeExtras(client: PluginClientContext) {
|
|
|
231
236
|
subscribe(listener: () => void) { listeners.add(listener); return () => { listeners.delete(listener); }; },
|
|
232
237
|
version: () => version,
|
|
233
238
|
sort: () => sort,
|
|
234
|
-
/** Home's
|
|
239
|
+
/** Home's order: shown at once, saved as the Display setting `home_sort`. The sidebar view keeps its own. */
|
|
235
240
|
setSort(next: SortMode) { if (next === sort) return; sort = next; storage.set(SORT_KEY, next); emit(); void writeSort(next).catch(() => undefined); },
|
|
241
|
+
sidebarSort: () => sidebarSort,
|
|
242
|
+
/** The sidebar view's order: shown at once, saved as the Display setting `sidebar_sort`. Home's stays as it is. */
|
|
243
|
+
setSidebarSort(next: SortMode) { if (next === sidebarSort) return; sidebarSort = next; storage.set(SIDEBAR_SORT_KEY, next); emit(); void sync.writeSidebar(next).catch(() => undefined); },
|
|
236
244
|
/** Grouping, Title, Show, the filters and Show background (shared/home-arrange.ts), for Home and the sidebar view. */
|
|
237
245
|
view: () => view,
|
|
238
246
|
/** Shown at once, saved as the Display setting `home_view`. */
|