paseo-follow-up 2.3.0-beta.1 → 2.3.0-beta.3

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/brief.tsx CHANGED
@@ -26,6 +26,7 @@ import { cardStore } from "./card-store";
26
26
  import { PrSheet } from "./pr-sheet";
27
27
  import { isLight, withAlpha, type Colors } from "./theme";
28
28
  import { dismissToast, notice, runAction, runUndoable } from "./toasts";
29
+ import { DismissX, RevealScope, useDismiss } from "./dismiss";
29
30
 
30
31
  /**
31
32
  * The brief card (design §2): the ask in one line, decisions as option rows, only the context needed, and the one
@@ -347,7 +348,7 @@ function Past({ b, c, now, compact, height, pending = false, onResend, resending
347
348
  /** `embedded`: inside Home's detail pane, which has its own reply box and action bar, so the card drops its moves. */
348
349
  /** `snoozed`: the row is in Later, so the card wears the row's muted tone and says "Later" instead of "Needs you". */
349
350
  /** `bare`: a section of the Needs you block (client/needs-you.tsx), whose frame says "Needs you": no border, margin or second label. */
350
- type BriefCardProps = PluginTimelineItemProps<Brief> & { deps: BriefDeps; embedded?: boolean; snoozed?: boolean; bare?: boolean };
351
+ type BriefCardProps = PluginTimelineItemProps<Brief> & { deps: BriefDeps; embedded?: boolean; snoozed?: boolean; bare?: boolean; /** After its x is pressed (Catch up moves on). */ onDismissed?: () => void };
351
352
  /** A brief names its PRs ("#240 is merged"): each "#N" its workspace tracks opens that PR (a-row-that-names-a-pr-opens-it-in-one-click). */
352
353
  export function BriefCard(props: BriefCardProps) {
353
354
  const workspace = props.item.data.workspaceId ? props.deps.workspace(props.item.data.workspaceId) : undefined;
@@ -355,7 +356,7 @@ export function BriefCard(props: BriefCardProps) {
355
356
  return <PrLinksProvider prs={prs}><BriefCardBody {...props} /></PrLinksProvider>;
356
357
  }
357
358
 
358
- function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, snoozed = false, bare = false }: BriefCardProps) {
359
+ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, snoozed = false, bare = false, onDismissed }: BriefCardProps) {
359
360
  const c = theme.colors; const row = item.data; const compact = layout.compact;
360
361
  // The row is a snapshot; the live brief decides (shownBrief). Only a row that still looks open asks, one query per
361
362
  // agent for every card in its chat. A card is actionable only when the server says this exact brief is open.
@@ -392,6 +393,7 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
392
393
  const [marked, setMarked] = useState<string | null>(null);
393
394
  // The send landed: green at once, before the server's answered brief replaces the card.
394
395
  const [sent, setSent] = useState(false);
396
+ const dismiss = useDismiss();
395
397
  const picks = usePicks(b.id);
396
398
  const words = useWords(b.id);
397
399
  const notes = useNotes(b.id);
@@ -420,6 +422,11 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
420
422
  const acts = flaggedAct && !snoozed;
421
423
  const tone = !snoozed && (acts || b.kind === "done" || b.kind === "review" || b.kind === "error") ? kindTone(b.kind, c) : c.foregroundMuted;
422
424
  const ageText = age(b.at, now);
425
+ // dismissing-anything-in-needs-you-sends-the-agent-nothing: an ask still in Needs you (or in Later) has the small x
426
+ // beside its age. It signs the row off as dismissed: the agent is sent nothing, and a restated ask isn't flagged again.
427
+ const x = flaggedAct && shown.actionable && agentId ? <View style={{ marginVertical: compact ? -8 : -5, marginRight: compact ? -8 : -6 }}>
428
+ <DismissX theme={theme} compact={compact} label="Dismiss the agent's ask" disabled={!!sending} onPress={() => dismiss({ agentId }, { onDismissed })} />
429
+ </View> : null;
423
430
  const border = acts ? withAlpha(attention, isLight(c) ? 0.5 : 0.45) : c.border;
424
431
  // Every send from the card (a pick, Something else, Send answers, the keyboard's Send) goes through runAction: the
425
432
  // card keeps the picks and words and says what failed, and the toast offers Retry. Success is the card itself.
@@ -470,7 +477,7 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
470
477
  if (b.slim) {
471
478
  // Permission: Paseo's own prompt below is the control (F9). Fallback: the paragraph is right above.
472
479
  // The label and age share the top line so the ask always gets the full width; at a narrow panel the move wraps under it.
473
- return <View accessibilityRole="summary" accessibilityLabel={`${acts ? "Needs you: " : ""}${askText}. ${b.sourceLine}`}
480
+ return <RevealScope accessibilityRole="summary" accessibilityLabel={`${acts ? "Needs you: " : ""}${askText}. ${b.sourceLine}`}
474
481
  style={[{ marginVertical: embedded ? 0 : 10, gap: 4, paddingHorizontal: 12, paddingVertical: 10, borderRadius: 10, borderWidth: 1, borderColor: border }, bare && BARE]}>
475
482
  <View style={{ flexDirection: "row", alignItems: "center", gap: 7 }}>
476
483
  <Icon name={ICON[b.kind]} size={14} color={tone} />
@@ -478,6 +485,7 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
478
485
  <View style={{ flex: 1 }} />
479
486
  {/* In Later the age would read as a second clock beside "Later until"; the pane header keeps it. */}
480
487
  {!snoozed && <Text style={{ color: c.foregroundMuted, fontSize: 12, lineHeight: 16, fontVariant: ["tabular-nums"] }}>{ageText}</Text>}
488
+ {x}
481
489
  </View>
482
490
  <View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", columnGap: 10, rowGap: 8 }}>
483
491
  <RichText numberOfLines={3} tooltip={askText}
@@ -486,7 +494,7 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
486
494
  </View>
487
495
  {!!error && <Text accessibilityRole="alert" style={{ color: c.statusDanger, fontSize: 13, lineHeight: 18 }}>{error}</Text>}
488
496
  {!!mergeWhy && <Text accessibilityRole="alert" style={{ color: c.statusWarning, fontSize: 13, lineHeight: 18 }}>{mergeWhy}</Text>}
489
- </View>;
497
+ </RevealScope>;
490
498
  }
491
499
 
492
500
  const tight = isTight(b, compact, height);
@@ -511,7 +519,7 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
511
519
  const otherId = !multi ? askedDecisions(b).find(d => isOther(picks[d.id]))?.id : undefined;
512
520
  const keySend = multi ? (sendBar(b, sendable).ready ? () => sendAll() : null) : otherId && words[otherId]?.trim() ? () => sendOther(otherId) : null;
513
521
  const sendOther = (decisionId: string) => { const text = words[decisionId]?.trim(); if (text) void run(`${decisionId}:${OTHER}`, async answerId => { await answer([{ decisionId, choice: OTHER, words: text }], answerId); clearCard(b.id); }); };
514
- return <View accessibilityRole="summary" accessibilityLabel={`${acts ? "Needs you" : flaggedAct ? "Later" : word(b.kind)}: ${askText}`}
522
+ return <RevealScope accessibilityRole="summary" accessibilityLabel={`${acts ? "Needs you" : flaggedAct ? "Later" : word(b.kind)}: ${askText}`}
515
523
  style={[{ marginVertical: embedded ? 0 : 10, borderRadius: 12, borderWidth: 1, borderColor: border, backgroundColor: c.surface1, overflow: "hidden" }, bare && BARE]}>
516
524
  <SubmitScope enabled={!!keySend && !busy} onSubmit={() => keySend?.()} style={{ paddingHorizontal: pad, paddingTop: compact ? 12 : 14, paddingBottom: 14, gap: tight ? 10 : 12 }}>
517
525
  <View style={{ gap: 4 }}>
@@ -525,9 +533,11 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
525
533
  {!snoozed && <Text style={{ color: c.foregroundMuted, fontSize: 12, lineHeight: 16, fontVariant: ["tabular-nums"] }}>{ageText}</Text>}
526
534
  {/* Phones: where the card's facts come from sits behind ⓘ instead of a footer under every card. */}
527
535
  {compact && <Pressable accessibilityRole="button" accessibilityLabel={why ? "Hide where this comes from" : "Where this comes from"} aria-expanded={why} accessibilityState={{ expanded: why }}
528
- onPress={() => setWhy(v => !v)} style={{ width: 44, height: 44, marginVertical: -15, marginRight: -14, alignItems: "center", justifyContent: "center" }}>
536
+ onPress={() => setWhy(v => !v)} style={{ width: 44, height: 44, marginVertical: -15, marginRight: x ? -10 : -14, alignItems: "center", justifyContent: "center" }}>
529
537
  <Icon name="Info" size={14} color={why ? c.foreground : c.foregroundMuted} />
530
538
  </Pressable>}
539
+ {/* The x is always the card's last control, in its top-right corner, on every Needs-you item. */}
540
+ {x}
531
541
  </View>
532
542
  {/* The ask role on phones (react-native-web ignores hitSlop, so the ⓘ above is a real 44 box); desktop keeps 19/26. */}
533
543
  {/* Bare: a section of the Needs you block, so the same size as its question titles. */}
@@ -558,7 +568,7 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
558
568
  <Text style={{ flex: 1, color: c.foregroundMuted, fontSize: 12, lineHeight: 16 }}>{b.sourceLine}</Text>
559
569
  </View>}
560
570
  {detail.workspace && sheet && <PrSheet workspace={detail.workspace} prKey={sheet.key} intent={sheet.intent} theme={theme} compact={compact} browserReady={browser.data?.ready ?? false} onClose={() => setSheet(null)} />}
561
- </View>;
571
+ </RevealScope>;
562
572
  }
563
573
 
564
574
  const BARE = { marginVertical: 0, borderWidth: 0, borderRadius: 0, backgroundColor: "transparent" } as const;
@@ -21,7 +21,8 @@ import { bottomInset, Button, focusSoon, IconButton, SubmitScope, text, type The
21
21
  import { glyphColor } from "./home-list";
22
22
  import { useHomeModel, type HomeSources } from "./home-data";
23
23
  import { useInbox } from "./inbox";
24
- import { QuestionBody, type SendReady } from "./questions";
24
+ import { QuestionBody, QuestionDismissX, type SendReady } from "./questions";
25
+ import { DismissReveal, useDismiss } from "./dismiss";
25
26
  import { NeedsYouList } from "./needs-you";
26
27
  import { BriefCard, type BriefDeps } from "./brief";
27
28
  import { SummaryLine } from "./about";
@@ -187,7 +188,8 @@ export function CatchUp({ theme, compact, deps, navigation, onExit }: { theme: T
187
188
  break;
188
189
  }
189
190
  // The card's own Dismiss (QuestionBody), so the key does exactly what the click does.
190
- case "dismiss": { const d = inCard('[aria-label^="Dismiss Q"]'); if (!d) return; d.click?.(); break; }
191
+ // The card's own x (client/dismiss.tsx), whatever the card is, so the key does exactly what the click does.
192
+ case "dismiss": { const d = inCard('[aria-label^="Dismiss"]'); if (!d) return; d.click?.(); break; }
191
193
  case "note": { const add = inCard('[aria-label^="Add a note"]'); if (add) add.click?.(); else r.querySelector('[aria-label="Tell the agent something"]')?.focus?.(); break; }
192
194
  // Its sheet or popover takes focus itself (MoveResult).
193
195
  case "later": if (!click('[aria-label="Later (L)"]')) return; break;
@@ -286,10 +288,11 @@ export function CatchUp({ theme, compact, deps, navigation, onExit }: { theme: T
286
288
 
287
289
  const body = finished || !card ? <Finished theme={theme} compact={compact} stats={stats} empty={!total} onHome={onExit}
288
290
  onSkipped={() => setSession(s => ({ ...s, pos: s.order.findIndex(k => s.outcomes[k] === "skipped"), lapped: true }))} />
289
- : <CardView key={card.key} card={card} w={w} theme={theme} compact={compact} deps={deps} navigation={navigation} gone={gone} more={more} setMore={setMore}
291
+ // The card on screen is the selected one: its x shows without hover (dismissing-anything-in-needs-you-sends-the-agent-nothing).
292
+ : <DismissReveal.Provider value="always"><CardView key={card.key} card={card} w={w} theme={theme} compact={compact} deps={deps} navigation={navigation} gone={gone} more={more} setMore={setMore}
290
293
  request={askFor(context, card)} waiting={!!session.parked[card.s.key]} onAsk={ask}
291
294
  sameWorkspace={session.order.filter(k => cardOf(k)?.s.key === card.s.key)}
292
- onDone={() => settle("done")} onSkip={skip} onSkipWorkspace={wsLeft > 1 ? skipWs : undefined} wsLeft={wsLeft} onBack={session.pos > 0 ? back : undefined} onLater={() => settle("later")} />;
295
+ onDone={() => settle("done")} onSkip={skip} onSkipWorkspace={wsLeft > 1 ? skipWs : undefined} wsLeft={wsLeft} onBack={session.pos > 0 ? back : undefined} onLater={() => settle("later")} /></DismissReveal.Provider>;
293
296
 
294
297
  const rail = <ScrollView {...({ dataSet: { catchUpRail: "1" } } as object)} contentContainerStyle={{ paddingVertical: 8 }}>
295
298
  {session.order.map((k, i) => {
@@ -356,6 +359,7 @@ function CardView({ card, w, theme, compact, deps, navigation, gone, more, setMo
356
359
  const ws = openRowCopy<ListWorkspace>(w, full);
357
360
  const [laterOpen, setLaterOpen] = useState(false);
358
361
  const [ready, setReady] = useState<SendReady | null>(null);
362
+ const dismiss = useDismiss();
359
363
  const openChat = () => { if (!navigation) return; if (s.agentId) navigation.openAgent({ agentId: s.agentId }); else if (s.workspaceId) navigation.openWorkspace({ workspaceId: s.workspaceId }); };
360
364
  const word = cardWord(card);
361
365
  const color = card.item?.kind === "merge" ? mergedColor(c) : card.kind === "finished" ? c.foregroundMuted : c.statusWarning;
@@ -395,8 +399,11 @@ function CardView({ card, w, theme, compact, deps, navigation, gone, more, setMo
395
399
 
396
400
  const askBlock = card.kind === "question" && q && ws
397
401
  ? <View style={{ gap: 8 }}>
398
- <RichText plain style={compact ? t.ask : [t.body, { fontSize: 15, lineHeight: 21, fontWeight: "600" }]}>{`${q.id} · ${q.title}`}</RichText>
399
- <QuestionBody key={q.id} workspace={ws} question={q} theme={theme} compact={compact} inline={false}
402
+ <View style={{ flexDirection: "row", alignItems: "flex-start", gap: 8 }}>
403
+ <RichText plain style={[compact ? t.ask : [t.body, { fontSize: 15, lineHeight: 21, fontWeight: "600" }], { flex: 1, minWidth: 0 }]}>{`${q.id} · ${q.title}`}</RichText>
404
+ <View style={{ marginTop: compact ? -4 : -1, marginRight: -5 }}><QuestionDismissX workspaceId={ws.id} questionId={q.id} theme={theme} compact={compact} onDismissed={onDone} dismiss={dismiss} /></View>
405
+ </View>
406
+ <QuestionBody key={q.id} workspace={ws} question={q} theme={theme} compact={compact} inline={false} dismissAt="host"
400
407
  openAgent={id => navigation?.openAgent({ agentId: id })} onAnswered={onDone} onSendReady={setReady} dictate moreContext={false} />
401
408
  </View>
402
409
  : card.kind === "item" && card.item && full
@@ -404,7 +411,7 @@ function CardView({ card, w, theme, compact, deps, navigation, gone, more, setMo
404
411
  <NeedsYouList workspace={full} theme={theme} compact={compact} rows={[card.item]} flush actions={{ after: onDone, openAgent: openChat } as never} />
405
412
  </View>
406
413
  : card.kind === "permission" ? <PermissionCard s={s} theme={theme} compact={compact} onDone={onDone} />
407
- : card.kind === "brief" ? <BriefAsk s={s} theme={theme} compact={compact} deps={deps} />
414
+ : card.kind === "brief" ? <BriefAsk s={s} theme={theme} compact={compact} deps={deps} onDismissed={onDone} />
408
415
  : <View style={{ gap: 10 }}>
409
416
  <Text style={compact ? t.ask : [t.body, { fontSize: 15, lineHeight: 21, fontWeight: "600" }]}>{s.line || "The agent finished its turn."}</Text>
410
417
  <Text style={t.meta}>Nothing to decide. Sign it off once you've read it, or reply.</Text>
@@ -479,12 +486,12 @@ function PermissionCard({ s, theme, compact, onDone }: { s: DeckCard["s"]; theme
479
486
  onRespond={r => { void agent.handle?.respondToPermission({ requestId: p.id, response: r as never }); onDone(); }} />)}</View>;
480
487
  }
481
488
 
482
- function BriefAsk({ s, theme, compact, deps }: { s: DeckCard["s"]; theme: Theme; compact: boolean; deps: CatchUpDeps }) {
489
+ function BriefAsk({ s, theme, compact, deps, onDismissed }: { s: DeckCard["s"]; theme: Theme; compact: boolean; deps: CatchUpDeps; onDismissed?: () => void }) {
483
490
  const read = useRpc(inboxBriefRpc);
484
491
  const brief = useQuery({ queryKey: ["follow-up", "home-brief", s.agentId, "catch-up"], queryFn: () => read({ agentId: s.agentId! }), enabled: !!s.agentId });
485
492
  const b = liveBrief(brief.data?.brief);
486
493
  if (!b) return <Text style={text(theme.colors, compact).ask}>{s.line}</Text>;
487
- return <BriefCard {...({ embedded: true, item: { data: b }, theme, layout: { compact }, agentId: s.agentId, deps: deps.briefDeps } as unknown as Parameters<typeof BriefCard>[0])} />;
494
+ return <BriefCard {...({ embedded: true, item: { data: b }, theme, layout: { compact }, agentId: s.agentId, deps: deps.briefDeps, onDismissed } as unknown as Parameters<typeof BriefCard>[0])} />;
488
495
  }
489
496
 
490
497
  export function Finished({ theme, compact, stats, empty, onHome, onSkipped }: { theme: Theme; compact: boolean; stats: ReturnType<typeof statsOf>; empty: boolean; onHome: () => void; onSkipped: () => void }) {
@@ -0,0 +1,106 @@
1
+ import { createContext, useContext, useEffect, useRef, useState, type ReactNode } from "react";
2
+ import { Platform, View, type StyleProp, type ViewProps, type ViewStyle } from "react-native";
3
+ import { useRpc } from "@getpaseo/plugin/client";
4
+ import { Icon, useToast } from "@getpaseo/plugin/client/ui";
5
+ import { useQueryClient } from "@tanstack/react-query";
6
+ import { dismissRpc } from "../shared/contracts";
7
+ import { Pressable } from "./text";
8
+ import { focusRing, type Theme } from "./kit";
9
+ import { withAlpha } from "./theme";
10
+ import { liveBriefKey, overviewKey, workspaceKey } from "./keys";
11
+ import { hasToastHost, pushToast, runAction } from "./toast-store";
12
+ import type { InboxStore } from "./inbox-store";
13
+
14
+ /**
15
+ * Dismiss, the same on every Needs-you item (dismissing-anything-in-needs-you-sends-the-agent-nothing): a small muted x
16
+ * in the card's top-right corner, next to its age. "This no longer needs me": the item leaves Needs you and every
17
+ * count at once, the agent is sent nothing, and the toast's Undo brings it back. One control (DismissX), one request
18
+ * (follow.dismiss), one toast.
19
+ *
20
+ * Where it shows: on a phone (no hover) always, muted, with a 40 px hit area (a real box, since react-native-web ignores hitSlop) rather than a bigger glyph.
21
+ * On desktop it appears while the pointer is over its card or focus is inside it (RevealScope), and always on the card
22
+ * that is selected (Catch up's card, Home's detail pane: `DismissReveal` "always"). Hidden is opacity 0, never
23
+ * unmounted, so the card doesn't move when it appears and the keyboard and screen readers always reach it.
24
+ */
25
+
26
+ /** As long as sign-off's Undo (6 s): the toast holds while the pointer or focus is on it. */
27
+ export const DISMISS_UNDO_MS = 6_000;
28
+ /** The x's tooltip and the second half of its accessibility label. */
29
+ export const DISMISS_HINT = "it no longer needs you, and the agent isn't messaged";
30
+
31
+ export type DismissTarget = { workspaceId: string; key: string } | { agentId: string };
32
+ const targetKey = (t: DismissTarget) => "agentId" in t ? `agent:${t.agentId}` : `${t.workspaceId}:${t.key}`;
33
+
34
+ /** The inbox store, bound once by the client entry, so dismissing a brief updates the rows at once. */
35
+ let inbox: InboxStore | null = null;
36
+ export function bindDismissInbox(store: InboxStore | null): void { inbox = store; }
37
+
38
+ /** Dismiss one item, with Undo in the toast. `onDismissed` runs at once, before the request: the card moves on. */
39
+ export function useDismiss(): (target: DismissTarget, options?: { onDismissed?: () => void }) => void {
40
+ const rpc = useRpc(dismissRpc);
41
+ const toast = useToast();
42
+ const cache = useQueryClient();
43
+ const refresh = (t: DismissTarget) => {
44
+ if ("agentId" in t) void cache.invalidateQueries({ queryKey: liveBriefKey(t.agentId) });
45
+ else void cache.invalidateQueries({ queryKey: workspaceKey(t.workspaceId) });
46
+ void cache.invalidateQueries({ queryKey: overviewKey });
47
+ };
48
+ const call = (t: DismissTarget, undo: boolean) => "agentId" in t && inbox ? inbox.dismiss(t.agentId, undo) : rpc({ ...t, ...(undo ? { undo: true } : {}) });
49
+ const undo = (t: DismissTarget, name: string) => void runAction({ label: `Undo dismiss ${name}`, toast, run: () => call(t, true), onSuccess: () => refresh(t),
50
+ success: () => `${name.charAt(0).toUpperCase()}${name.slice(1)} is back in Needs you`, failure: `Couldn't bring back ${name}` }, `dismiss:${targetKey(t)}`);
51
+ return (t, options = {}) => {
52
+ options.onDismissed?.();
53
+ void runAction({ label: "Dismiss", toast, run: () => call(t, false), onSuccess: () => refresh(t), failure: "Couldn't dismiss it",
54
+ // Already gone (merged, answered, sent elsewhere): nothing to say, the surface shows what happened.
55
+ reconcile: () => refresh(t),
56
+ success: r => {
57
+ const message = `Dismissed ${r.name}. The agent wasn't messaged.`;
58
+ if (!hasToastHost()) return message;
59
+ pushToast("success", message, [{ label: "Undo", onPress: () => undo(t, r.name) }], { durationMs: DISMISS_UNDO_MS, keep: true });
60
+ return null;
61
+ } }, `dismiss:${targetKey(t)}`);
62
+ };
63
+ }
64
+
65
+ /** "always": the card is the selected one (Catch up's card, Home's detail pane), so its x shows without hover. */
66
+ export const DismissReveal = createContext<"hover" | "always">("hover");
67
+ const Hovered = createContext<boolean>(false);
68
+
69
+ type DomNode = { addEventListener(type: string, f: () => void): void; removeEventListener(type: string, f: () => void): void; setAttribute?(k: string, v: string): void };
70
+
71
+ /**
72
+ * A card whose x shows while the pointer is over it or focus is inside it (desktop web). Native and phones draw the x
73
+ * always, so this is a plain View there.
74
+ */
75
+ export function RevealScope({ children, style, ...rest }: { children: ReactNode; style?: StyleProp<ViewStyle> } & Omit<ViewProps, "style" | "children">) {
76
+ const [hovered, setHovered] = useState(false);
77
+ const [focused, setFocused] = useState(false);
78
+ // react-native-web forwards these to the DOM (as client/linked.tsx's hover does); React's onFocus/onBlur bubble, so
79
+ // focus anywhere inside the card counts. Native ignores them: the x is always shown there.
80
+ 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>;
82
+ }
83
+
84
+ /**
85
+ * The small x. `label` names what it dismisses ("Dismiss Q3", "Dismiss #12 is approved"); the hint follows it. Quiet by
86
+ * design: the muted foreground at 14 px (16 on phones), no fill until hovered, never the size or colour of an action.
87
+ */
88
+ export function DismissX({ theme, compact, label, onPress, disabled = false }: { theme: Theme; compact: boolean; label: string; onPress: () => void; disabled?: boolean }) {
89
+ const c = theme.colors;
90
+ const reveal = useContext(DismissReveal);
91
+ const hovered = useContext(Hovered);
92
+ const [focused, setFocused] = useState(false);
93
+ const touch = compact || Platform.OS !== "web";
94
+ const shown = touch || reveal === "always" || hovered || focused;
95
+ const tip = useRef<View>(null);
96
+ useEffect(() => { if (Platform.OS === "web") (tip.current as unknown as DomNode | null)?.setAttribute?.("title", `Dismiss: ${DISMISS_HINT}`); }, []);
97
+ // 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
+ // native also gets 4 px of hitSlop, a 48 px target. The glyph stays small and muted.
99
+ const box = touch ? 40 : 22;
100
+ return <Pressable ref={tip} accessibilityRole="button" accessibilityLabel={`${label}: ${DISMISS_HINT}`} disabled={disabled} onPress={onPress}
101
+ hitSlop={4} onFocus={() => setFocused(true)} onBlur={() => setFocused(false)}
102
+ style={(state: { hovered?: boolean; pressed: boolean; focused?: boolean }) => ({ ...focusRing(state.focused, c), width: box, height: box, margin: touch ? -6 : 0, borderRadius: box / 2, alignItems: "center", justifyContent: "center",
103
+ opacity: shown ? (disabled ? 0.4 : 1) : 0, backgroundColor: state.pressed ? c.surface2 : state.hovered ? withAlpha(c.foreground, 0.06) : "transparent" })}>
104
+ {state => <Icon name="X" size={touch ? 16 : 14} color={(state as { hovered?: boolean }).hovered ? c.foreground : c.foregroundMuted} />}
105
+ </Pressable>;
106
+ }
@@ -3,7 +3,8 @@ import { Platform, TextInput, View } from "react-native";
3
3
  import { Pressable, Text } from "./text";
4
4
  import { Icon, ScrollView, useToast } from "@getpaseo/plugin/client/ui";
5
5
  import { homeCounts, type HomeGroupId, type HomeModel } from "../shared/home";
6
- import { filterHome, homeSearchDocs, indexDocs, defaultActive, omniboxResults, overseerProvider, workspaceProvider, type OmniboxItem, type OmniboxProvider } from "../shared/search";
6
+ import { layoutHint, filterHome, homeSearchDocs, indexDocs, defaultActive, omniboxResults, overseerProvider, workspaceProvider, type OmniboxItem, type OmniboxProvider } from "../shared/search";
7
+ import { LayoutCapture, type LayoutKey } from "../shared/layout-swap";
7
8
  import { DEFAULT_SORT, SORT_HINT, SORT_LABEL, SORT_MODES, type SortMode } from "../shared/sort";
8
9
  import { PRIORITY_SOURCE_LABEL } from "../shared/priorities";
9
10
  import { rankFooter } from "../shared/ranker";
@@ -13,7 +14,7 @@ import type { HomeSources } from "./home-data";
13
14
  import { useMinute } from "./home-data";
14
15
  import { Spinner } from "./motion";
15
16
  import { withAlpha, type Colors } from "./theme";
16
- import type { Theme } from "./kit";
17
+ import { text, type Theme } from "./kit";
17
18
  import { MenuItemContent, menuGlyph, menuItemRow } from "./menu-item";
18
19
  import { useLinkedIndex } from "./linked";
19
20
 
@@ -27,6 +28,8 @@ import { useLinkedIndex } from "./linked";
27
28
  export type Omnibox = {
28
29
  query: string;
29
30
  setQuery(q: string): void;
31
+ setPhysical?: (q: string | null) => void;
32
+ layoutHint?: string | null;
30
33
  /** null while the query is empty: the list shows its groups. */
31
34
  results: OmniboxItem[] | null;
32
35
  active: number;
@@ -42,6 +45,7 @@ export type Omnibox = {
42
45
  */
43
46
  export function useOmnibox(model: HomeModel, sources: HomeSources, extraProviders: readonly OmniboxProvider[] = []): Omnibox {
44
47
  const [query, setQueryState] = useState("");
48
+ const [physical, setPhysical] = useState<string | null>(null);
45
49
  // null: the default row. -1: none, so Enter does nothing.
46
50
  const [active, setActive] = useState<number | null>(null);
47
51
  const inputRef = useRef<TextInput | null>(null);
@@ -57,7 +61,7 @@ export function useOmnibox(model: HomeModel, sources: HomeSources, extraProvider
57
61
  const index = useMemo(() => searching ? indexDocs(homeSearchDocs({ model, paseo: sources.paseo.all(), tracked: sources.live.all(), archived: sources.live.archived(), agents: sources.extras.agents(), linked })) : null,
58
62
  // eslint-disable-next-line react-hooks/exhaustive-deps
59
63
  [searching, model, live, paseo, extras, linked]);
60
- const providers = useMemo(() => index ? [workspaceProvider(index), ...extraProviders, overseerProvider(askOn)] : [], [index, extraProviders, askOn]);
64
+ const providers = useMemo(() => index ? [workspaceProvider(index, Date.now(), physical), ...extraProviders, overseerProvider(askOn)] : [], [index, extraProviders, askOn, physical]);
61
65
  const results = useMemo(() => searching ? omniboxResults(providers, query) : null, [providers, query, searching]);
62
66
  const setQuery = useCallback((q: string) => { setQueryState(q); setActive(null); }, []);
63
67
  const fallback = defaultActive(results);
@@ -67,7 +71,8 @@ export function useOmnibox(model: HomeModel, sources: HomeSources, extraProvider
67
71
  // A request made before this field mounted (the search key opening Home) is taken on mount.
68
72
  const token = useSyncExternalStore(sources.extras.subscribe, sources.extras.focusToken, sources.extras.focusToken);
69
73
  useEffect(() => { if (sources.extras.takeFocus()) inputRef.current?.focus(); }, [token, sources.extras]);
70
- return { query, setQuery, results, active: Math.min(current, Math.max(0, (results?.length ?? 1) - 1)), move, inputRef, askOn };
74
+ const hint = layoutHint((results ?? []).flatMap(r => r.hit ? [r.hit] : []));
75
+ return { query, setQuery, setPhysical, layoutHint: hint, results, active: Math.min(current, Math.max(0, (results?.length ?? 1) - 1)), move, inputRef, askOn };
71
76
  }
72
77
 
73
78
  type DomKey = { key: string; metaKey: boolean; ctrlKey: boolean; altKey: boolean; target: unknown; preventDefault(): void };
@@ -92,9 +97,10 @@ export function useSlashToFocus(omnibox: Omnibox, enabled = true) {
92
97
  * The one query field: Home's omnibox (SearchField) and the sidebar view's filter (FilterField) are this with
93
98
  * different words. `dense` is the phone layout: a 44px field with a rounder shape and body-size text.
94
99
  */
95
- export function QueryField({ theme, value, onChange, placeholder, icon, dense, inputRef, slashHint, slashTitle, onSubmit, onArrow, listKeys = false, count, autoFocus = false, onEscape }: {
100
+ export function QueryField({ theme, value, onChange, placeholder, icon, dense, inputRef, slashHint, slashTitle, onSubmit, onArrow, listKeys = false, count, autoFocus = false, onEscape, onLayoutQuery }: {
96
101
  /** Its arrows step into the list below (client/list-keys.ts): the sidebar filter, and Home's search while empty. */
97
102
  listKeys?: boolean;
103
+ onLayoutQuery?: (q: string | null) => void;
98
104
  /** "2 of 12" at the field's end (a panel section's search), in place of the field's own ✕: the section has its own. */
99
105
  count?: string;
100
106
  autoFocus?: boolean;
@@ -108,10 +114,31 @@ export function QueryField({ theme, value, onChange, placeholder, icon, dense, i
108
114
  }) {
109
115
  const c = theme.colors;
110
116
  const [focused, setFocused] = useState(false);
117
+ const capture = useRef(new LayoutCapture());
118
+ const layoutCallback = useRef(onLayoutQuery); layoutCallback.current = onLayoutQuery;
119
+ useEffect(() => {
120
+ if (Platform.OS !== "web" || !onLayoutQuery) return;
121
+ type Input = { value: string; selectionStart: number | null; selectionEnd: number | null };
122
+ type InputEvent = LayoutKey & { target: unknown };
123
+ type Listen = (name: string, listener: (e: InputEvent) => void, capture: boolean) => void;
124
+ const doc = (globalThis as unknown as { document?: { addEventListener: Listen; removeEventListener: Listen } }).document;
125
+ if (!doc) return;
126
+ const belongs = (e: InputEvent) => e.target === inputRef.current;
127
+ const key = (e: InputEvent) => {
128
+ if (!belongs(e)) return;
129
+ const input = e.target as Input;
130
+ capture.current.key(e, input.value, input.selectionStart, input.selectionEnd);
131
+ };
132
+ const reset = (e: InputEvent) => { if (belongs(e)) { capture.current.reset(); layoutCallback.current?.(null); } };
133
+ doc.addEventListener("keydown", key, true);
134
+ const resets = ["paste", "cut", "drop", "compositionstart", "compositionend", "select"];
135
+ for (const event of resets) doc.addEventListener(event, reset, true);
136
+ return () => { doc.removeEventListener("keydown", key, true); for (const event of resets) doc.removeEventListener(event, reset, true); };
137
+ }, [inputRef, !!onLayoutQuery]);
111
138
  return <View style={{ flex: 1, minWidth: 0, flexDirection: "row", alignItems: "center", gap: dense ? 8 : 6, height: dense ? 44 : 32, paddingHorizontal: dense ? 12 : 8, borderRadius: dense ? 12 : 6,
112
139
  borderWidth: 1, borderColor: focused ? withAlpha(c.foreground, 0.35) : c.border, backgroundColor: c.surface1 }}>
113
140
  <Icon name={icon as never} size={dense ? 16 : 13} color={c.foregroundMuted} />
114
- <TextInput ref={inputRef} value={value} onChangeText={onChange} placeholder={placeholder} placeholderTextColor={c.foregroundMuted}
141
+ <TextInput ref={inputRef} value={value} onChangeText={q => { onLayoutQuery?.(capture.current.change(q)); onChange(q); }} placeholder={placeholder} placeholderTextColor={c.foregroundMuted}
115
142
  accessibilityLabel={placeholder} autoFocus={autoFocus} autoCorrect={false} autoCapitalize="none" spellCheck={false} returnKeyType="go"
116
143
  {...(listKeys ? { dataSet: { listKeys: "1" } } as object : {})}
117
144
  onFocus={() => setFocused(true)} onBlur={() => setFocused(false)}
@@ -130,7 +157,9 @@ export function QueryField({ theme, value, onChange, placeholder, icon, dense, i
130
157
  : !!value && <Pressable accessibilityRole="button" accessibilityLabel={`Clear ${placeholder.toLowerCase()}`} hitSlop={dense ? 14 : 8} onPress={() => { onChange(""); inputRef.current?.focus(); }}>
131
158
  <Icon name="X" size={dense ? 16 : 13} color={c.foregroundMuted} />
132
159
  </Pressable>}
133
- {slashHint && !value && !focused && !dense && Platform.OS === "web" && <Text accessibilityElementsHidden importantForAccessibility="no" {...(slashTitle ? { title: slashTitle } as object : null)} style={{ color: c.foregroundMuted, fontSize: 11, paddingHorizontal: 4, borderRadius: 3, borderWidth: 1, borderColor: c.border, fontVariant: ["tabular-nums"] }}>{slashHint}</Text>}
160
+ {slashHint && !value && !focused && !dense && Platform.OS === "web" && <Text accessibilityElementsHidden importantForAccessibility="no"
161
+ // React Native Web drops title props on Text; keep the existing chip's DOM title current directly.
162
+ ref={node => { (node as unknown as { setAttribute?: (key: string, value: string) => void } | null)?.setAttribute?.("title", slashTitle ?? ""); }} style={{ color: c.foregroundMuted, fontSize: 11, paddingHorizontal: 4, borderRadius: 3, borderWidth: 1, borderColor: c.border, fontVariant: ["tabular-nums"] }}>{slashHint}</Text>}
134
163
  </View>;
135
164
  }
136
165
 
@@ -142,7 +171,7 @@ export function QueryField({ theme, value, onChange, placeholder, icon, dense, i
142
171
  export function SearchField({ theme, omnibox, dense, onEnter, anywhereKey }: { theme: Theme; omnibox: Omnibox; dense: boolean; onEnter: (item: OmniboxItem | null) => void; anywhereKey?: string | null }) {
143
172
  const { query, setQuery, results, active, move, inputRef, askOn } = omnibox;
144
173
  const placeholder = askOn ? dense ? "Search or ask the Overseer" : "Search, or ask the Overseer" : "Search workspaces, branches, PRs";
145
- return <QueryField theme={theme} value={query} onChange={setQuery} placeholder={placeholder} icon="Search" dense={dense} inputRef={inputRef} slashHint={anywhereKey || "/"}
174
+ return <QueryField theme={theme} onLayoutQuery={omnibox.setPhysical} value={query} onChange={setQuery} placeholder={placeholder} icon="Search" dense={dense} inputRef={inputRef} slashHint={anywhereKey || "/"}
146
175
  slashTitle={anywhereKey ? `${anywhereKey} from anywhere · / on Home` : "/ focuses the search"}
147
176
  onSubmit={() => { const item = results?.[active]; if (item || !query.trim()) onEnter(item ?? null); }} onArrow={move} listKeys={!query.trim()} />;
148
177
  }
@@ -151,8 +180,9 @@ export function SearchField({ theme, omnibox, dense, onEnter, anywhereKey }: { t
151
180
  * The sidebar view's filter (2.1): narrows the list in place with Home search's matcher (shared/search.ts
152
181
  * `filterHome`), keeping groups and the chosen order. Archived workspaces stay out; Home's search finds those.
153
182
  */
154
- export type ListFilter = { query: string; setQuery: (q: string) => void; model: HomeModel; hits: ReturnType<typeof filterHome>["hits"]; inputRef: { current: TextInput | null } };
183
+ export type ListFilter = { setPhysical?: (q: string | null) => void; layoutHint?: string | null; query: string; setQuery: (q: string) => void; model: HomeModel; hits: ReturnType<typeof filterHome>["hits"]; inputRef: { current: TextInput | null } };
155
184
  export function useListFilter(model: HomeModel, sources: HomeSources): ListFilter {
185
+ const [physical, setPhysical] = useState<string | null>(null);
156
186
  const [query, setQuery] = useState("");
157
187
  const inputRef = useRef<TextInput | null>(null);
158
188
  const live = useSyncExternalStore(sources.live.subscribe, sources.live.version, sources.live.version);
@@ -164,12 +194,17 @@ export function useListFilter(model: HomeModel, sources: HomeSources): ListFilte
164
194
  const index = useMemo(() => searching ? indexDocs(homeSearchDocs({ model, paseo: sources.paseo.all(), tracked: sources.live.all(), agents: sources.extras.agents(), linked })) : null,
165
195
  // eslint-disable-next-line react-hooks/exhaustive-deps
166
196
  [searching, model, live, paseo, extras, linked]);
167
- const filtered = useMemo(() => index ? filterHome(model, index, query) : { model, hits: null }, [index, model, query]);
168
- return { query, setQuery, model: filtered.model, hits: filtered.hits, inputRef };
197
+ const filtered = useMemo(() => index ? filterHome(model, index, query, Date.now(), physical) : { model, hits: null }, [index, model, query, physical]);
198
+ return { query, setQuery, setPhysical, layoutHint: layoutHint([...(filtered.hits?.values() ?? [])]), model: filtered.model, hits: filtered.hits, inputRef };
169
199
  }
170
200
  /** "Filter workspaces": a filter icon and no key binding, so it never reads as Paseo's own Search (the Command Center, ⌘K). */
171
201
  export function FilterField({ theme, filter, dense }: { theme: Theme; filter: ListFilter; dense: boolean }) {
172
- return <QueryField theme={theme} value={filter.query} onChange={filter.setQuery} placeholder="Filter workspaces" icon="ListFilter" dense={dense} inputRef={filter.inputRef} slashHint={false} listKeys />;
202
+ return <QueryField theme={theme} onLayoutQuery={filter.setPhysical} value={filter.query} onChange={filter.setQuery} placeholder="Filter workspaces" icon="ListFilter" dense={dense} inputRef={filter.inputRef} slashHint={false} listKeys />;
203
+ }
204
+
205
+ /** Kept outside the textbox: never changes the query or adds a decision to the search flow. */
206
+ export function LayoutNotice({ theme, query, dense }: { theme: Theme; query?: string | null; dense: boolean }) {
207
+ return <Text accessibilityLiveRegion="polite" numberOfLines={2} style={{ ...text(theme.colors, dense).meta, ...(query ? { paddingTop: 4 } : { height: 0 }) }}>{query ? `Showing results for “\u2068${query}\u2069”` : ""}</Text>;
173
208
  }
174
209
 
175
210
  // ---------- sort ----------
package/client/home.tsx CHANGED
@@ -23,10 +23,11 @@ import { NeedsYouBlock } from "./needs-you";
23
23
  import { HeldMerges } from "./merge-button";
24
24
  import { PrSheet } from "./pr-sheet";
25
25
  import { QuestionSheet } from "./questions";
26
+ import { DismissReveal } from "./dismiss";
26
27
  import { Age, BadgeView, BRIEF_KEY, glyphColor, HomeList, OVERSEER_KEY, PrChipView, PrSummaryText, type OverseerRowState } from "./home-list";
27
28
  import { answerLine, overseerRowState } from "../shared/overseer";
28
29
  import type { OmniboxItem } from "../shared/search";
29
- import { ListTop, SearchField, SortMenu, StatusStrip, UsageMeters, useOmnibox, useSlashToFocus } from "./home-chrome";
30
+ import { LayoutNotice, ListTop, SearchField, SortMenu, StatusStrip, UsageMeters, useOmnibox, useSlashToFocus } from "./home-chrome";
30
31
  import { useHomeModel, useTick, type HomeSources } from "./home-data";
31
32
  import { laterLabel, useInbox, UndoBar, useNextRelay } from "./inbox";
32
33
  import { Spinner } from "./motion";
@@ -248,6 +249,7 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
248
249
  {!(compact && nothing) && <SortMenu theme={theme} mode={model.sort} onChange={deps.sources.extras.setSort} rankedAt={model.rankedAt} touch={compact} rank={rank} onRerank={deps.sources.extras.rankNow} />}
249
250
  {compact && <IconButton theme={theme} compact icon="Settings" label="Follow-up settings" onPress={deps.openSettings} />}
250
251
  </View>
252
+ <View style={{ paddingHorizontal: 16 }}><LayoutNotice theme={theme} query={omnibox.layoutHint} dense={compact} /></View>
251
253
  {!compact && !omnibox.results && <StatusStrip theme={theme} model={model} filter={filter} onFilter={setFilter} touch={compact} dense={compact} />}
252
254
  {!compact && !omnibox.results && <UsageMeters theme={theme} sources={deps.sources} dense={compact} hold={!!model.hold} />}
253
255
  {!compact && !omnibox.results && <SetupOffer theme={theme} compact={compact} view={props.onboarding} />}
@@ -592,7 +594,8 @@ function DetailPane({ s, model, theme, compact, deps, openFull, signOffNext, ask
592
594
  // Only a real ask joins it (shared briefAsks): a done brief on a row flagged for something else stays out of the count.
593
595
  const inBlock = !!w && !!showBrief && !later && briefAsks(b, row);
594
596
 
595
- return <><DockedPane compact={compact} header={header} style={{ backgroundColor: c.surface0 }} contentContainerStyle={{ padding: compact ? 16 : 20, gap: 16, paddingBottom: 24 }}
597
+ // Home's detail pane is the selected workspace: every x in it shows without hover (client/dismiss.tsx).
598
+ return <DismissReveal.Provider value="always"><DockedPane compact={compact} header={header} style={{ backgroundColor: c.surface0 }} contentContainerStyle={{ padding: compact ? 16 : 20, gap: 16, paddingBottom: 24 }}
596
599
  dock={({ yields, typingInContent }) => s.agentId && !typingInContent && <View nativeID={compact ? TOAST_ANCHOR : undefined} style={[{ borderTopWidth: 1, borderTopColor: c.border, backgroundColor: c.surface0 }, bottomInset(compact)]}>
597
600
  {!yields && moves}
598
601
  <ReplyBox theme={theme} compact={compact} agentName={s.title} placeholder={compact ? "Reply to the agent" : undefined} onSend={async text => {
@@ -617,7 +620,7 @@ function DetailPane({ s, model, theme, compact, deps, openFull, signOffNext, ask
617
620
  {laterModal}
618
621
  {full && sheet && <PrSheet workspace={full} prKey={sheet.key} intent={sheet.intent} theme={theme} compact={compact} browserReady={browser.data?.ready ?? false} onClose={() => setSheet(null)} />}
619
622
  {full && <QuestionSheet workspace={full} questionId={question} theme={theme} compact={compact} onClose={() => setQuestion(null)} />}
620
- </>;
623
+ </DismissReveal.Provider>;
621
624
  }
622
625
 
623
626
  /**
@@ -1,5 +1,5 @@
1
1
  import type { PluginClientContext } from "@getpaseo/plugin/client";
2
- import { inboxActRpc, inboxFeed, inboxListRpc } from "../shared/contracts";
2
+ import { dismissRpc, inboxActRpc, inboxFeed, inboxListRpc } from "../shared/contracts";
3
3
  import { openFeed, type Feed } from "./feeds";
4
4
  import type { RpcInput, RpcOutput } from "@getpaseo/plugin";
5
5
  import { withoutWithdrawnAsks, type InboxRow } from "../shared/inbox";
@@ -143,6 +143,16 @@ export function createInboxStore(client: PluginClientContext) {
143
143
  nudge,
144
144
  stop() { stopped = true; feed?.stop(); offVisible(); offNoReview(); if (timer) clearTimeout(timer); if (nudged) clearTimeout(nudged); listeners.clear(); unsubscribe(); },
145
145
 
146
+ /**
147
+ * Dismiss an agent's ask (dismissing-anything-in-needs-you-sends-the-agent-nothing): it leaves Needs you at once and
148
+ * the agent is sent nothing. The caller's toast carries Undo (`undo: true`), so no Undo bar here.
149
+ */
150
+ async dismiss(agentId: string, undo = false) {
151
+ if (!undo) { patch([agentId], r => ({ ...r, needs: null, snooze: null, signedOffAt: new Date().toISOString(), undoable: true })); emit(); }
152
+ try { return await client.rpc(dismissRpc, { agentId, ...(undo ? { undo: true } : {}) }); }
153
+ finally { refresh(); }
154
+ },
155
+
146
156
  /** Sign off now; queue for replay when the host can't be reached. */
147
157
  async signOff(requested: string[], options: { muteTurn?: boolean } = {}) {
148
158
  const agentIds = requested.filter(id => !inflight.has(id));