@notis_ai/cli 0.2.32 → 0.2.34

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.
Files changed (95) hide show
  1. package/README.md +75 -11
  2. package/dist/agent-hooks/notis-agent-hook.mjs +4407 -905
  3. package/dist/base-skills/notis-cli/.notis-base-skill.json +1 -1
  4. package/dist/base-skills/notis-cli/SKILL.md +7 -3
  5. package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
  6. package/dist/base-skills/notis-spaces/SKILL.md +5 -3
  7. package/dist/base-skills/notis-spaces/references/comments.md +102 -0
  8. package/dist/base-skills/notis-spaces/references/context.md +20 -19
  9. package/dist/base-skills/notis-spaces/references/design.md +3 -2
  10. package/dist/base-skills/notis-spaces/references/sdk.md +135 -83
  11. package/dist/base-skills/notis-spaces/references/store.md +24 -1
  12. package/dist/sdk/src/components/NotisSelectionBoundary.tsx +13 -5
  13. package/dist/sdk/src/components/SelectionActionBar.tsx +45 -8
  14. package/dist/sdk/src/components/SpaceTextComments.tsx +293 -0
  15. package/dist/sdk/src/components/selectionRange.ts +65 -0
  16. package/dist/sdk/src/config.ts +3 -1
  17. package/dist/sdk/src/functions.ts +218 -0
  18. package/dist/sdk/src/hooks/useAgentQueue.ts +17 -28
  19. package/dist/sdk/src/hooks/useCollectionInteractions.ts +66 -9
  20. package/dist/sdk/src/hooks/useConnection.ts +102 -0
  21. package/dist/sdk/src/hooks/useFunction.ts +42 -0
  22. package/dist/sdk/src/hooks/useNotisSettings.ts +101 -0
  23. package/dist/sdk/src/index.ts +16 -4
  24. package/dist/sdk/src/interactions/shortcuts.tsx +6 -1
  25. package/dist/sdk/src/interactions/swipeDownToDismiss.ts +158 -0
  26. package/dist/sdk/src/interactions/textBoxTwoState.ts +174 -0
  27. package/dist/sdk/src/interactions.ts +17 -0
  28. package/dist/sdk/src/runtime.ts +16 -1
  29. package/dist/sdk/src/space.ts +401 -33
  30. package/dist/sdk/src/ui/comments/passageModel.ts +99 -0
  31. package/dist/sdk/src/ui/comments/textHighlights.ts +33 -0
  32. package/dist/skill-sync/index.js +262 -31
  33. package/dist/skill-sync-worker.mjs +515 -127
  34. package/dist/space-harness/host.js +389 -154
  35. package/dist/space-sdk/dist/chunk-3NPBCE6E.js +3 -0
  36. package/dist/space-sdk/dist/index.js +3 -3
  37. package/dist/space-sdk/dist/ui.js +16 -11
  38. package/dist/space-sdk/src/config.ts +3 -1
  39. package/dist/space-sdk/src/functions.ts +218 -0
  40. package/dist/space-sdk/src/hooks/useAgentQueue.d.ts +2 -13
  41. package/dist/space-sdk/src/hooks/useCollectionInteractions.d.ts +7 -0
  42. package/dist/space-sdk/src/hooks/useConnection.d.ts +42 -0
  43. package/dist/space-sdk/src/hooks/useFunction.d.ts +20 -0
  44. package/dist/space-sdk/src/hooks/useNotisSettings.d.ts +48 -0
  45. package/dist/space-sdk/src/index.d.ts +10 -4
  46. package/dist/space-sdk/src/interactions/shortcuts.d.ts +5 -0
  47. package/dist/space-sdk/src/runtime.d.ts +14 -1
  48. package/dist/space-sdk/src/space.ts +401 -33
  49. package/dist/space-sdk/src/tailwind-candidates.d.ts +400 -204
  50. package/dist/space-sdk/src/ui/comments/CommentPane.d.ts +90 -15
  51. package/dist/space-sdk/src/ui/comments/PassageComments.d.ts +4 -1
  52. package/dist/space-sdk/src/ui/comments/agentRuntime.d.ts +4 -2
  53. package/dist/space-sdk/src/ui/comments/commentDrafts.d.ts +63 -0
  54. package/dist/space-sdk/src/ui/comments/commentModel.d.ts +59 -88
  55. package/dist/space-sdk/src/ui/comments/commentWords.d.ts +32 -1
  56. package/dist/space-sdk/src/ui/comments/handover.d.ts +34 -0
  57. package/dist/space-sdk/src/ui/comments/hostComments.d.ts +13 -9
  58. package/dist/space-sdk/src/ui/comments/hostPanel.d.ts +113 -0
  59. package/dist/space-sdk/src/ui/comments/index.d.ts +7 -2
  60. package/dist/space-sdk/src/ui/comments/paneOutlet.d.ts +33 -0
  61. package/dist/space-sdk/src/ui/comments/paneParts.d.ts +71 -27
  62. package/dist/space-sdk/src/ui/comments/passageModel.d.ts +12 -36
  63. package/dist/space-sdk/src/ui/comments/reviewRun.d.ts +190 -0
  64. package/dist/space-sdk/src/ui/comments/useCommentRouting.d.ts +26 -4
  65. package/dist/space-sdk/src/ui/comments/useComments.d.ts +116 -77
  66. package/dist/space-sdk/src/ui/comments/usePassageComments.d.ts +8 -4
  67. package/dist/space-sdk/src/ui/index.d.ts +1 -1
  68. package/dist/space-sdk/src/ui/layout/SidePane.d.ts +3 -4
  69. package/dist/space-sdk/src/ui/period/dateFormat.d.ts +27 -8
  70. package/dist/view-renderer/dist/host.js +450 -215
  71. package/package.json +3 -3
  72. package/skills/notis-cli/AGENT_INSTRUCTIONS.md +2 -2
  73. package/skills/notis-spaces/cli.md +3 -3
  74. package/src/cli.js +2 -1
  75. package/src/command-specs/index.js +3 -0
  76. package/src/command-specs/repository-secrets.js +171 -0
  77. package/src/command-specs/spaces.js +3 -3
  78. package/src/runtime/agent-credential.js +175 -0
  79. package/src/runtime/agent-identity.js +95 -19
  80. package/src/runtime/app-platform.js +8 -0
  81. package/src/runtime/auth-recovery.js +14 -0
  82. package/src/runtime/profiles.js +74 -2
  83. package/src/runtime/skill-sync/cloud-client.ts +33 -3
  84. package/src/runtime/skill-sync/index.ts +4 -3
  85. package/src/runtime/skill-sync/symlink-manager.ts +354 -35
  86. package/src/runtime/skill-sync/types.ts +14 -2
  87. package/src/runtime/space-functions.js +213 -0
  88. package/src/runtime/space-platform.js +12 -3
  89. package/src/runtime/space-source.js +116 -13
  90. package/src/runtime/space-test-server.js +22 -4
  91. package/src/runtime/space-verification.js +3 -1
  92. package/src/runtime/transport.js +15 -0
  93. package/dist/sdk/src/components/NotisCommentBoundary.tsx +0 -132
  94. package/dist/space-sdk/dist/chunk-I4Z4UFGB.js +0 -3
  95. package/dist/space-sdk/src/components/NotisCommentBoundary.d.ts +0 -26
@@ -0,0 +1,113 @@
1
+ /**
2
+ * What a comment pane and the host panel around it share. The pane is SDK code drawn in the host Comments panel's
3
+ * shadow root (`hostComments`); the host (the Portal) owns the panel's frame. `@notis/sdk/ui` is one module instance
4
+ * for the host and every Space on the page (`runtimeModules`), so these stores are read on both sides.
5
+ *
6
+ * - Slots. The pane's one header row leaves `<slot name="lead">` and `<slot name="trail">` for the host's own
7
+ * Chat | Comments switch and close button, its list ends with `<slot name="after-list">`, and the selected card
8
+ * starts with `<slot name="run-bar">` (the pane's foot holds a second one, which shows the bar only while no card
9
+ * is selected: the first slot of a name in the tree takes the host's element). They are real shadow DOM slots: the
10
+ * host renders children of the shadow host with a `slot` attribute, which keep the host's styles and React tree. A
11
+ * pane drawn anywhere else leaves them empty.
12
+ * - Waiting for you. The host tells the pane which comment threads wait for the viewer, as the server counts them
13
+ * (`setWaitingCommentThreads`), so the pane's "Waiting for you" filter lists exactly what the host's numbers count,
14
+ * and the number on its switch (`setWaitingCommentCount`), which the Filter shows beside "Waiting for you".
15
+ * - Comment boxes. A new comment and a reply are written in the host's own composer (the chat box's parts: the pills,
16
+ * the / and @ menus, attach, Send). The pane asks for one (`useHostComposer`), which adds a slotted box to the shadow
17
+ * host; the host lists the requests (`subscribeHostComposers`) and draws its composer into each box, so the composer
18
+ * keeps the host's styles and React tree while it sits inside the card. Where no host draws composers the pane keeps
19
+ * its own plain text box.
20
+ */
21
+ import { type RefObject } from 'react';
22
+ /** The slot names a pane leaves for its host. */
23
+ export declare const COMMENT_PANE_SLOTS: Readonly<{
24
+ /** The start of the header row: the host's Chat | Comments switch. */
25
+ readonly lead: 'lead';
26
+ /** The end of the header row: the host's close button. */
27
+ readonly trail: 'trail';
28
+ /** After the last card: where the review run says what follows this page. */
29
+ readonly afterList: 'after-list';
30
+ /** The top of the selected card, above its quoted words (the pane's foot while none is selected): the review run's bar. */
31
+ readonly runBar: 'run-bar';
32
+ }>;
33
+ /** The shadow host of the host Comments panel `element` draws in, or null (a card a Space lays out itself). */
34
+ export declare function commentsShadowHost(element: Element | null): HTMLElement | null;
35
+ /**
36
+ * The comment threads that wait for the viewer (their first comments' ids), as the server counts them: a mention, an
37
+ * agent's question, a reply in a thread they started or replied to. Null: not read (the pane then counts what it can
38
+ * see for itself, an agent's unanswered question).
39
+ */
40
+ export declare function setWaitingCommentThreads(ids: readonly string[] | null): void;
41
+ export declare function waitingCommentThreads(): ReadonlySet<string> | null;
42
+ export declare function useWaitingCommentThreads(): ReadonlySet<string> | null;
43
+ /**
44
+ * The number the host shows on its Chat | Comments switch: what waits for the viewer in the Space on screen. The
45
+ * pane's Filter shows the same number beside "Waiting for you", so the two never disagree. Null: the host shows none
46
+ * (the pane then counts what waits on the page it lists).
47
+ */
48
+ export declare function setWaitingCommentCount(count: number | null): void;
49
+ export declare function useWaitingCommentCount(): number | null;
50
+ /** Who a comment goes to, as the box's first pill says it. */
51
+ export interface HostComposerTo {
52
+ /** "To Deck polish", "To a new Claude thread", "To Velvet Margin Echo". */
53
+ label: string;
54
+ /** An agent outside Notis: the pill adds "outside Notis". */
55
+ outside: boolean;
56
+ outsideLabel: string;
57
+ /** The app or harness that runs it, for its logo. */
58
+ harness: string | null;
59
+ /** Opens the picker under `anchor`; true once something was picked. Absent: the pill only says where it goes. */
60
+ pick?: (anchor: HTMLElement) => Promise<boolean>;
61
+ pickLabel: string;
62
+ }
63
+ /** What the pane hands the host for one comment box. Read fresh by the host each time it draws. */
64
+ export interface HostComposerProps {
65
+ kind: 'new' | 'reply';
66
+ /** "Add a comment", "Reply to Claude". */
67
+ placeholder: string;
68
+ /** The box's accessible name ("New comment on Slide 2", "Reply to Claude"). */
69
+ label: string;
70
+ to: HostComposerTo | null;
71
+ /** The words a new text comment quotes. */
72
+ quote: string | null;
73
+ /** Where a new comment sits when it quotes nothing ("Point 1 on hero.png", "Whole page"). */
74
+ place: string | null;
75
+ /** The draft kept while the pane was away. */
76
+ initialText: string;
77
+ onText(text: string): void;
78
+ /**
79
+ * The files the box held when it went away (another page and back, a save that failed): the host attaches them
80
+ * again, and says with `onFiles` each time what it holds, so the pane keeps them (`commentDrafts`).
81
+ */
82
+ initialFiles: readonly File[];
83
+ onFiles(files: readonly File[]): void;
84
+ /** Sends the comment; the host's files upload first. True once saved. */
85
+ send(text: string, files: File[]): Promise<boolean>;
86
+ /** Drops a new comment (Escape in an empty box, the cross on a phone); a reply box folds back to its one line. */
87
+ dismiss(): void;
88
+ canWrite: boolean;
89
+ /** Whether files can be attached here. */
90
+ attach: boolean;
91
+ /** Goes up each time the pane asks for the caret in this box (Other on a question, a key). */
92
+ focusToken: number;
93
+ /** A new comment takes the caret as it opens; a reply box waits for a press. */
94
+ autoFocus: boolean;
95
+ }
96
+ export interface HostComposerRequest {
97
+ id: string;
98
+ /** The slotted element the host draws the composer in. */
99
+ box: HTMLElement;
100
+ props(): HostComposerProps;
101
+ }
102
+ export declare function subscribeHostComposers(listener: () => void): () => void;
103
+ /** The boxes the panes ask for now. The same array until one comes, goes or changes what it shows. */
104
+ export declare function listHostComposers(): readonly HostComposerRequest[];
105
+ /** The host says it draws comment boxes, until the returned call-back runs. */
106
+ export declare function registerHostComposerHost(): () => void;
107
+ export declare function hostComposerAvailable(): boolean;
108
+ /**
109
+ * Asks the host for its composer at `marker` (an element of the pane, beside the `<slot>` the box shows in). Returns
110
+ * the slot's name once the box exists, or null when no host draws composers here (the pane then keeps its own text
111
+ * box). `watch` lists what the host draws from `props`: it draws again when one changes, never on each keystroke.
112
+ */
113
+ export declare function useHostComposer(marker: RefObject<HTMLElement | null>, active: boolean, props: HostComposerProps, watch: readonly unknown[]): string | null;
@@ -1,7 +1,7 @@
1
1
  export * from './commentModel';
2
2
  export * from './commentWords';
3
3
  export * from './useComments';
4
- export * from './CommentPane';
4
+ export { CommentAgentSource, CommentPane, CommentPins, CommentToolBar, commentExcerpt, sendsOnEnter, type CommentPaneProps, type CommentPinsProps, type CommentToolBarProps, } from './CommentPane';
5
5
  export { COMMENT_HARNESS_NAMES, CommentAgentBadge, commentAgentRuntimeView, type CommentAgentRuntimeView, type CommentHarness, } from './agentRuntime';
6
6
  export * from './commentFiles';
7
7
  export * from './passageModel';
@@ -9,4 +9,9 @@ export * from './usePassageComments';
9
9
  export * from './PassageComments';
10
10
  export { COMMENT_FOCUS_PARAM, useCommentFocusParam, useHostComments } from './hostComments';
11
11
  export { useCommentRouting, type CommentRouting } from './useCommentRouting';
12
- export type { CommentListOptions } from './paneParts';
12
+ export { commentGroupSlot, type CommentListOptions } from './paneParts';
13
+ export { COMMENT_PANE_SLOTS, hostComposerAvailable, listHostComposers, registerHostComposerHost, setWaitingCommentCount, setWaitingCommentThreads, subscribeHostComposers, useWaitingCommentThreads, waitingCommentThreads, type HostComposerProps, type HostComposerRequest, type HostComposerTo, } from './hostPanel';
14
+ export { REVIEW_RUN_TRAVEL_MS, cardComesIntoPlace, cardThatTookThePlace, emitReviewRunEvent, markReviewRunAnswered, publishReviewRunPane, reviewRunAnswered, reviewRunCommands, reviewRunHost, reviewRunPane, resetReviewRunAnswered, setReviewRunHost, subscribeReviewRunAnswered, subscribeReviewRunEvents, subscribeReviewRunHost, subscribeReviewRunPane, unmarkReviewRunAnswered, type ReviewRunEvent, type ReviewRunHost, type ReviewRunPaneState, type ReviewRunSheet, } from './reviewRun';
15
+ export { CommentPaneOutlet, registerPaneOutlet } from './paneOutlet';
16
+ export { handOverCommentState } from './handover';
17
+ export { flushCommentDrafts, keepCommentDraftsIn, type CommentDraftStorage } from './commentDrafts';
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The comment pane drawn by the host, not by the Space view that owns its controller.
3
+ *
4
+ * A pane used to be a React portal from the Space view into the host Comments panel, so it was made again whenever
5
+ * the view was: a new published version of the page emptied the list, lost its scroll and closed the box being
6
+ * written in. Comments do not depend on the page's version. Where the host says it draws panes for the element it
7
+ * hands out (`registerPaneOutlet`), `CommentPane` and `PassageCommentPane` no longer portal: after each of their
8
+ * renders they hand the host what to draw (`usePaneOutlet`), and the host renders it in its own React tree
9
+ * (`CommentPaneOutlet`). When the view that owned the pane goes away, what it last handed over stays drawn until the
10
+ * view that replaces it hands over its own; with the same key (`handover`) React keeps every element of the pane: the
11
+ * cards, the list's scroll, an open reply box and its caret.
12
+ *
13
+ * A host that registers no outlet (a test, an older host) gets the portal as before.
14
+ */
15
+ import { type ReactNode } from 'react';
16
+ /** How long a pane left behind by its view stays drawn while the pane that replaces it reads its comments. */
17
+ export declare const PANE_OUTLET_WAIT_MS = 2500;
18
+ /**
19
+ * The host says it draws the panes handed the element `target` (with `<CommentPaneOutlet target={target} />`), until
20
+ * the returned call-back runs. Call it before the element is handed to a source (`SpaceCommentSource.show`).
21
+ */
22
+ export declare function registerPaneOutlet(target: HTMLElement): () => void;
23
+ /** Whether the host draws the panes handed `target`. */
24
+ export declare function paneOutletFor(target: HTMLElement | null): boolean;
25
+ /**
26
+ * Hands the host what the pane draws in `target`, after each render. True when the host draws it (the pane then
27
+ * renders nothing itself); false when no host outlet is registered for `target` and the pane must portal as before.
28
+ */
29
+ export declare function usePaneOutlet(target: HTMLElement | null, key: string, node: ReactNode, ready: boolean): boolean;
30
+ /** Draws, in the host's own React tree, the pane handed the element `target` (see the file's note). */
31
+ export declare function CommentPaneOutlet({ target }: {
32
+ target: HTMLElement | null;
33
+ }): ReactNode;
@@ -1,25 +1,46 @@
1
1
  /**
2
- * Pieces both comment panes share (the pins pane `CommentPane` and the passage pane `PassageCommentPane`): the filter
3
- * menu (Open, Done, All with counts), the New comment button listing the Space's modes, the hint a mode shows, the
4
- * To chip of a new comment, the Goes to line under a reply, the ordered and grouped list, and E / Shift+E.
2
+ * Pieces both comment panes share (the pins pane `CommentPane` and the passage pane `PassageCommentPane`): the one
3
+ * header row (New comment, the filter with "Waiting for you" first, the "..." menu), the hint a mode shows, the To chip
4
+ * of a new comment, how a thread a comment goes to is named, the ordered and grouped list, and E / Shift+E.
5
5
  */
6
6
  import React, { type ReactNode, type RefObject } from 'react';
7
- import { type CommentGroup, type CommentOrder, type CommentThread } from './commentModel';
7
+ import { type CommentAnchor, type CommentGroup, type CommentOrder, type CommentThread } from './commentModel';
8
8
  import type { SpaceCommentThreadRef } from '../../space';
9
9
  import type { CommentWordKey } from './commentWords';
10
- import type { CommentController, CommentMode, CommentStatusView } from './useComments';
10
+ import type { CommentMode } from './commentModel';
11
+ import type { CommentController } from './useComments';
11
12
  export declare const COMMENT_MODE_ICON: Readonly<Record<CommentMode, string>>;
12
13
  export declare const COMMENT_MODE_WORD: Readonly<Record<CommentMode, CommentWordKey>>;
13
- /** Open (default), Done and All, each with its count, behind one menu (SPC-126). */
14
- export declare function CommentFilterMenu({ controller, counts }: {
14
+ export interface CommentPaneBarProps {
15
15
  controller: CommentController;
16
- /** The counts shown. Default: the controller's, for its anchor filter. */
17
- counts?: Readonly<Record<CommentStatusView, number>>;
18
- }): React.JSX.Element;
19
- /** The pane header's New comment button: one mode starts at once, several open a menu of the Space's modes. */
20
- export declare function NewCommentMenu({ controller }: {
21
- controller: CommentController;
22
- }): React.JSX.Element | null;
16
+ /** The pane's root: Copy changes falls back to it when the clipboard needs an element. */
17
+ rootRef: RefObject<HTMLElement | null>;
18
+ /** Shows Copy changes behind "...". Default true. */
19
+ showCopy?: boolean;
20
+ /**
21
+ * What waits for the viewer in this pane. Default: the controller's count for its anchor filter. In the host panel
22
+ * the host's own number replaces it (`setWaitingCommentCount`): what waits in the Space on screen.
23
+ */
24
+ waitingCount?: number;
25
+ /**
26
+ * In a review run: what waits in the run's scope. The "Waiting for you" chip then reads "5 waiting" and counts down
27
+ * as the person goes (at none it reads "Waiting for you" again); a press on it shows every open comment again.
28
+ */
29
+ runCount?: number | null;
30
+ }
31
+ /**
32
+ * The pane's one header row, the same on a phone and a computer: the host's Chat | Comments switch (`lead` slot), then
33
+ * New comment (+), Filter, the "..." menu of what the Space adds to its panel, then the host's close button (`trail`
34
+ * slot).
35
+ *
36
+ * - New comment starts the Space's one mode at once, or opens a menu of its modes, with "Comment on all of <item>"
37
+ * first on a page with items.
38
+ * - Filter holds both choices: which comment threads ("Waiting for you" first, the only one with a number, then Open,
39
+ * Done and All) and where (this item or all items, on a page with items). No totals.
40
+ * - A second row shows only while the filter is not the usual one (open threads, this item): one chip per choice that
41
+ * differs, and a press on it puts that choice back.
42
+ */
43
+ export declare function CommentPaneBar({ controller, rootRef, showCopy, waitingCount: listed, runCount }: CommentPaneBarProps): React.JSX.Element;
23
44
  /**
24
45
  * What the tool bar says before a mode starts: the hint of the first mode that waits for you to point (no "Point at"
25
46
  * on a Space without point mode), or nothing when every mode opens the box at once (time, page).
@@ -44,8 +65,8 @@ export declare function commentThreadName(controller: CommentController, thread:
44
65
  pending: boolean;
45
66
  };
46
67
  /**
47
- * The "To <thread>" chip of a new comment (SPC-117): the thread picked, else the best match, else "To a new thread".
48
- * A click opens the @ thread picker, at any time. Nothing on a host without best matches or the picker. A long name
68
+ * The "To <thread>" chip of a new comment (SPC-117): the thread picked, else the best match, else "To a new thread";
69
+ * "Choose a thread" when the best match could not be read. A click opens the @ thread picker, at any time. Nothing on a host without best matches or the picker. A long name
49
70
  * ends with an ellipsis (never cut mid-word without one); its title attribute has it in full.
50
71
  */
51
72
  export declare function CommentToChip({ controller }: {
@@ -57,18 +78,22 @@ export declare function CommentToChip({ controller }: {
57
78
  * mentions someone. `setValue` writes the box's text.
58
79
  */
59
80
  export declare function useAtThreadPicker(controller: CommentController): (value: string, field: HTMLElement, setValue?: (value: string) => void) => string;
81
+ /** The name of the agent outside Notis a `claimed` ref names, as its comments sign it. */
82
+ export declare function commentOutsideName(ref: SpaceCommentThreadRef): string;
83
+ /** The agent outside Notis that holds this comment thread (SPC-535), else null. */
84
+ export declare function commentOutsideClaim(controller: CommentController, thread: CommentThread): SpaceCommentThreadRef | null;
60
85
  /**
61
- * At the top of a comment thread's card, the thread that owns it: "Thread <title>" (its first linked thread), else
62
- * "Goes to <best match>" or "Goes to a new thread", with Change, which opens the @ thread picker and links the pick
63
- * (SPC-114). The signatures below it name only who wrote each comment. Nothing when the host does not link threads;
64
- * "Goes to" and a quiet placeholder (no name, no Change) while where it goes is still being read.
86
+ * SPC-536: whether the agent outside Notis that holds this thread has not read the person's latest word yet: someone
87
+ * replied or answered after the agent last wrote, and the agent has not read the thread since (`readAt`, recorded
88
+ * when it reads comments through the CLI or replies).
65
89
  */
66
- export declare function CommentGoesTo({ controller, thread }: {
67
- controller: CommentController;
68
- thread: CommentThread;
69
- }): React.JSX.Element | null;
70
- /** A thread's place, for the card meta line: a moment ("0:24") and how many items it is on. */
71
- export declare function commentPlaceMeta(controller: CommentController, thread: CommentThread): string[];
90
+ export declare function commentOutsideUnread(thread: CommentThread, claim: SpaceCommentThreadRef): boolean;
91
+ /**
92
+ * The items a comment is on, named (SPC-463): each item's title, else its anchor label ("Task 2"), the first three
93
+ * then "+N" for the rest. `total` counts items the Space no longer lists too; with none of them listed it reads
94
+ * "3 items".
95
+ */
96
+ export declare function commentItemNames(controller: Pick<CommentController, 'say'>, items: readonly CommentAnchor[], total?: number): string;
72
97
  export interface CommentListOptions {
73
98
  /**
74
99
  * The order of the threads (SPC-116). Default 'newest': the newest thread first, by when its first comment was
@@ -81,13 +106,32 @@ export interface CommentListOptions {
81
106
  * function to group your way (by slide, by time, by status), or false for a flat list.
82
107
  */
83
108
  groupBy?: ((thread: CommentThread) => CommentGroup | null) | false;
109
+ /**
110
+ * 'always': a heading over every group, also when there is only one (a host that lists a part of a Space's comments
111
+ * names the page of each). Default 'auto': headings only when there is more than one group.
112
+ */
113
+ groupHeadings?: 'auto' | 'always';
84
114
  }
115
+ /** The slot a group's heading leaves for its host, after the group's name (Open the page). */
116
+ export declare function commentGroupSlot(groupKey: string): string;
85
117
  /** The threads in order, under group headings when there is more than one group. */
86
- export declare function CommentThreadList({ controller, threads, order, groupBy, children }: CommentListOptions & {
118
+ export declare function CommentThreadList({ controller, threads, order, groupBy, groupHeadings, children }: CommentListOptions & {
87
119
  controller: CommentController;
88
120
  threads: readonly CommentThread[];
89
121
  children: (thread: CommentThread) => ReactNode;
90
122
  }): React.JSX.Element;
123
+ /**
124
+ * The end of a list that has older Done threads left to read (`controller.hasMore`). It shows as one loading card.
125
+ * The next page is read when the end is in view and the reader moved the list since the last page (a wheel, a
126
+ * finger, a scroll key, the scroll bar), never page after page by itself: a card kept in view at the end of the list
127
+ * (the comment a link opened) would otherwise pull every page of the Space. A list too short to scroll reads on
128
+ * until it can. Where the browser cannot watch the end, the pages are read one after the other.
129
+ */
130
+ export declare function CommentListMore({ controller }: {
131
+ controller: Pick<CommentController, 'say' | 'loadMore' | 'loadingMore'>;
132
+ /** @deprecated The end is watched against what the window shows, whatever box scrolls the list. */
133
+ scrollRef?: RefObject<HTMLElement | null>;
134
+ }): React.JSX.Element;
91
135
  /**
92
136
  * Scrolls the selected thread's card into view inside the pane's own scroller (C7): when a deep link or the page picks
93
137
  * a thread (`threadKey`, and each `revealRequest`). While the panel is hidden (no height) or the card is not drawn
@@ -1,23 +1,11 @@
1
1
  /**
2
- * Comments on a passage of a record's text (pure; no React). A thread can sit on words of a property (a subject, a
3
- * Markdown body) instead of a pin: the comment row keeps which field it is on, the quoted words and a few words
4
- * before and after them. The quote is found again in the text as it is now, white space ignored, the surrounding
5
- * words telling apart several matches; when the quoted words are gone the thread reads Text changed.
6
- *
7
- * The Comments table needs these columns besides the `CommentColumns` ones:
8
- *
9
- * | Column | Type | Meaning |
10
- * | ------ | ---- | ----------------------------------------------------------------------- |
11
- * | Field | text or select | Which field the passage is in (the field's key by default). |
12
- * | Quote | text | The selected words (white space collapsed, at most 1000 characters). |
13
- * | Prefix | text | Up to 40 characters before the quote, to tell apart repeated words. |
14
- * | Suffix | text | Up to 40 characters after it. |
15
- *
16
- * Every name can be changed with `PassageColumns`. A field can also be named by several columns (`values`), for
17
- * example a Field and a Language column for the same property in two languages.
2
+ * Comments on a passage of a page's text (pure; no React). A thread can sit on words (a subject, a Markdown body, any
3
+ * text of the page) instead of a pin: the comment keeps the quoted words, a few words before and after them, and the
4
+ * field they are in when the Space names one (`field`). The quote is found again in the text as it is now, white
5
+ * space ignored, the surrounding words telling apart several matches; when the quoted words are gone the thread reads
6
+ * Passage changed (it stays open with its old quote).
18
7
  */
19
8
  import type { Words } from '../../words';
20
- import { type CommentRow } from './commentModel';
21
9
  /** The words a thread sits on, with the words around them. */
22
10
  export interface TextPassage {
23
11
  quote: string;
@@ -34,30 +22,22 @@ export interface PassageField {
34
22
  key: string;
35
23
  /** Its name in the pane, above each quote. */
36
24
  label: Words;
37
- /**
38
- * The values that name this field on a comment row: written with each new comment, and a row whose columns hold
39
- * all of them is on this field. Default `{ [columns.field]: key }`.
40
- */
41
- values?: Readonly<Record<string, string>>;
42
25
  /** Fields shown together, such as one language. The pane lists the threads of the group on screen. */
43
26
  group?: string;
44
27
  /** The value is Markdown: Text changed and the reading order look at its words, not its syntax. */
45
28
  markdown?: boolean;
46
29
  }
47
- export interface PassageColumns {
48
- field: string;
49
- quote: string;
50
- prefix: string;
51
- suffix: string;
52
- }
53
- export declare const PASSAGE_COLUMNS: Readonly<PassageColumns>;
54
- export declare function passageColumns(columns?: Partial<PassageColumns>): PassageColumns;
30
+ /**
31
+ * The Space page's selection bar hands a selection in a Space's own commentable rich text to that text with this DOM
32
+ * event (detail: `{ range }`), so one bar shows Cite and Comment together and the text draws no button of its own.
33
+ */
34
+ export declare const PASSAGE_COMMENT_EVENT = "notis-passage-comment";
35
+ /** On the Space page root while its selection bar takes comments: own rich text then leaves Comment to the bar. */
36
+ export declare const SELECTION_BAR_COMMENTS_ATTR = "data-notis-bar-comments";
55
37
  /** Characters kept before and after a quote. */
56
38
  export declare const PASSAGE_CONTEXT = 40;
57
39
  /** The longest quote kept. */
58
40
  export declare const PASSAGE_MAX_QUOTE = 1000;
59
- /** The column values naming a field on a comment row. */
60
- export declare function passageFieldValues(field: PassageField, columns?: PassageColumns): Readonly<Record<string, string>>;
61
41
  /**
62
42
  * Finds a passage in `text`, white space ignored (line breaks and block gaps move with edits). With several matches,
63
43
  * the one whose surrounding words best match the stored prefix and suffix. Offsets in `text`, or null when the quoted
@@ -76,7 +56,3 @@ export declare function markdownReadableText(source: string): string;
76
56
  * looked for in what a reader sees (the offset is then proportional), then in the source itself.
77
57
  */
78
58
  export declare function passageOffset(value: string, passage: TextPassage, markdown?: boolean): number | null;
79
- /** The passage a comment row sits on, with its field, or null when it has none or its field is not declared. */
80
- export declare function readPassage(row: CommentRow, fields: readonly PassageField[], columns?: PassageColumns): PassageAnchor | null;
81
- /** The properties a new comment on `passage` writes besides its body, author and status. */
82
- export declare function passageProperties(passage: PassageAnchor, field: PassageField, columns?: PassageColumns): Record<string, unknown>;
@@ -0,0 +1,190 @@
1
+ /**
2
+ * The review run: one comment after the other. With "Waiting for you" on, the pane lists the comment threads that wait
3
+ * for the viewer; an answer, Done or a sent reply takes the next step, and J and K move between cards. The host (the
4
+ * Portal) knows what the pane cannot: whether a run is going, how many wait in its scope, whether another page follows
5
+ * this one and what the person's setting says. They share this module (`@notis/sdk/ui` is one instance for both).
6
+ *
7
+ * - The host tells the pane (`setReviewRunHost`): a run is going, the count in its scope, whether another page with
8
+ * waiting comments follows, and the setting "Move to the next one after sending".
9
+ * - The pane tells the host what it shows (`publishReviewRunPane`): the cards listed in order, the one selected; and
10
+ * what happened (`emitReviewRunEvent`): a card was selected, answered, the page's last card was passed, the run left
11
+ * (Escape, or "Waiting for you" turned off). The host also ends the run when its panel is closed.
12
+ * - The host moves the pane (`reviewRunCommands`): next and previous, the last card, the filter.
13
+ * - On a phone the host shows comments as a sheet over the page and says its height (`sheet`): the pane then draws the
14
+ * selected card alone (half), the list (full) or nothing (low). This holds with or without a run going.
15
+ *
16
+ * One step. Done always moves on. An option picked and a sent reply move on when the setting is on: the card leaves the
17
+ * list and the next one is selected. With the setting off the answer stays in view on its card, which stays listed
18
+ * (it no longer counts as waiting), and next (the bar, J) goes on.
19
+ *
20
+ * Keys, the same as in a conversation: J and K next and previous, Enter the recommended option, 1 to 9 an option by
21
+ * its position, R reply, E Done, Z undo, Escape leaves the run (the panel stays as it is). They are read on the window
22
+ * while a run is going, so they still work once the focus fell back to the page's body (a card that just left the list
23
+ * no longer holds it). They are the run's only with the focus in the Comments panel or on the body: a page that holds
24
+ * the focus keeps its own keys, and a panel that is closed or shows Chat takes none. Out of a run, only with the focus
25
+ * in the pane.
26
+ */
27
+ import { type RefObject } from 'react';
28
+ import type { CommentRecord, CommentThread } from './commentModel';
29
+ import type { CommentController } from './useComments';
30
+ export interface ReviewRunHost {
31
+ /** A run is going: the pane keeps "Waiting for you" on, selects a card and takes the keys from the page's body too. */
32
+ active: boolean;
33
+ /** Goes up by one each time a run starts or crosses to this page: the pane selects its first waiting card again. */
34
+ startToken: number;
35
+ /** The card a crossing asked for (the next page's first waiting one), else the list's first. */
36
+ startKey: string | null;
37
+ /** What waits in the run's scope (this Space, or everywhere from the Spaces root); null: not read yet. */
38
+ scopeCount: number | null;
39
+ /** Another page with waiting comments follows this one. */
40
+ hasNext: boolean;
41
+ /** The person's setting "Move to the next one after sending": an answer or a sent reply moves on. */
42
+ advance: boolean;
43
+ /**
44
+ * On a phone the host shows comments as a sheet over the page, and says the height it rests at: at 'half' the pane
45
+ * shows the selected card alone, at 'low' nothing (the host draws its one line), at 'full' the list. Null: no sheet.
46
+ */
47
+ sheet: ReviewRunSheet | null;
48
+ }
49
+ /** The three heights a phone's comments sheet rests at. */
50
+ export type ReviewRunSheet = 'low' | 'half' | 'full';
51
+ export declare function reviewRunHost(): ReviewRunHost;
52
+ export declare function setReviewRunHost(next: Partial<ReviewRunHost>): void;
53
+ export declare function subscribeReviewRunHost(listener: () => void): () => void;
54
+ export declare function useReviewRunHost(): ReviewRunHost;
55
+ export interface ReviewRunPaneState {
56
+ /** "Waiting for you" is on. */
57
+ waiting: boolean;
58
+ /** The cards listed, in the list's order (their threads' first comments). */
59
+ keys: readonly string[];
60
+ /** The listed cards that still wait (an answered card that stays listed is not one of them). */
61
+ waitingKeys: readonly string[];
62
+ selected: string | null;
63
+ /** A new comment is being written. */
64
+ drafting: boolean;
65
+ /** What the selected card is about, in a few words: the words it quotes, else its place, else how it starts. */
66
+ words?: string | null;
67
+ }
68
+ export declare function reviewRunPane(): ReviewRunPaneState | null;
69
+ export declare function publishReviewRunPane(next: ReviewRunPaneState | null): void;
70
+ export declare function subscribeReviewRunPane(listener: () => void): () => void;
71
+ export type ReviewRunEvent =
72
+ /** A card was selected by the run (a key, the bar, an answer that moved on): the page shows where it sits. */
73
+ {
74
+ type: 'selected';
75
+ key: string;
76
+ direction: 'next' | 'previous';
77
+ by: 'start' | 'step' | 'answer';
78
+ }
79
+ /** A card no longer waits: answered, marked done, or replied to. */
80
+ | {
81
+ type: 'answered';
82
+ key: string;
83
+ }
84
+ /** A card waits again: Undo brought it back, or the server refused its answer. */
85
+ | {
86
+ type: 'restored';
87
+ key: string;
88
+ }
89
+ /** The list's last card was passed. `advance`: an answer did it (the setting is on), not next or J. */
90
+ | {
91
+ type: 'end';
92
+ advance: boolean;
93
+ }
94
+ /** The run is left: Escape (the panel stays as it is), or "Waiting for you" turned off (its chip, another filter). */
95
+ | {
96
+ type: 'leave';
97
+ };
98
+ export declare function emitReviewRunEvent(event: ReviewRunEvent): void;
99
+ export declare function subscribeReviewRunEvents(listener: (event: ReviewRunEvent) => void): () => void;
100
+ export interface ReviewRunCommands {
101
+ /** Selects the next (1) or previous (-1) card. False at the list's end. */
102
+ step(delta: 1 | -1): boolean;
103
+ /** Selects the list's last card. */
104
+ last(): boolean;
105
+ /** Turns "Waiting for you" on or off. */
106
+ setWaiting(on: boolean): void;
107
+ }
108
+ export declare function registerReviewRunCommands(next: ReviewRunCommands): () => void;
109
+ export declare function reviewRunCommands(): ReviewRunCommands | null;
110
+ /**
111
+ * How long an answer given here outweighs the host's list of what waits. The server files an answer a few seconds
112
+ * later (up to about 24); after that its own list is the truth again (a new question in the same thread waits again).
113
+ */
114
+ export declare const REVIEW_RUN_ANSWER_HOLD_MS = 45000;
115
+ /** A thread answered in this run: `kept` when its card stays listed with the answer (the setting is off). */
116
+ export declare function markReviewRunAnswered(key: string, kept: boolean, now?: number): void;
117
+ /** Undo: the thread waits again. */
118
+ export declare function unmarkReviewRunAnswered(key: string): void;
119
+ /** Forgets every answer held here (a run that starts, "Waiting for you" turned off). */
120
+ export declare function resetReviewRunAnswered(): void;
121
+ /** Whether the thread was answered here a moment ago: it no longer waits, whatever the host's list says. */
122
+ export declare function reviewRunAnswered(key: string, now?: number): boolean;
123
+ /** Whether the thread's card stays listed under "Waiting for you" though it was answered (the setting is off). */
124
+ export declare function reviewRunKept(key: string): boolean;
125
+ export declare function subscribeReviewRunAnswered(listener: () => void): () => void;
126
+ /** Re-renders the caller when an answer is marked or undone; returns a number that changes with it. */
127
+ export declare function useReviewRunAnswered(): number;
128
+ export type ReviewRunAction = {
129
+ kind: 'answered' | 'replied' | 'done';
130
+ key: string;
131
+ /** An option picked: whether its write was saved. A refused answer was never given: the thread waits again. */
132
+ saved?: Promise<boolean>;
133
+ };
134
+ /**
135
+ * A card says what the person just did on it. True when a pane's run took it (it moves on, or keeps the card); false
136
+ * when none did and the card acts alone (Done then archives the thread itself).
137
+ */
138
+ export declare function notifyReviewRunAction(action: ReviewRunAction): boolean;
139
+ /**
140
+ * A reply is being sent from a comment box, until the returned call-back runs: the run's keys stand still meanwhile.
141
+ * The box's field is switched off while it sends and may lose the focus to the page, where a second Enter would
142
+ * otherwise pick the card's recommended option.
143
+ */
144
+ export declare function holdReviewRunKeys(): () => void;
145
+ /** How long the next card takes to come into place, as the next conversation does. */
146
+ export declare const REVIEW_RUN_TRAVEL_MS = 320;
147
+ /**
148
+ * A card comes into place the way the next conversation does: from below for next, from above for previous, over
149
+ * REVIEW_RUN_TRAVEL_MS; a fade alone for reduced motion.
150
+ */
151
+ export declare function cardComesIntoPlace(card: HTMLElement, direction: 'next' | 'previous'): void;
152
+ /** The card that takes the place of one that left the list: the key at the index `before` held it, when nothing else changed. */
153
+ export declare function cardThatTookThePlace(before: readonly string[], after: readonly string[]): string | null;
154
+ /**
155
+ * After an answer that moves on, Done or Delete, the next card comes into place: the card that takes the place of the
156
+ * one that left slides up into it. A list that changes any other way (a filter, a new comment, Undo) does not move.
157
+ */
158
+ export declare function useNextCardComesIntoPlace(rootRef: RefObject<HTMLElement | null>, scope: unknown): void;
159
+ /** How long after a run starts a list that fills in may still change which card is first. */
160
+ export declare const START_SETTLE_MS = 6000;
161
+ export interface ReviewRunPaneOptions {
162
+ controller: CommentController;
163
+ rootRef: RefObject<HTMLElement | null>;
164
+ /** The threads the pane can list (for the keys and the first card). */
165
+ threads: readonly CommentThread[];
166
+ /** A new comment is being written: the run's keys stand still. */
167
+ drafting: boolean;
168
+ /** The options of a thread's question still waiting for a pick, and the recommended one. */
169
+ asking(thread: CommentThread): {
170
+ comment: CommentRecord;
171
+ options: string[];
172
+ recommended: string | null;
173
+ } | null;
174
+ }
175
+ export interface ReviewRunPaneView {
176
+ /** "Waiting for you" is on in the host panel's main pane: the run's rules apply. */
177
+ running: boolean;
178
+ /** Attributes for the pane's root element. */
179
+ attrs: Record<string, string | undefined>;
180
+ /** The count the "n waiting" chip shows while a run is going; null: the chip reads "Waiting for you". */
181
+ count: number | null;
182
+ }
183
+ /**
184
+ * Whether a run going in the pane at `root` may take a key: the focus is in the Comments panel (the pane, its bar, a
185
+ * box of it) or nowhere (the page's body). An element of the page that holds the focus keeps its keys.
186
+ */
187
+ export declare function reviewRunHoldsKeys(root: HTMLElement): boolean;
188
+ /** Done on a card outside a run: archives it, then selects the card that takes its place, so E archives it in turn. */
189
+ export declare function archiveThenNext(controller: CommentController, root: CommentThread['root'], card: HTMLElement | null): void;
190
+ export declare function useReviewRunPane({ controller, rootRef, threads, drafting, asking }: ReviewRunPaneOptions): ReviewRunPaneView;
@@ -12,7 +12,11 @@
12
12
  * when the link fails.
13
13
  *
14
14
  * Until a root's links came back (and, with none, the page's best match), its Goes to line names nothing: `known` is
15
- * false, never a guess that turns into another thread a moment later. The last links of each root and the best match
15
+ * false, never a guess that turns into another thread a moment later. When those reads fail and nothing is kept,
16
+ * `lost` is true and the line shows nothing, never "a new thread"; a failed best match keeps the last one known.
17
+ *
18
+ * The server may name an agent's thread ahead of the links (`via`, SPC-458, SPC-459): it is where a reply goes, so
19
+ * `goesTo` names it, but it is no link (`linksOf` leaves it out). The last links of each root and the best match
16
20
  * of each page are kept for the session, per viewer and Space, so a page shown again names its threads at once while
17
21
  * they are read again.
18
22
  */
@@ -20,12 +24,22 @@ import type { SpaceCommentThreadPick, SpaceCommentThreadRef } from '../../space'
20
24
  export interface CommentRouting {
21
25
  /** True when the host links comment threads to threads: each card shows its Goes to line. */
22
26
  links: boolean;
23
- /** The threads a comment thread is linked to; the first is where a reply goes. */
27
+ /** The threads a comment thread is linked to; the first is where a reply goes unless an agent's thread takes it. */
24
28
  linksOf(rootKey: string): readonly SpaceCommentThreadRef[];
25
- /** Where a reply on this thread goes: its first link, else the best match (no link yet), else null (a new thread). */
29
+ /**
30
+ * Where a reply on this thread goes: the agent's thread the server names ahead of the links (`via`), else its first
31
+ * link, else the best match (no link yet), else null (a new thread).
32
+ */
26
33
  goesTo(rootKey: string): SpaceCommentThreadRef | null;
27
34
  /** The best-match thread for a new comment on this page (THR-024); null: none, or the host has no best match. */
28
35
  bestMatch: SpaceCommentThreadRef | null;
36
+ /** True when this page's best match could not be read and none is kept: the To chip names no thread. */
37
+ bestMatchLost?: boolean;
38
+ /**
39
+ * True when where this thread goes could not be read (its links, or with none the best match) and nothing is kept:
40
+ * the Goes to line shows nothing rather than a destination it does not know (never "a new thread").
41
+ */
42
+ lost?(rootKey: string): boolean;
29
43
  /** True when the host answers best matches: the new comment box shows its To chip. */
30
44
  hasBestMatch: boolean;
31
45
  /** The thread the next new comment goes to, when picked with the chip or @; null: the best match. */
@@ -57,8 +71,16 @@ export interface CommentRouting {
57
71
  export declare const LINK_BATCH = 200;
58
72
  /** Forgets every kept answer (tests). */
59
73
  export declare function clearCommentRoutingCache(): void;
74
+ /**
75
+ * A comment thread an agent outside Notis holds (the server's `claimed` ref, SPC-535): a reply stays with that agent
76
+ * and wakes nobody in Notis until the viewer hands it to a thread with Change.
77
+ */
78
+ export declare function outsideClaim(ref: SpaceCommentThreadRef | null | undefined): boolean;
79
+ /** A reply that wakes an agent another person runs (the server's `elsewhere` ref): no thread of the viewer's is named. */
80
+ export declare function elsewhere(ref: SpaceCommentThreadRef | null | undefined): boolean;
60
81
  export declare function useCommentRouting(input: {
61
- database: string;
82
+ /** @deprecated Comments live in one store: only splits the session cache. */
83
+ database?: string;
62
84
  /** Root record keys of the threads on screen (drafts left out): their links are read in one batch. */
63
85
  rootKeys: readonly string[];
64
86
  /** The record the page shows, for the best match. */