@notis_ai/cli 0.2.29 → 0.2.30

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 (64) hide show
  1. package/README.md +25 -8
  2. package/dist/agent-hooks/notis-agent-hook.mjs +1030 -610
  3. package/dist/base-skills/notis-cli/.notis-base-skill.json +1 -1
  4. package/dist/base-skills/notis-cli/SKILL.md +11 -0
  5. package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
  6. package/dist/base-skills/notis-spaces/references/release.md +6 -5
  7. package/dist/base-skills/notis-spaces/references/sdk.md +82 -17
  8. package/dist/sdk/src/hooks/useThreadItem.ts +56 -0
  9. package/dist/sdk/src/index.ts +6 -1
  10. package/dist/sdk/src/runtime.ts +8 -1
  11. package/dist/sdk/src/space.ts +230 -0
  12. package/dist/skill-sync-worker.mjs +185 -30
  13. package/dist/space-harness/host.js +237 -93
  14. package/dist/space-sdk/dist/{chunk-BFGB6XXC.js → chunk-6GJ2BS7B.js} +1 -3
  15. package/dist/space-sdk/dist/index.js +4 -2
  16. package/dist/space-sdk/dist/ui.js +18 -13
  17. package/dist/space-sdk/src/hooks/useThreadItem.d.ts +28 -0
  18. package/dist/space-sdk/src/index.d.ts +3 -1
  19. package/dist/space-sdk/src/runtime.d.ts +8 -1
  20. package/dist/space-sdk/src/space.ts +230 -0
  21. package/dist/space-sdk/src/tailwind-candidates.d.ts +492 -14
  22. package/dist/space-sdk/src/ui/actions/useToast.d.ts +2 -0
  23. package/dist/space-sdk/src/ui/comments/CommentPane.d.ts +56 -10
  24. package/dist/space-sdk/src/ui/comments/PassageComments.d.ts +16 -7
  25. package/dist/space-sdk/src/ui/comments/agentRuntime.d.ts +59 -0
  26. package/dist/space-sdk/src/ui/comments/commentFiles.d.ts +5 -2
  27. package/dist/space-sdk/src/ui/comments/commentModel.d.ts +103 -8
  28. package/dist/space-sdk/src/ui/comments/commentWords.d.ts +82 -0
  29. package/dist/space-sdk/src/ui/comments/hostComments.d.ts +37 -0
  30. package/dist/space-sdk/src/ui/comments/index.d.ts +4 -0
  31. package/dist/space-sdk/src/ui/comments/paneParts.d.ts +119 -0
  32. package/dist/space-sdk/src/ui/comments/useCommentRouting.d.ts +75 -0
  33. package/dist/space-sdk/src/ui/comments/useComments.d.ts +147 -15
  34. package/dist/space-sdk/src/ui/comments/usePassageComments.d.ts +24 -8
  35. package/dist/space-sdk/src/ui/index.d.ts +2 -1
  36. package/dist/space-sdk/src/ui/layout/SidePane.d.ts +6 -1
  37. package/dist/space-sdk/src/ui/overlay/Tooltip.d.ts +8 -2
  38. package/dist/space-sdk/src/ui/styles.d.ts +27 -5
  39. package/dist/view-renderer/dist/host.js +307 -163
  40. package/dist/view-renderer/src/host.tsx +6 -3
  41. package/dist/view-renderer/src/renderer.js +25 -2
  42. package/package.json +3 -3
  43. package/skills/notis-cli/AGENT_INSTRUCTIONS.md +2 -1
  44. package/skills/notis-spaces/cli.md +8 -8
  45. package/src/cli.js +10 -2
  46. package/src/command-specs/computer.js +21 -1
  47. package/src/command-specs/profile.js +12 -5
  48. package/src/command-specs/spaces.js +30 -16
  49. package/src/runtime/agent-identity.js +187 -0
  50. package/src/runtime/api-hosts.js +92 -0
  51. package/src/runtime/channel.js +3 -7
  52. package/src/runtime/oauth.js +95 -4
  53. package/src/runtime/profiles.js +200 -41
  54. package/src/runtime/skill-sync-service.js +4 -5
  55. package/src/runtime/space-platform.js +2 -0
  56. package/src/runtime/space-source.js +66 -1
  57. package/src/runtime/space-test-server.js +20 -4
  58. package/src/runtime/space-verification.js +5 -1
  59. package/src/runtime/telemetry.js +14 -1
  60. package/src/runtime/transport.js +12 -0
  61. package/src/runtime/upsell.js +3 -6
  62. package/src/runtime/view-render.js +3 -1
  63. package/src/skill-sync-worker.js +13 -2
  64. package/src/space-harness-host.ts +6 -3
@@ -0,0 +1,119 @@
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.
5
+ */
6
+ import React, { type ReactNode, type RefObject } from 'react';
7
+ import { type CommentGroup, type CommentOrder, type CommentThread } from './commentModel';
8
+ import type { SpaceCommentThreadRef } from '../../space';
9
+ import type { CommentWordKey } from './commentWords';
10
+ import type { CommentController, CommentMode, CommentStatusView } from './useComments';
11
+ export declare const COMMENT_MODE_ICON: Readonly<Record<CommentMode, string>>;
12
+ 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 }: {
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;
23
+ /**
24
+ * 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
+ * on a Space without point mode), or nothing when every mode opens the box at once (time, page).
26
+ */
27
+ export declare function commentIdleHint(controller: CommentController): CommentWordKey | null;
28
+ /** The short hint a mode shows until you point at something, with how to cancel it. */
29
+ export declare function CommentModeHint({ controller, className }: {
30
+ controller: CommentController;
31
+ className?: string;
32
+ }): React.JSX.Element | null;
33
+ /** A harness id as people read it: "claude" reads "Claude". */
34
+ export declare function commentHarnessName(harness: string | null | undefined): string;
35
+ /**
36
+ * How a thread a comment goes to is named: its title, or "a new Claude thread" for a new-thread pick or a pending link
37
+ * (no thread yet, the first wake starts it), or "a new thread" without one.
38
+ */
39
+ export declare function commentThreadName(controller: CommentController, thread: SpaceCommentThreadRef | {
40
+ newThread: string;
41
+ } | null): {
42
+ title: string;
43
+ to: string;
44
+ pending: boolean;
45
+ };
46
+ /**
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
49
+ * ends with an ellipsis (never cut mid-word without one); its title attribute has it in full.
50
+ */
51
+ export declare function CommentToChip({ controller }: {
52
+ controller: CommentController;
53
+ }): React.JSX.Element | null;
54
+ /**
55
+ * For a new comment's text box: an @ typed in the empty box opens the thread picker instead of writing the @. A pick
56
+ * leaves the box empty; dismissing the picker (Escape) puts the @ back with the caret after it, so "@Alice" still
57
+ * mentions someone. `setValue` writes the box's text.
58
+ */
59
+ export declare function useAtThreadPicker(controller: CommentController): (value: string, field: HTMLElement, setValue?: (value: string) => void) => string;
60
+ /**
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.
65
+ */
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[];
72
+ export interface CommentListOptions {
73
+ /**
74
+ * The order of the threads (SPC-116). Default 'newest': the newest thread first, by when its first comment was
75
+ * written (a reply never moves a thread). 'oldest', 'anchor' (the order of the anchors, then creation) or the
76
+ * Space's own comparator.
77
+ */
78
+ order?: CommentOrder;
79
+ /**
80
+ * Group headings. Default: by page when the controller covers the whole Space (no scope record), else none. Pass a
81
+ * function to group your way (by slide, by time, by status), or false for a flat list.
82
+ */
83
+ groupBy?: ((thread: CommentThread) => CommentGroup | null) | false;
84
+ }
85
+ /** 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 & {
87
+ controller: CommentController;
88
+ threads: readonly CommentThread[];
89
+ children: (thread: CommentThread) => ReactNode;
90
+ }): React.JSX.Element;
91
+ /**
92
+ * Scrolls the selected thread's card into view inside the pane's own scroller (C7): when a deep link or the page picks
93
+ * a thread (`threadKey`, and each `revealRequest`). While the panel is hidden (no height) or the card is not drawn
94
+ * yet, it waits; once both are there it reveals the card and keeps it in view while the panel finishes opening
95
+ * (`revealInScroller`: measured against the scroller, again on each resize and frame until the layout settles, then on
96
+ * each change of the card's size for a while, as its pictures load). The page around the panel never moves.
97
+ */
98
+ export declare function useThreadScroller(controller: CommentController, scrollRef: RefObject<HTMLElement | null>): void;
99
+ /**
100
+ * Keeps focus in the pane when the focused card leaves the list (archived with E, deleted): it moves to the card that
101
+ * took its place, else the pane, instead of falling to the page body, so Z and the next keys still reach the pane.
102
+ */
103
+ export declare function usePaneFocusKeeper(rootRef: RefObject<HTMLElement | null>, listKey: unknown): void;
104
+ /**
105
+ * A pane's own shortcut owner: E archives and Shift+E unarchives the focused (or selected) thread while focus is in
106
+ * the pane, and the Undo toast's Z belongs to this pane, so two panes on one page never clash.
107
+ */
108
+ export declare function CommentPaneKeys({ controller, rootRef, children }: {
109
+ controller: CommentController;
110
+ rootRef: RefObject<HTMLElement | null>;
111
+ children: ReactNode;
112
+ }): React.JSX.Element;
113
+ /**
114
+ * Placeholders where the threads come while the first read of the comments has not settled (C4): a page opened in a
115
+ * new tab shows that it is loading, never "No comments" for a moment before its threads arrive.
116
+ */
117
+ export declare function CommentListLoading({ controller }: {
118
+ controller: Pick<CommentController, 'say'>;
119
+ }): React.JSX.Element;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Where comment threads go (SPC-113, SPC-114, SPC-117): the manager threads each comment thread is linked to, the
3
+ * best-match thread a new comment goes to, and the host @ thread picker. Everything comes from the host Comments
4
+ * transport (`runtime.spaceComments`); a host without `links` shows no Goes to line, one without `bestMatch` no To chip.
5
+ *
6
+ * Links are read once per root and kept, at most `LINK_BATCH` roots per request: a root counts as read only once its
7
+ * answer came back, an answer that arrives after the screen moved on is still kept, and a failed read is tried again. A
8
+ * new transport object from the host (its viewer resolving) reads nothing again. A root is read again after a reply is
9
+ * sent and while its first link is a pending new thread (5 s, 15 s and 45 s later), until it names a real thread.
10
+ *
11
+ * A pick (Change, or the To chip of a new comment) shows at once, marked saving, and goes back with the error notice
12
+ * when the link fails.
13
+ *
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
16
+ * of each page are kept for the session, per viewer and Space, so a page shown again names its threads at once while
17
+ * they are read again.
18
+ */
19
+ import type { SpaceCommentThreadPick, SpaceCommentThreadRef } from '../../space';
20
+ export interface CommentRouting {
21
+ /** True when the host links comment threads to threads: each card shows its Goes to line. */
22
+ links: boolean;
23
+ /** The threads a comment thread is linked to; the first is where a reply goes. */
24
+ 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). */
26
+ goesTo(rootKey: string): SpaceCommentThreadRef | null;
27
+ /** The best-match thread for a new comment on this page (THR-024); null: none, or the host has no best match. */
28
+ bestMatch: SpaceCommentThreadRef | null;
29
+ /** True when the host answers best matches: the new comment box shows its To chip. */
30
+ hasBestMatch: boolean;
31
+ /** The thread the next new comment goes to, when picked with the chip or @; null: the best match. */
32
+ newPick: SpaceCommentThreadPick | null;
33
+ /** True when the host has the @ thread picker. */
34
+ canPick: boolean;
35
+ /** True when the host can link a comment thread to a thread: the Goes to line shows Change. */
36
+ canLink: boolean;
37
+ /** Opens the picker for the next new comment, under `anchor`. Resolves with the pick, or null when dismissed. */
38
+ pickForNew(anchor: HTMLElement): Promise<SpaceCommentThreadPick | null>;
39
+ clearPick(): void;
40
+ /** Change: opens the picker for a thread's replies and links the pick as where they go. */
41
+ change(rootKey: string, anchor: HTMLElement): Promise<void>;
42
+ /** Links a new comment thread, once its first comment is saved, to the pick or the best match. */
43
+ linkNew(rootKey: string): Promise<void>;
44
+ /** True while a pick for this thread is being linked: its Goes to line already names it. */
45
+ saving(rootKey: string): boolean;
46
+ /** Reads where this thread goes again, 5 s, 15 s and 45 s from now, until it names a real thread (after a reply). */
47
+ reread(rootKey: string): void;
48
+ /**
49
+ * False while where this thread goes is still being read (its links, or with none the page's best match): the Goes
50
+ * to line shows a neutral loading state instead of a destination. Absent: always known.
51
+ */
52
+ known?(rootKey: string): boolean;
53
+ /** Opens a manager thread in the chat; undefined on hosts without it. */
54
+ open?: (threadId: string) => void;
55
+ }
56
+ /** The most roots one links request asks for: more are split into several requests. */
57
+ export declare const LINK_BATCH = 200;
58
+ /** Forgets every kept answer (tests). */
59
+ export declare function clearCommentRoutingCache(): void;
60
+ export declare function useCommentRouting(input: {
61
+ database: string;
62
+ /** Root record keys of the threads on screen (drafts left out): their links are read in one batch. */
63
+ rootKeys: readonly string[];
64
+ /** The record the page shows, for the best match. */
65
+ recordKey: string | null;
66
+ /**
67
+ * The page's draft scope (`useComments` draftScope): a pick for the next new comment is kept per page, like the
68
+ * comment's text, so a pick made on one record never links another record's comment.
69
+ */
70
+ draftScope?: string | null;
71
+ /** Opens a thread when the host Comments transport has no `openThread` (the side chat transport). */
72
+ fallbackOpen?: (threadId: string) => void;
73
+ /** Called when a thread someone picked could not be linked, so they hear it instead of a silent "a new thread". */
74
+ onLinkFailed?: () => void;
75
+ }): CommentRouting;
@@ -1,20 +1,37 @@
1
1
  /**
2
2
  * The comment controller: reads a Comments database through the view's declared list, follows its live feed, writes
3
3
  * through the normal native mutations and keeps every change on screen at once (optimistic patches and drafts) until
4
- * the server rows carry it. `CommentPane`, `CommentPins` and `CommentThreadCard` render from it.
4
+ * the server rows carry it. `CommentPane`, `CommentPins`, `CommentToolBar` and `CommentThreadCard` render from it.
5
+ *
6
+ * People archive (Status `Resolved`, shown Done) and delete at once with a 6-second Undo toast and Z (SPC-124,
7
+ * SPC-133); agents never archive through it. Deleting a first comment deletes its thread; a later one leaves a "Comment
8
+ * deleted" line (SPC-127). Rights come from the host's viewer (SPC-128): you edit and delete your own comments, and a
9
+ * whole thread or someone else's comment needs Space edit rights. Without a viewer nothing can be edited or deleted.
10
+ * Under the host Comments panel a comment is written as the viewer (their name in Author, which the server stamps too)
11
+ * and nothing can be sent until the viewer is known (`canWrite`).
5
12
  */
6
13
  import { type MouseEvent as ReactMouseEvent, type PointerEvent as ReactPointerEvent } from 'react';
14
+ import { type SpaceCommentViewer } from '../../space';
7
15
  import { type Locale, type Words } from '../../words';
8
16
  import { type ToastController } from '../actions/useToast';
9
- import { type CommentAnchor, type CommentColumns, type CommentDigestOptions, type CommentRecord, type CommentScope, type CommentThread } from './commentModel';
17
+ import { type CommentAnchor, type CommentColumns, type CommentDigestOptions, type CommentGroup, type CommentRecord, type CommentScope, type CommentThread } from './commentModel';
10
18
  import { type CommentWordKey, type CommentWords } from './commentWords';
19
+ import { type CommentRouting } from './useCommentRouting';
11
20
  /** Which threads the pane lists: the current anchor's, or every thread in the scope. */
12
21
  export type CommentAnchorFilter = 'anchor' | 'all';
13
- /** Open threads, or resolved ones. */
14
- export type CommentStatusFilter = 'open' | 'resolved';
22
+ /** Open threads (default), archived ones (Done, stored as `Resolved`) or both (SPC-126): what the pane shows. */
23
+ export type CommentStatusView = 'open' | 'done' | 'all';
24
+ /** A status filter as `setStatusFilter` takes it: 'resolved' is an older name of 'done' and reads as 'done'. */
25
+ export type CommentStatusFilter = CommentStatusView | 'resolved';
26
+ /**
27
+ * What a new comment points at (SPC-118): words of the text, a point or a box on an anchor, some items (records or
28
+ * rows), a moment of a recording, or the whole page (no anchor).
29
+ */
30
+ export type CommentMode = 'text' | 'point' | 'box' | 'items' | 'time' | 'page';
15
31
  /**
16
32
  * A new comment being written: on an anchor, with a pin (x and y, 0 to 1), a zone (w and h too, 0 to 1 of the
17
- * anchor's size) or neither (on the whole anchor).
33
+ * anchor's size) or neither (on the whole anchor; `anchorKey` null: on the whole page). `items` lists the record keys
34
+ * (records or rows) of an items comment, `time` the seconds of a time comment.
18
35
  */
19
36
  export interface CommentDraftPin {
20
37
  anchorKey: string | null;
@@ -22,6 +39,8 @@ export interface CommentDraftPin {
22
39
  y: number | null;
23
40
  w: number | null;
24
41
  h: number | null;
42
+ items?: readonly CommentAnchor[] | null;
43
+ time?: number | null;
25
44
  }
26
45
  /** The zone being dragged on an anchor, 0 to 1 of its size. */
27
46
  export interface CommentDragZone {
@@ -51,15 +70,39 @@ export interface CommentFile {
51
70
  export type CommentAttachMode = 'on' | 'off' | 'checking';
52
71
  export interface CommentActions {
53
72
  /**
54
- * Adds a reply, with the files already uploaded for it. A reply reopens a resolved thread and answers an open input
55
- * ask. True once saved.
73
+ * Adds a reply, with the files already uploaded for it. It answers `answers` (an input ask on the first comment or a
74
+ * reply), else the latest open input ask in the thread; an archived thread stays archived (the server brings it back
75
+ * when a reply waits for someone). True once saved.
56
76
  */
57
- reply(thread: CommentThread, body: string, files?: readonly CommentFile[]): Promise<boolean>;
77
+ reply(thread: CommentThread, body: string, files?: readonly CommentFile[], answers?: CommentRecord): Promise<boolean>;
58
78
  /** Answers a check or choice ask. */
59
79
  answer(root: CommentRecord, answer: string): void;
80
+ /** Writes the status without a toast. People archive with `archive` and `unarchive`. */
60
81
  setStatus(root: CommentRecord, status: 'Open' | 'Resolved'): void;
61
- /** Opens the delete confirmation for the thread. */
82
+ /** Archives an open thread (Done) with a 6-second Undo toast; Z undoes. */
83
+ archive(root: CommentRecord): void;
84
+ /** Brings an archived thread back to Open, with Undo. */
85
+ unarchive(root: CommentRecord): void;
86
+ /**
87
+ * Deletes at once with Undo (no dialog): a first comment deletes its whole thread, a later one leaves a "Comment
88
+ * deleted" line. Does nothing unless `canDelete` allows it.
89
+ */
90
+ remove(comment: CommentRecord): void;
91
+ /** Same as `remove` on a thread's first comment. */
62
92
  askDelete(root: CommentRecord): void;
93
+ /**
94
+ * Saves new text for your own comment and marks it edited (Edited at, which Copy changes reports). Change keeps what
95
+ * it said (an archive or an answer is never overwritten); without an Edited at column Change and Changed at mark the
96
+ * edit unless they say resolved or answered. True once saved (or unchanged).
97
+ */
98
+ edit(comment: CommentRecord, body: string): Promise<boolean>;
99
+ /**
100
+ * Copies the link that opens this page with the thread revealed (`comment=<root key>`, as a push or a chat pill
101
+ * opens it): the host's address for it (`commentLink`), else the page's own address with that param. A toast says
102
+ * Link copied, or that it could not be copied. `host` (the card) holds the selection copy when the clipboard API is
103
+ * refused. True once copied.
104
+ */
105
+ copyLink(root: CommentRecord, host?: HTMLElement | null): Promise<boolean>;
63
106
  notify(words: Words | string): void;
64
107
  }
65
108
  export interface UseCommentsOptions {
@@ -76,7 +119,8 @@ export interface UseCommentsOptions {
76
119
  /**
77
120
  * The person using the Space; their comments count as changes and never as new activity. Default: the viewer's
78
121
  * first name from the host, and when the Author column refuses it (a choice list without that name) "Person",
79
- * then no author. Pass it to sign comments with a fixed name.
122
+ * then no author. Pass it to sign comments with a fixed name. Ignored under the host Comments panel: the viewer's
123
+ * name is used, for reading and writing.
80
124
  */
81
125
  me?: string;
82
126
  /** Authors the Author select knows; anyone else reads as `fallbackAuthor`. Default: any name. */
@@ -94,6 +138,26 @@ export interface UseCommentsOptions {
94
138
  live?: boolean;
95
139
  /** Called when a thread is picked (a pin, a card): the Space can move to its anchor and open its panel. */
96
140
  onSelectThread?(thread: CommentThread): void;
141
+ /**
142
+ * Open this comment's thread (a root or a reply key) once it is read, and scroll to it. Default: the `comment` view
143
+ * param of a link (`useCommentFocusParam`); null turns that off.
144
+ */
145
+ focusKey?: string | null;
146
+ /**
147
+ * The comment modes the Space offers (SPC-118), in the order the New comment menu and the tool bar list them.
148
+ * Default: point (and box with zone columns) when there are anchors, items and time when their call-backs are given,
149
+ * and the whole page. 'items' needs `onStartItems`, 'time' needs `currentTime`.
150
+ */
151
+ modes?: readonly CommentMode[];
152
+ /**
153
+ * Items mode: show your way of picking records or rows (checkboxes, a selection), then call
154
+ * `controller.startItems(items)` with the anchors picked. The hint shows until then; Escape cancels.
155
+ */
156
+ onStartItems?(): void;
157
+ /** Time mode: the current moment of the recording, in seconds. The new comment is written at that moment. */
158
+ currentTime?(): number | null | undefined;
159
+ /** Names of the pages (scope records, by id or record key) the Space home groups comments under. */
160
+ scopeNames?: Readonly<Record<string, string>>;
97
161
  }
98
162
  export interface CommentController {
99
163
  comments: CommentRecord[];
@@ -106,7 +170,10 @@ export interface CommentController {
106
170
  checkpoint: string | null;
107
171
  isNew(comment: CommentRecord): boolean;
108
172
  threadsOn(anchorKey: string | null | undefined): CommentThread[];
109
- /** The thread's pin number on its anchor (1-based), 0 when it is not there. */
173
+ /**
174
+ * The thread's pin number (1-based), 0 when it has none: per page (scope record), in the order its first comments
175
+ * were written, deleted ones keeping theirs, so a number never moves and reads the same on the page and the Space home.
176
+ */
110
177
  numberOf(thread: CommentThread): number;
111
178
  scope: CommentScope | null;
112
179
  anchors: readonly CommentAnchor[];
@@ -114,17 +181,65 @@ export interface CommentController {
114
181
  anchor: CommentAnchor | undefined;
115
182
  filter: CommentAnchorFilter;
116
183
  setFilter(filter: CommentAnchorFilter): void;
184
+ /** What the pane shows: never 'resolved' (typed wide so older comparisons with 'resolved' still compile). */
117
185
  statusFilter: CommentStatusFilter;
186
+ /** 'resolved' is read as 'done'. */
118
187
  setStatusFilter(filter: CommentStatusFilter): void;
188
+ /** Threads per status filter, for the current anchor filter. */
189
+ counts: Readonly<Record<CommentStatusView, number>>;
190
+ /** Threads per anchor filter ("This item", "All items"), for the current status filter. */
191
+ scopeCounts: Readonly<Record<CommentAnchorFilter, number>>;
192
+ /** True when the controller covers the whole Space (no scope record): the pane groups threads by page. */
193
+ wholeSpace: boolean;
194
+ /** The page a thread sits on, for grouping on the Space home: its scope record, else its anchor, else the Space. */
195
+ groupOf(thread: CommentThread): CommentGroup | null;
119
196
  threadKey: string | null;
120
197
  setThreadKey(key: string | null): void;
198
+ /** Picks a thread from the pane (a card): the page follows, the host panel stays as it is. */
121
199
  selectThread(thread: CommentThread): void;
200
+ /**
201
+ * Picks a thread from the page (a pin, a highlight, a key on the page): like `selectThread`, and asks the host to
202
+ * show it in its Comments panel (`revealRequest` goes up by one).
203
+ */
204
+ revealThread(thread: CommentThread): void;
205
+ /**
206
+ * Starts at 0 and goes up by one each time a comment is picked on the page (C8). The host opens its Comments panel
207
+ * on each increase and the pane scrolls the thread into view; picking inside the pane leaves it as it is.
208
+ */
209
+ revealRequest: number;
122
210
  actions: CommentActions;
123
- /** Add comment mode: the next click on the anchor drops a pin. Escape leaves it. */
211
+ /** The signed-in viewer from the host (name and Space edit rights), or null while unknown. */
212
+ viewer: SpaceCommentViewer | null;
213
+ /** Whether the viewer may edit this comment: their own, never an agent's. */
214
+ canEdit(comment: CommentRecord): boolean;
215
+ /** Whether the viewer may delete it: their own comment; a whole thread or someone else's needs Space edit rights. */
216
+ canDelete(comment: CommentRecord): boolean;
217
+ /** False while the host's viewer is not known: Send stays off, so no comment is written under a wrong name. */
218
+ canWrite: boolean;
219
+ /** Threads, Goes to and the To chip (SPC-113, SPC-114, SPC-117). */
220
+ routing: CommentRouting;
221
+ /** The comment modes this Space offers, in order. */
222
+ modes: readonly CommentMode[];
223
+ /** The mode waiting for you to point at something (its hint shows), or null. */
224
+ commentMode: CommentMode | null;
225
+ /** Starts a mode: point and box wait for a click or drag, text for a selection, items for `startItems`; time and page open the box at once. */
226
+ startMode(mode: CommentMode): void;
227
+ cancelMode(): void;
228
+ /** Items mode: starts a new comment on these anchors (records or rows). */
229
+ startItems(items: readonly CommentAnchor[]): void;
230
+ /** Whether the page comment tool bar shows (`CommentToolBar`, C toggles it). */
231
+ toolBar: boolean;
232
+ setToolBar(on: boolean): void;
233
+ /** Add comment mode (point or box): the next click on the anchor drops a pin. Escape leaves it. */
124
234
  commenting: boolean;
125
235
  setCommenting(on: boolean): void;
126
236
  toggleCommenting(): void;
127
237
  draftPin: CommentDraftPin | null;
238
+ /**
239
+ * Names this page's comments (the Space, the table and the scope record) for the drafts the boxes keep while they are
240
+ * away (`commentDrafts`): a reply, a new comment and an answer come back with what was typed and attached.
241
+ */
242
+ draftScope: string;
128
243
  /**
129
244
  * Starts a new comment on `anchorKey` at x, y (0 to 1), on a zone when w and h are given too, or on the whole
130
245
  * anchor when x and y are null.
@@ -138,9 +253,16 @@ export interface CommentController {
138
253
  dragZone: CommentDragZone | null;
139
254
  /** In Add comment mode: a click on the element drops a pin, a press and drag marks a zone. */
140
255
  zoneHandlers(anchorKey: string | null): CommentZoneHandlers;
256
+ /** Drops the new comment, and the thread picked for it. */
141
257
  cancelPin(): void;
142
258
  /** Saves the new comment with the files already uploaded for it. True once saved. */
143
259
  sendNew(body: string, files?: readonly CommentFile[]): Promise<boolean>;
260
+ /** @deprecated Delete happens at once with Undo (SPC-133): always null. */
261
+ deleting: CommentRecord | null;
262
+ /** @deprecated Nothing to cancel: delete happens at once with Undo. */
263
+ cancelDelete(): void;
264
+ /** @deprecated Deletes `comment` at once with Undo (`actions.remove`); without one it does nothing. */
265
+ confirmDelete(comment?: CommentRecord): Promise<void>;
144
266
  /**
145
267
  * 'on' when people can attach pictures and files: the table has the Attachments column and the host uploads files
146
268
  * (signed-in Editors in Notis; never on a Site, a link or a preview). 'off' leaves the pane text only.
@@ -155,9 +277,6 @@ export interface CommentController {
155
277
  }): Promise<CommentFile>;
156
278
  /** A shown picture failed to load (its signed address expired): reads the comments again, at most twice a minute. */
157
279
  refreshFiles(): void;
158
- deleting: CommentRecord | null;
159
- cancelDelete(): void;
160
- confirmDelete(): Promise<void>;
161
280
  /** Copies the digest and records the checkpoint. `host` is the Space's own element, for the selection fallback. */
162
281
  copyChanges(host: HTMLElement | null): Promise<boolean>;
163
282
  copying: boolean;
@@ -182,6 +301,19 @@ export interface CommentController {
182
301
  error: Error | null;
183
302
  refetch(): Promise<unknown>;
184
303
  }
304
+ /** How long a delete's Undo toast stays on a touch screen (a coarse pointer, or a phone-width window). */
305
+ export declare const DELETE_UNDO_TOUCH_MS = 8000;
306
+ /**
307
+ * The link that opens the page with one comment thread revealed: the host's (`commentLink`, a full address that names
308
+ * the thread's own page, possibly later as a promise), else the page's own address with `comment=<root key>` (any
309
+ * earlier comment param replaced). Null when neither is known.
310
+ */
311
+ export declare function commentLinkFor(host: {
312
+ commentLink?(input: {
313
+ rootKey: string;
314
+ database?: string;
315
+ }): string | null | Promise<string | null>;
316
+ } | null | undefined, rootKey: string, database?: string): string | null | Promise<string | null>;
185
317
  /** The neutral author a Comments database's choice list can offer for anyone it does not name. */
186
318
  export declare const COMMENT_PERSON_AUTHOR = "Person";
187
319
  /**
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * The controller for comments on passages of a record's text: a `useComments` controller (reading, live feed,
3
- * replies, Resolve, Delete) plus where each thread sits (its field and quoted words), the comment being written on a
4
- * selection, which threads read Text changed, and the reading order. `CommentableText`, `CommentableRichText` and
5
- * `PassageCommentPane` render from it.
3
+ * replies, Archive, Delete, Edit, where a thread goes) plus where each thread sits (its field and quoted words), the
4
+ * comment being written on a selection, which threads read Passage changed (their words are gone; they stay open with
5
+ * the old quote), and the reading order. `CommentableText`, `CommentableRichText` and `PassageCommentPane` render from
6
+ * it. Its modes default to text (a selection) and the whole page.
6
7
  */
7
8
  import { type CommentThread } from './commentModel';
8
- import { type CommentController, type UseCommentsOptions } from './useComments';
9
+ import { type CommentController, type CommentFile, type UseCommentsOptions } from './useComments';
9
10
  import { type PassageAnchor, type PassageColumns, type PassageField } from './passageModel';
10
11
  /** Where a thread was opened: its highlight in the text, its card or its quote in the pane, or a link to one comment. */
11
12
  export type PassageOpenedFrom = 'passage' | 'pane' | 'quote' | 'link';
@@ -25,11 +26,14 @@ export interface UsePassageCommentsOptions extends Omit<UseCommentsOptions, 'anc
25
26
  onOpen?(thread: CommentThread, passage: PassageAnchor | undefined, from: PassageOpenedFrom): void;
26
27
  /** A selection started a new comment: show the pane, which holds its box. */
27
28
  onDraft?(passage: PassageAnchor): void;
28
- /** Open the thread of this comment (a root or a reply) once it is read: a link to one comment. */
29
+ /**
30
+ * Open the thread of this comment (a root or a reply) once it is read: a link to one comment. Default: the
31
+ * `comment` view param (`useCommentFocusParam`); null turns that off.
32
+ */
29
33
  focusKey?: string | null;
30
34
  }
31
35
  export interface PassageCommentController {
32
- /** The underlying comment controller: thread cards, Resolve, Delete, the status filter and the toast. */
36
+ /** The underlying comment controller: thread cards, Archive, Delete, Edit, the status filter, routing and the toast. */
33
37
  controller: CommentController;
34
38
  fields: readonly PassageField[];
35
39
  field(key: string): PassageField | undefined;
@@ -46,10 +50,15 @@ export interface PassageCommentController {
46
50
  isChanged(rootKey: string): boolean;
47
51
  /** The comment being written on a selection. */
48
52
  draft: PassageAnchor | null;
53
+ /** The comment being placed or written on the page (the New comment menu): the same as `controller.draftPin`. */
54
+ draftPin: CommentController['draftPin'];
49
55
  startDraft(passage: PassageAnchor): void;
50
56
  cancelDraft(): void;
51
- /** Saves the draft. True once saved; its thread is then selected. */
52
- send(body: string): Promise<boolean>;
57
+ /**
58
+ * Saves the draft with its text and the pictures and files attached to it (SPC-131: paste, drop or the paperclip),
59
+ * either one enough. True once saved; its thread is then selected.
60
+ */
61
+ send(body: string, files?: readonly CommentFile[]): Promise<boolean>;
53
62
  sending: boolean;
54
63
  /** The last send failed. */
55
64
  failed: boolean;
@@ -59,8 +68,15 @@ export interface PassageCommentController {
59
68
  scroll: boolean;
60
69
  n: number;
61
70
  } | null;
71
+ /**
72
+ * Opens a thread: its passage flashes and the pane selects it. From the page ('passage': a highlight or a field's
73
+ * Comment count) or a link ('link') it is a reveal: `revealRequest` goes up by one and the host shows its Comments
74
+ * panel (C8). From the pane ('pane', 'quote') the panel stays as it is.
75
+ */
62
76
  open(thread: CommentThread, from: PassageOpenedFrom): void;
63
77
  openKey(rootKey: string, from: PassageOpenedFrom): void;
78
+ /** Starts at 0 and goes up by one on each comment picked on the page: the same number as `controller.revealRequest`. */
79
+ revealRequest: number;
64
80
  /** Rich text on screen reports which passages it shows: Text changed then follows what is rendered. */
65
81
  reportFound(field: string, keys: ReadonlySet<string> | null): void;
66
82
  }
@@ -18,7 +18,8 @@ export * from './open';
18
18
  export * from './blocks';
19
19
  export * from './gallery';
20
20
  export { Icon, hasIcon, renderIcon } from './icons';
21
- export { adoptToolkitStyles, getToolkitStyleSheet, getToolkitStyleText, registerToolkitStyles } from './styles';
21
+ export { adoptToolkitStyles, getToolkitStyleSheet, getToolkitStyleText, registerToolkitStyles, toolkitCascadeFor, TOOLKIT_CASCADE_LAYER } from './styles';
22
+ export type { AdoptToolkitOptions, ToolkitCascade } from './styles';
22
23
  export { COMPARES, DEFAULT_COMPARE, DEFAULT_PRESET, PRESETS, compareRange, customPeriod, dayCount, formatPeriodParam, fromIsoDay, isCompareId, isPresetId, normalizePeriod, parsePeriodParam, periodRanges, presetRange, samePeriod, toIsoDay, } from './period/periods';
23
24
  export type { CompareId, DateRange as PeriodRange, Period, PresetId } from './period/periods';
24
25
  export { dayNumberLabel, formatDateRange, formatDayHeading, formatDelta, formatDuration, formatLongDay, formatMonthYear, formatNumber, formatShortDay, formatValue, intlLocale, weekdayNames, } from './period/dateFormat';
@@ -23,7 +23,12 @@ export declare function clampSidePaneWidth(want: number, container: number | nul
23
23
  export interface SidePaneProps {
24
24
  /** The page. */
25
25
  children: ReactNode;
26
- /** The pane, always shown: beside the page while both fit, after it otherwise. */
26
+ /**
27
+ * The pane, always shown: beside the page while both fit, after it otherwise. A retired comment pane
28
+ * (`CommentPane`, `PassageCommentPane`) shows nothing here: the host Comments panel lists its threads. Only a
29
+ * direct `<CommentPane />` or `<PassageCommentPane />` element passed as `pane` is detected; one wrapped in another
30
+ * element or component keeps its pane column like any other pane.
31
+ */
27
32
  pane: ReactNode;
28
33
  /** The page never gets narrower than this beside the pane. */
29
34
  mainMin?: number;
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Tooltip (toolkit spec 2.8): a label and an optional shortcut on a black pill, the Manager's tooltip. Shows after
3
3
  * 500ms of hover or at once on keyboard focus; hides on leave, blur, a press or any key. Never takes focus.
4
+ * With `card`, it shows that content on a popover card instead (the chat timeline's hover card), still never focusable.
4
5
  */
5
- import React, { type ReactElement } from 'react';
6
+ import React, { type ReactElement, type ReactNode } from 'react';
6
7
  import type { KeySpec, Words } from '../../words';
7
8
  import type { Align, Side } from './position';
8
9
  export interface TooltipProps {
@@ -15,5 +16,10 @@ export interface TooltipProps {
15
16
  /** One focusable element. */
16
17
  children: ReactElement;
17
18
  disabled?: boolean;
19
+ /**
20
+ * Rich content shown on a popover card in place of the label (several lines, logos). The card only describes the
21
+ * trigger (aria-describedby), so give the trigger an accessible name that says the same in words.
22
+ */
23
+ card?: ReactNode;
18
24
  }
19
- export declare function Tooltip({ label, keys, side, align, delay, children, disabled }: TooltipProps): React.JSX.Element;
25
+ export declare function Tooltip({ label, keys, side, align, delay, children, disabled, card }: TooltipProps): React.JSX.Element;
@@ -6,16 +6,38 @@
6
6
  * the SDK never looks for the sheet among the page's own stylesheets, because a host that bundles its CSS would hand
7
7
  * over its whole merged stylesheet instead of the toolkit.
8
8
  */
9
+ /**
10
+ * The cascade layer the toolkit sits in inside a Space shadow root. It comes after Tailwind 4's preflight (`base`) and
11
+ * before its `utilities`, so a Space's utilities and its own CSS override a toolkit piece (`hidden sm:flex`, `px-6`)
12
+ * the way they override any element, while preflight never reaches it. The SDK shell (`styles.css`) sits just before.
13
+ */
14
+ export declare const TOOLKIT_CASCADE_LAYER = "components.notis-toolkit";
15
+ /**
16
+ * How the toolkit joins a root's cascade. `layered` (the default): in TOOLKIT_CASCADE_LAYER. `unlayered`: as plain
17
+ * rules, for a Space built with Tailwind 3, whose preflight is unlayered and would otherwise reset toolkit buttons.
18
+ */
19
+ export type ToolkitCascade = 'layered' | 'unlayered';
20
+ /**
21
+ * The cascade a Space's own compiled CSS needs: `unlayered` for Tailwind 3 output (its banner, or `--tw-` rules with
22
+ * no Tailwind 4 `base` or `utilities` layer block; the SDK stylesheet's order statement and its own sublayer do not
23
+ * count), else `layered`.
24
+ */
25
+ export declare function toolkitCascadeFor(css: string | null | undefined): ToolkitCascade;
9
26
  /** Registers the toolkit stylesheet: its CSS text, or an already built sheet. Later roots adopt this one. */
10
27
  export declare function registerToolkitStyles(source: string | CSSStyleSheet): void;
11
- /** The registered toolkit CSS text; null until the host registers it. */
28
+ /** The registered toolkit CSS text, as registered (no layer); null until the host registers it. */
12
29
  export declare function getToolkitStyleText(): string | null;
13
- /** The shared sheet; null without constructable stylesheets or until the host registers the CSS. */
14
- export declare function getToolkitStyleSheet(): CSSStyleSheet | null;
30
+ /** The shared sheet for a cascade; null without constructable stylesheets or until the host registers the CSS. */
31
+ export declare function getToolkitStyleSheet(cascade?: ToolkitCascade): CSSStyleSheet | null;
32
+ export interface AdoptToolkitOptions {
33
+ /** Default `layered`; pass `toolkitCascadeFor(spaceCss)` when the Space's CSS is known. */
34
+ cascade?: ToolkitCascade;
35
+ }
15
36
  /**
16
37
  * Adds the registered toolkit sheet to a document or shadow root, once. Without constructable stylesheets the root
17
- * gets one `<style>` element instead. Returns false, and adds nothing, while the host has not registered the CSS.
38
+ * gets one `<style>` element instead. Adopting again with the other cascade swaps the sheet in place. Returns false,
39
+ * and adds nothing, while the host has not registered the CSS.
18
40
  */
19
- export declare function adoptToolkitStyles(root: Document | ShadowRoot): boolean;
41
+ export declare function adoptToolkitStyles(root: Document | ShadowRoot, options?: AdoptToolkitOptions): boolean;
20
42
  /** Test hook: forget the registered sheet. */
21
43
  export declare function resetToolkitStylesForTests(): void;