@kortix/ui 0.15.9 → 0.15.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/dist/_vendor/kortix-shared.js +467 -2
  2. package/dist/_vendor/shared/app-config.d.ts +6 -30
  3. package/dist/_vendor/shared/channel-descriptors.d.ts +0 -34
  4. package/dist/_vendor/shared/channel-header.d.ts +2 -1
  5. package/dist/_vendor/shared/connector-sections.d.ts +0 -25
  6. package/dist/_vendor/shared/file-tags.d.ts +2 -1
  7. package/dist/_vendor/shared/index.d.ts +1 -0
  8. package/dist/_vendor/shared/pasted-content.d.ts +0 -4
  9. package/dist/_vendor/shared/pixel-mark.d.ts +0 -17
  10. package/dist/_vendor/shared/project-glyphs.d.ts +0 -1
  11. package/dist/_vendor/shared/session/attachment-tile.d.ts +32 -0
  12. package/dist/_vendor/shared/session/stop-refusal.d.ts +15 -0
  13. package/dist/_vendor/shared/session/tool-row-text.d.ts +58 -0
  14. package/dist/_vendor/shared/session-delivery.d.ts +2 -0
  15. package/dist/customize/agents/agent-model-view.d.ts +11 -1
  16. package/dist/customize/agents/agent-model-view.js +12 -1
  17. package/dist/customize/agents/agent-page.js +19 -6
  18. package/dist/customize/agents/agent-tabs.d.ts +2 -0
  19. package/dist/customize/agents/agent-tabs.js +2 -0
  20. package/dist/customize/connectors/connectors-page.js +1 -1
  21. package/dist/customize/connectors/detail/connector-page.js +9 -4
  22. package/dist/customize/connectors/detail/connector-triggers.js +1 -1
  23. package/dist/customize/connectors/install/use-install.js +1 -1
  24. package/dist/customize/connectors/use-agent-access.d.ts +1 -0
  25. package/dist/customize/providers/provider-accordion.js +5 -5
  26. package/dist/customize/providers/provider-connect.d.ts +3 -3
  27. package/dist/customize/providers/provider-connect.js +8 -16
  28. package/dist/customize/providers/provider-sheet.js +4 -4
  29. package/dist/customize/sections/component/teams-byo-wizard.js +4 -1
  30. package/dist/customize/sections/connector-connection-form.d.ts +0 -1
  31. package/dist/customize/sections/connector-connection-form.js +0 -9
  32. package/dist/customize/sections/view/review-center-connected.js +7 -3
  33. package/dist/customize/settings/tabs/workspace-keys.js +53 -11
  34. package/dist/customize/shared/feature-gate-screen.js +1 -1
  35. package/dist/customize/triggers/runtime-triggers.js +13 -2
  36. package/dist/customize/triggers/schedule/event-account-picker.js +1 -1
  37. package/dist/customize/triggers/schedule/event-trigger-copy.js +1 -1
  38. package/dist/customize/triggers/schedule/schedule-detail-sheet.js +5 -4
  39. package/dist/customize/triggers/schedule/then-fields.d.ts +5 -1
  40. package/dist/customize/triggers/schedule/then-fields.js +23 -3
  41. package/dist/customize/triggers/schedule/trigger-callouts.js +1 -1
  42. package/dist/customize/triggers/schedule/trigger-composer-logic.d.ts +27 -0
  43. package/dist/customize/triggers/schedule/trigger-composer-logic.js +51 -5
  44. package/dist/customize/triggers/schedule/trigger-composer.js +19 -13
  45. package/dist/customize/triggers/schedule/trigger-edit-logic.js +25 -5
  46. package/dist/customize/triggers/schedule/trigger-filter.d.ts +10 -3
  47. package/dist/customize/triggers/schedule/trigger-filter.js +7 -6
  48. package/dist/customize/triggers/schedule/trigger-readonly.js +1 -1
  49. package/dist/customize/triggers/schedule/trigger-runs-panel.js +1 -1
  50. package/dist/customize/triggers/schedule/use-event-app-connect.js +2 -1
  51. package/dist/customize/triggers/schedule/when-event.js +1 -1
  52. package/dist/customize/triggers/schedule/when-schedule.d.ts +5 -1
  53. package/dist/customize/triggers/schedule/when-schedule.js +16 -1
  54. package/dist/customize/triggers/schedule-view.js +4 -2
  55. package/dist/i18n/en.d.ts +56 -7
  56. package/dist/i18n/en.js +65 -16
  57. package/dist/internal/billing/compute-pricing.d.ts +7 -1
  58. package/dist/internal/billing/compute-pricing.js +7 -1
  59. package/dist/internal/hooks/connectors/invalidate-connections.d.ts +10 -0
  60. package/dist/internal/hooks/connectors/invalidate-connections.js +18 -0
  61. package/dist/internal/hooks/connectors/use-finish-sign-in.js +1 -1
  62. package/dist/internal/hooks/connectors/use-pipedream-connect-member.js +1 -1
  63. package/dist/internal/hooks/connectors/use-pipedream-connect-project.js +1 -1
  64. package/dist/internal/hooks/projects/use-new-project-session.d.ts +2 -0
  65. package/dist/internal/hooks/projects/use-new-project-session.js +4 -1
  66. package/dist/internal/hooks/use-review-session-summary.d.ts +1 -1
  67. package/dist/internal/hooks/use-review-session-summary.js +1 -1
  68. package/dist/internal/layout/project-settings-nav.d.ts +17 -0
  69. package/dist/internal/layout/project-settings-nav.js +24 -0
  70. package/dist/internal/lib/browser-noise/rules/injected-scripts.js +2 -2
  71. package/dist/internal/lib/capability-tab-routes.d.ts +8 -0
  72. package/dist/internal/lib/capability-tab-routes.js +11 -0
  73. package/dist/internal/notifications/notification-inbox.d.ts +4 -10
  74. package/dist/internal/notifications/notification-inbox.js +8 -9
  75. package/dist/internal/stores/composer-prefill-store.d.ts +7 -0
  76. package/dist/internal/stores/composer-prefill-store.js +1 -0
  77. package/dist/internal/stores/connector-gate-store.d.ts +3 -1
  78. package/dist/internal/stores/connector-gate-store.js +13 -3
  79. package/dist/internal/stores/upgrade-dialog-store.d.ts +4 -0
  80. package/dist/internal/stores/upgrade-dialog-store.js +2 -0
  81. package/dist/lib/routes.d.ts +4 -11
  82. package/dist/lib/routes.js +3 -5
  83. package/dist/markdown/unified-markdown-utils.d.ts +7 -0
  84. package/dist/markdown/unified-markdown-utils.js +19 -0
  85. package/dist/markdown/unified-markdown.js +16 -3
  86. package/dist/primitives/alert-dialog.js +1 -1
  87. package/dist/primitives/dialog.js +3 -1
  88. package/dist/primitives/drawer.js +1 -1
  89. package/dist/primitives/modal.js +1 -1
  90. package/dist/primitives/preview-image.js +1 -1
  91. package/dist/primitives/sheet.js +1 -1
  92. package/dist/session/actions/session-label.js +2 -2
  93. package/dist/session/agents/agent-strip.d.ts +10 -5
  94. package/dist/session/agents/agent-strip.js +40 -12
  95. package/dist/session/agents/held-messages.d.ts +6 -2
  96. package/dist/session/agents/held-messages.js +6 -3
  97. package/dist/session/composer/ComposerCard.js +8 -3
  98. package/dist/session/composer/agent-selector.d.ts +2 -0
  99. package/dist/session/composer/agent-selector.js +5 -0
  100. package/dist/session/composer/attachment-tile.d.ts +2 -26
  101. package/dist/session/composer/attachment-tile.js +3 -47
  102. package/dist/session/composer/composer-chat-input.d.ts +3 -1
  103. package/dist/session/composer/composer-chat-input.js +2 -2
  104. package/dist/session/composer/composer-logic.d.ts +7 -0
  105. package/dist/session/composer/composer-logic.js +18 -0
  106. package/dist/session/composer/composer-reset.d.ts +8 -14
  107. package/dist/session/composer/composer-toolbar.d.ts +3 -1
  108. package/dist/session/composer/composer-toolbar.js +3 -3
  109. package/dist/session/composer/composer.d.ts +9 -0
  110. package/dist/session/composer/composer.js +22 -11
  111. package/dist/session/composer/draft/home-composer-focus-handoff.d.ts +7 -0
  112. package/dist/session/composer/draft/home-composer-focus-handoff.js +94 -0
  113. package/dist/session/composer/draft/use-composer-draft.d.ts +3 -1
  114. package/dist/session/composer/draft/use-composer-draft.js +22 -2
  115. package/dist/session/composer/editor/composer-editor.d.ts +4 -2
  116. package/dist/session/composer/editor/composer-editor.js +13 -7
  117. package/dist/session/composer/hooks/use-composer-focus.js +4 -2
  118. package/dist/session/header/session-site-header.d.ts +3 -1
  119. package/dist/session/header/session-site-header.js +3 -2
  120. package/dist/session/index.d.ts +1 -0
  121. package/dist/session/index.js +1 -0
  122. package/dist/session/models/chatgpt-connection-button.js +5 -9
  123. package/dist/session/models/connect-model-step.d.ts +29 -0
  124. package/dist/session/models/connect-model-step.js +50 -0
  125. package/dist/session/models/model-connection-gate.d.ts +2 -1
  126. package/dist/session/models/model-connection-gate.js +6 -3
  127. package/dist/session/models/model-connection-layout.d.ts +2 -0
  128. package/dist/session/models/model-connection-layout.js +4 -0
  129. package/dist/session/models/model-selector.d.ts +1 -1
  130. package/dist/session/models/model-selector.js +9 -6
  131. package/dist/session/models/subscription-offer.d.ts +4 -0
  132. package/dist/session/models/subscription-offer.js +11 -3
  133. package/dist/session/models/use-workspace-model-gate.d.ts +11 -0
  134. package/dist/session/models/use-workspace-model-gate.js +62 -0
  135. package/dist/session/models/workspace-model-gate.d.ts +46 -0
  136. package/dist/session/models/workspace-model-gate.js +66 -0
  137. package/dist/session/overrides/session-overrides-toolbar.js +2 -4
  138. package/dist/session/prompts/ask-deck.d.ts +5 -1
  139. package/dist/session/prompts/ask-deck.js +15 -3
  140. package/dist/session/prompts/question-labels.d.ts +16 -0
  141. package/dist/session/prompts/question-labels.js +34 -0
  142. package/dist/session/prompts/question-prompt.js +6 -6
  143. package/dist/session/prompts/session-connect-card.d.ts +63 -0
  144. package/dist/session/prompts/{session-connect-prompt.js → session-connect-card.js} +53 -42
  145. package/dist/session/status/provisioning-failure.d.ts +23 -2
  146. package/dist/session/status/provisioning-failure.js +53 -3
  147. package/dist/session/status/stop-refusal.d.ts +6 -12
  148. package/dist/session/status/stop-refusal.js +6 -19
  149. package/dist/session/thread/agent-run-props.d.ts +19 -0
  150. package/dist/session/thread/agent-run-props.js +54 -0
  151. package/dist/session/thread/session-chat.js +317 -298
  152. package/dist/session/thread/transcript.d.ts +19 -2
  153. package/dist/session/thread/transcript.js +93 -25
  154. package/dist/session/tool/tool-part-renderer.js +7 -2
  155. package/dist/session/tool/tools/bash-tool.d.ts +3 -52
  156. package/dist/session/tool/tools/bash-tool.js +3 -86
  157. package/dist/session/tool/tools/kortix-action-tool.js +10 -2
  158. package/dist/session/turn/answer-streaming.d.ts +21 -0
  159. package/dist/session/turn/answer-streaming.js +34 -0
  160. package/dist/session/turn/queued-prompt-bubbles.d.ts +5 -0
  161. package/dist/session/turn/queued-prompt-bubbles.js +12 -0
  162. package/dist/session/turn/turn-viewport.d.ts +66 -10
  163. package/dist/session/turn/turn-viewport.js +92 -12
  164. package/dist/session/turn/turn-work-accordion.d.ts +3 -1
  165. package/dist/session/turn/turn-work-accordion.js +2 -2
  166. package/dist/session/turn/user-message.js +7 -5
  167. package/dist/styles.css +1 -1
  168. package/dist/test-utils/intl.d.ts +56 -7
  169. package/dist/workspace/admin/project-admin-dashboard.js +2 -4
  170. package/dist/workspace/home/existing-repo-setup-prompt.d.ts +5 -8
  171. package/dist/workspace/home/existing-repo-setup-prompt.js +16 -42
  172. package/dist/workspace/home/first-chat.d.ts +7 -1
  173. package/dist/workspace/home/first-chat.js +12 -5
  174. package/dist/workspace/home/no-agent-home.d.ts +3 -1
  175. package/dist/workspace/home/no-agent-home.js +2 -2
  176. package/dist/workspace/inbox/workspace-inbox.d.ts +6 -16
  177. package/dist/workspace/inbox/workspace-inbox.js +9 -51
  178. package/dist/workspace/layout/project-home.js +17 -16
  179. package/dist/workspace/layout/use-project-home-send.d.ts +2 -0
  180. package/dist/workspace/layout/use-project-home-send.js +29 -15
  181. package/dist/workspace/new/advanced-fields.d.ts +4 -1
  182. package/dist/workspace/new/advanced-fields.js +2 -2
  183. package/dist/workspace/new/workspace-name.d.ts +9 -0
  184. package/dist/workspace/new/workspace-name.js +20 -0
  185. package/dist/workspace/projects/session-starter.d.ts +6 -4
  186. package/dist/workspace/projects/session-starter.js +8 -14
  187. package/dist/workspace/review/review-center.d.ts +6 -2
  188. package/dist/workspace/review/review-center.js +45 -25
  189. package/dist/workspace/sidebar/session-grouping.d.ts +1 -1
  190. package/dist/workspace/sidebar/session-grouping.js +1 -1
  191. package/dist/workspace/sidebar/workspace-menu-model.d.ts +3 -5
  192. package/dist/workspace/sidebar/workspace-menu-model.js +1 -1
  193. package/dist/workspace/spaces/space-details-panel.js +2 -2
  194. package/dist/workspace/spaces/space-triggers.js +2 -2
  195. package/dist/workspace/spaces/space-view.js +11 -5
  196. package/package.json +15 -7
  197. package/skills/kortix-ui/references/modules.md +1 -1
  198. package/dist/customize/connectors/invalidate-connections.d.ts +0 -2
  199. package/dist/customize/connectors/invalidate-connections.js +0 -4
  200. package/dist/internal/notifications/use-inbox-summary.d.ts +0 -17
  201. package/dist/internal/notifications/use-inbox-summary.js +0 -28
  202. package/dist/session/prompts/session-connect-prompt.d.ts +0 -40
@@ -1,6 +1,9 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { newSessionHref } from '../../lib/routes.js';
4
+ import { UiLink } from '../../providers/ui-provider.js';
3
5
  import { Button } from '../../primitives/button.js';
6
+ import { ButtonGroup } from '../../primitives/button-group.js';
4
7
  import { InlineMeta } from '../../primitives/inline-meta.js';
5
8
  import { useTranslations } from '../../i18n/index.js';
6
9
  /** Pending text stays legible while the active turn continues above it. */
@@ -25,3 +28,12 @@ export function QueuedPromptFailure({ lastError, onRetry, onRemove, }) {
25
28
  const common = useTranslations('common');
26
29
  return (_jsx(InlineMeta, { children: _jsxs("span", { "data-queued-status": "failed", className: "flex items-center gap-1", children: [_jsxs("span", { className: "text-kortix-red", role: "status", title: lastError ?? undefined, children: [copy.raw('textcd5f943d5863'), lastError ? ` — ${lastError}` : ''] }), onRetry && (_jsx(Button, { type: "button", variant: "ghost", size: "xs", onClick: onRetry, children: copy.raw('text942087cc2d41') })), onRemove && (_jsx(Button, { type: "button", variant: "ghost", size: "xs", onClick: onRemove, children: common('remove') }))] }) }));
27
30
  }
31
+ /** A failed callback path requires a new computer, not a retry on the old one. */
32
+ export function QueuedPromptRecovery({ projectId, onRemove }) {
33
+ const sidebar = useTranslations('sidebar');
34
+ const turn = useTranslations('sessionUi.turn');
35
+ const common = useTranslations('common');
36
+ const newSession = projectId ? (_jsx(Button, { variant: "ghost", size: "xs", asChild: true, children: _jsx(UiLink, { href: newSessionHref(projectId), children: sidebar('newSession') }) })) : null;
37
+ const remove = onRemove ? (_jsx(Button, { type: "button", variant: "ghost", size: "xs", onClick: onRemove, children: common('remove') })) : null;
38
+ return (_jsxs("div", { "data-queued-status": "failed", className: "flex flex-col items-end gap-1", children: [_jsx("span", { role: "status", className: "text-kortix-red text-xs", children: turn('computerDisconnected') }), newSession && remove ? _jsxs(ButtonGroup, { children: [newSession, remove] }) : newSession ?? remove] }));
39
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Containment for a turn wrapper — and the two rules that make it safe.
2
+ * Containment for a turn wrapper — and the four rules that make it safe.
3
3
  *
4
4
  * `content-visibility: auto` lets the browser skip layout and paint for a turn
5
5
  * that is off screen. That is a real saving here: the transcript grows by a
@@ -21,9 +21,6 @@
21
21
  * while I scroll back"). So the stand-in is the turn's own measured height,
22
22
  * written per turn, and no turn is contained before it has one.
23
23
  *
24
- * RULE 3 — no containment below `TURN_MIN_CONTAIN_PX`. See its own comment:
25
- * a turn skipped at a near-zero stand-in can never come back.
26
- *
27
24
  * RULE 2 — no containment for an EMPTY turn, ever. A zero-height element can
28
25
  * never intersect the viewport, so `content-visibility: auto` classifies it as
29
26
  * "not relevant" and SKIPS it — permanently — and a skipped element stands in
@@ -37,6 +34,42 @@
37
34
  * because ANY empty turn reproduces it.) An empty turn also drops the spacing
38
35
  * its caller gave it, so a run of invisible turns contributes 0px, not a
39
36
  * stack of 48px margins.
37
+ *
38
+ * RULE 3 — no containment below `TURN_MIN_CONTAIN_PX`. See its own comment:
39
+ * a turn skipped at a near-zero stand-in can never come back.
40
+ *
41
+ * RULE 4 — containment is only ever ADDED while the turn is off screen.
42
+ * Chrome resolves `content-visibility: auto` relevance after the frame that
43
+ * adds the property, so a turn contained while the reader looks at it is
44
+ * skipped for that frame: its bubble and avatar report a `previousRect` of
45
+ * 0x0 and the turn box a stale one, and the frame is scored as a layout shift.
46
+ * Measured on a plain send (F-022, 2026-11-13): 0.026-0.046 per new turn,
47
+ * 900ms after it mounted (`TURN_SETTLE_MS` plus the measure frames), with an
48
+ * rAF probe that saw the turn's box never move. Forcing `content-visibility:
49
+ * visible` on the same build removed every turn shift. The queued turns of a
50
+ * burst each paid it in turn, which is where the audit's 0.107-0.141 shifts
51
+ * came from. Containment only saves work on a turn that is off screen, so
52
+ * holding it until the turn is out of view costs nothing: the turn is
53
+ * contained out of sight, where no shift is scored and none is seen. "Was off
54
+ * screen once" is not enough: a queued turn mounts below the fold, the
55
+ * auto-scroll brings it up, and its height settles 500ms later in full view
56
+ * (measured: 0.072 for one queued turn). So the decision is taken while the
57
+ * turn is out of view, and then held: once contained, `content-visibility:
58
+ * auto` tracks relevance by itself. Losing its stand-in (RULE 2/3) drops the
59
+ * hold, so containment comes back only out of view again.
60
+ *
61
+ * And it is granted only at the height the turn has AT THAT MOMENT. A turn
62
+ * contained for the first time out of view has no last-remembered size, so it
63
+ * stands in at the published height, and a turn that just grew has not
64
+ * published its new one yet (`TURN_SETTLE_MS`). Measured: a queued turn whose
65
+ * answer took it from 130px to 206px was scrolled off and contained at 130px
66
+ * in the same second, pulling everything under it up 76px (0.097). A height
67
+ * still settling waits for its publish, and the grant is checked again then.
68
+ *
69
+ * "Out of view" is read from layout at the moment of the grant, never from the
70
+ * observer's last report: that report is a frame late, and an auto-scroll can
71
+ * bring the turn on screen inside that frame. The observer only says WHEN to
72
+ * look again.
40
73
  */
41
74
  export type TurnMeasureState = 'unmeasured' | 'empty' | 'measured';
42
75
  /**
@@ -66,7 +99,26 @@ export declare const TURN_MIN_CONTAIN_PX = 48;
66
99
  * short to be a credible box, which is the case a stand-in can never recover
67
100
  * from.
68
101
  */
69
- export declare function turnIntrinsicSize(state: TurnMeasureState, measuredHeight: number): string | undefined;
102
+ export declare function turnIntrinsicSize(state: TurnMeasureState, measuredHeight: number, containedOffscreen: boolean): string | undefined;
103
+ /**
104
+ * RULE 4's hold, as one pure step. Dropped the moment the turn has no stand-in
105
+ * (RULE 2/3); kept once granted; granted only while the turn is out of view AND
106
+ * its current layout height is the published one.
107
+ */
108
+ export declare function nextContainHold(input: {
109
+ held: boolean;
110
+ hasStandIn: boolean;
111
+ outOfView: boolean;
112
+ heightSettled: boolean;
113
+ }): boolean;
114
+ /** RULE 4's geometry: no pixel of the turn is inside the visible band. */
115
+ export declare function turnOutOfView(turn: {
116
+ top: number;
117
+ bottom: number;
118
+ }, visible: {
119
+ top: number;
120
+ bottom: number;
121
+ }): boolean;
70
122
  /**
71
123
  * The wrapper's full class list. Pure and DOM-free so every rule above has a
72
124
  * test that can fail:
@@ -75,12 +127,14 @@ export declare function turnIntrinsicSize(state: TurnMeasureState, measuredHeigh
75
127
  * - `empty` → no containment (RULE 2), and `mt-0` AFTER the caller's
76
128
  * classes so tailwind-merge drops the caller's `mt-*`.
77
129
  * - `measured` → containment, but ONLY when it has a stand-in to be skipped
78
- * at (RULE 3). The size itself is an inline style, so the
79
- * class is driven by `turnIntrinsicSize` rather than by the
80
- * state: that is what makes "contained" and "has a stand-in"
81
- * the same fact instead of two that can disagree.
130
+ * at (RULE 3) and the hold was granted out of view, at
131
+ * its current height (RULE 4). The size itself is an
132
+ * inline style, so the class is driven by
133
+ * `turnIntrinsicSize` rather than by the state: that is
134
+ * what makes "contained" and "has a stand-in" the same fact
135
+ * instead of two that can disagree.
82
136
  */
83
- export declare function turnViewportClassName(state: TurnMeasureState, className?: string, measuredHeight?: number): string;
137
+ export declare function turnViewportClassName(state: TurnMeasureState, className?: string, measuredHeight?: number, containedOffscreen?: boolean): string;
84
138
  /**
85
139
  * How long a turn's height must hold still before it is allowed to skip.
86
140
  *
@@ -132,6 +186,8 @@ export declare function turnLayoutHeight(el: HTMLElement): number;
132
186
  export declare function useTurnMeasure(ref: React.RefObject<HTMLDivElement | null>): {
133
187
  state: TurnMeasureState;
134
188
  height: number;
189
+ /** RULE 4: containment was granted while the turn was out of view. */
190
+ containedOffscreen: boolean;
135
191
  };
136
192
  /**
137
193
  * One turn's wrapper: the scroll anchor (`data-turn-id`) plus the containment
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { cn } from '../../lib/utils.js';
4
- import { useEffect, useRef, useState } from 'react';
4
+ import { useEffect, useLayoutEffect, useRef, useState } from 'react';
5
5
  /**
6
6
  * The smallest stand-in a turn may be skipped at — RULE 3.
7
7
  *
@@ -29,13 +29,51 @@ export const TURN_MIN_CONTAIN_PX = 48;
29
29
  * short to be a credible box, which is the case a stand-in can never recover
30
30
  * from.
31
31
  */
32
- export function turnIntrinsicSize(state, measuredHeight) {
32
+ export function turnIntrinsicSize(state, measuredHeight, containedOffscreen) {
33
33
  if (state !== 'measured')
34
34
  return undefined;
35
+ if (!containedOffscreen)
36
+ return undefined; // RULE 4
35
37
  if (!(measuredHeight >= TURN_MIN_CONTAIN_PX))
36
38
  return undefined;
37
39
  return `auto ${measuredHeight}px`;
38
40
  }
41
+ /**
42
+ * RULE 4's hold, as one pure step. Dropped the moment the turn has no stand-in
43
+ * (RULE 2/3); kept once granted; granted only while the turn is out of view AND
44
+ * its current layout height is the published one.
45
+ */
46
+ export function nextContainHold(input) {
47
+ if (!input.hasStandIn)
48
+ return false;
49
+ if (input.held)
50
+ return true;
51
+ return input.outOfView && input.heightSettled;
52
+ }
53
+ /** RULE 4's geometry: no pixel of the turn is inside the visible band. */
54
+ export function turnOutOfView(turn, visible) {
55
+ return turn.bottom <= visible.top || turn.top >= visible.bottom;
56
+ }
57
+ /**
58
+ * The band a turn can be seen in: its nearest clipping ancestor's box, clipped
59
+ * to the window. A clip wrapper inside the scroller only narrows the band, so
60
+ * the error is always "in view" (left uncontained), never a visible turn
61
+ * contained.
62
+ */
63
+ function visibleBand(el) {
64
+ let top = 0;
65
+ let bottom = window.innerHeight;
66
+ for (let a = el.parentElement; a; a = a.parentElement) {
67
+ const overflowY = getComputedStyle(a).overflowY;
68
+ if (overflowY === 'auto' || overflowY === 'scroll' || overflowY === 'hidden') {
69
+ const r = a.getBoundingClientRect();
70
+ top = Math.max(top, r.top);
71
+ bottom = Math.min(bottom, r.bottom);
72
+ break;
73
+ }
74
+ }
75
+ return { top, bottom };
76
+ }
39
77
  /**
40
78
  * The wrapper's full class list. Pure and DOM-free so every rule above has a
41
79
  * test that can fail:
@@ -44,13 +82,15 @@ export function turnIntrinsicSize(state, measuredHeight) {
44
82
  * - `empty` → no containment (RULE 2), and `mt-0` AFTER the caller's
45
83
  * classes so tailwind-merge drops the caller's `mt-*`.
46
84
  * - `measured` → containment, but ONLY when it has a stand-in to be skipped
47
- * at (RULE 3). The size itself is an inline style, so the
48
- * class is driven by `turnIntrinsicSize` rather than by the
49
- * state: that is what makes "contained" and "has a stand-in"
50
- * the same fact instead of two that can disagree.
85
+ * at (RULE 3) and the hold was granted out of view, at
86
+ * its current height (RULE 4). The size itself is an
87
+ * inline style, so the class is driven by
88
+ * `turnIntrinsicSize` rather than by the state: that is
89
+ * what makes "contained" and "has a stand-in" the same fact
90
+ * instead of two that can disagree.
51
91
  */
52
- export function turnViewportClassName(state, className, measuredHeight = 0) {
53
- return cn(turnIntrinsicSize(state, measuredHeight) !== undefined && '[content-visibility:auto]', className, state === 'empty' && 'mt-0');
92
+ export function turnViewportClassName(state, className, measuredHeight = 0, containedOffscreen = false) {
93
+ return cn(turnIntrinsicSize(state, measuredHeight, containedOffscreen) !== undefined && '[content-visibility:auto]', className, state === 'empty' && 'mt-0');
54
94
  }
55
95
  /**
56
96
  * How long a turn's height must hold still before it is allowed to skip.
@@ -103,6 +143,24 @@ export function turnLayoutHeight(el) {
103
143
  * value.
104
144
  */
105
145
  export function useTurnMeasure(ref) {
146
+ // RULE 4. Whether the turn is in view right now. The scroll container clips
147
+ // the turn, so a root-less observer sees it leave. Starts as "in view": a
148
+ // turn is never contained before the observer has reported once.
149
+ const [inView, setInView] = useState(true);
150
+ const [containedOffscreen, setContainedOffscreen] = useState(false);
151
+ useEffect(() => {
152
+ const el = ref.current;
153
+ // Held: `content-visibility: auto` tracks relevance now; stop observing.
154
+ if (!el || containedOffscreen || typeof IntersectionObserver === 'undefined')
155
+ return;
156
+ const io = new IntersectionObserver((entries) => {
157
+ const entry = entries[entries.length - 1];
158
+ if (entry)
159
+ setInView(entry.isIntersecting);
160
+ });
161
+ io.observe(el);
162
+ return () => io.disconnect();
163
+ }, [ref, containedOffscreen]);
106
164
  const [measure, setMeasure] = useState({
107
165
  state: 'unmeasured',
108
166
  height: 0,
@@ -151,7 +209,29 @@ export function useTurnMeasure(ref) {
151
209
  ro?.disconnect();
152
210
  };
153
211
  }, [ref]);
154
- return measure;
212
+ // The hold (`nextContainHold`). Dropping it needs no layout read: a guarded
213
+ // render-phase update, so the class goes in the commit that loses the
214
+ // stand-in. Granting reads layout, so it is a layout effect: the geometry
215
+ // check and the class land in the same frame.
216
+ const hasStandIn = turnIntrinsicSize(measure.state, measure.height, true) !== undefined;
217
+ if (!hasStandIn && containedOffscreen)
218
+ setContainedOffscreen(false);
219
+ useLayoutEffect(() => {
220
+ const el = ref.current;
221
+ if (!el || containedOffscreen || !hasStandIn || inView)
222
+ return;
223
+ const box = el.getBoundingClientRect();
224
+ const grant = nextContainHold({
225
+ held: false,
226
+ hasStandIn,
227
+ outOfView: turnOutOfView(box, visibleBand(el)),
228
+ // Still settling: the publish re-runs this with the height it settles at.
229
+ heightSettled: box.height === measure.height,
230
+ });
231
+ if (grant)
232
+ setContainedOffscreen(true);
233
+ }, [ref, measure.height, hasStandIn, inView, containedOffscreen]);
234
+ return { ...measure, containedOffscreen };
155
235
  }
156
236
  /**
157
237
  * One turn's wrapper: the scroll anchor (`data-turn-id`) plus the containment
@@ -159,7 +239,7 @@ export function useTurnMeasure(ref) {
159
239
  */
160
240
  export function TurnViewport({ turnId, className, continues, children, }) {
161
241
  const ref = useRef(null);
162
- const { state, height } = useTurnMeasure(ref);
163
- const containIntrinsicSize = turnIntrinsicSize(state, height);
164
- return (_jsx("div", { ref: ref, "data-turn-id": turnId, "data-turn-continues": continues || undefined, className: turnViewportClassName(state, className, height), style: containIntrinsicSize ? { containIntrinsicSize } : undefined, children: children }));
242
+ const { state, height, containedOffscreen } = useTurnMeasure(ref);
243
+ const containIntrinsicSize = turnIntrinsicSize(state, height, containedOffscreen);
244
+ return (_jsx("div", { ref: ref, "data-turn-id": turnId, "data-turn-continues": continues || undefined, className: turnViewportClassName(state, className, height, containedOffscreen), style: containIntrinsicSize ? { containIntrinsicSize } : undefined, children: children }));
165
245
  }
@@ -9,7 +9,9 @@ export declare const WorkFoldContext: import("react").Context<boolean>;
9
9
  * the reader touched while it worked settles with its row open.
10
10
  */
11
11
  export declare const WorkTouchContext: import("react").Context<(() => void) | null>;
12
- export declare function TurnWorkAccordion({ durationMs, open, onToggle, contentId, }: {
12
+ export declare function TurnWorkAccordion({ label, durationMs, open, onToggle, contentId, }: {
13
+ /** The row's words in place of "Worked for …": an agent run's (`sessionLogAgentRunLabel`). */
14
+ label?: string;
13
15
  /** `sessionTurnDurationMs(turn)`; `null` reads "Worked". */
14
16
  durationMs: number | null;
15
17
  open: boolean;
@@ -27,6 +27,6 @@ export const WorkFoldContext = createContext(false);
27
27
  * the reader touched while it worked settles with its row open.
28
28
  */
29
29
  export const WorkTouchContext = createContext(null);
30
- export function TurnWorkAccordion({ durationMs, open, onToggle, contentId, }) {
31
- return (_jsx("div", { className: cn('flex items-center', open && 'border-border/60 border-b pb-2'), children: _jsxs("button", { type: "button", "aria-expanded": open, "aria-controls": open ? contentId : undefined, onClick: onToggle, className: cn('group/work text-muted-foreground/70 hover:text-muted-foreground flex min-w-0 cursor-pointer items-center gap-2', 'focus-visible:ring-ring/50 rounded-sm text-left text-sm transition-colors select-none focus-visible:ring-2 focus-visible:outline-none'), children: [_jsx("span", { className: "min-w-0 truncate tabular-nums", children: workedForLabel(durationMs) }), _jsx(CaretRightIcon, { "aria-hidden": true, className: cn('text-muted-foreground/40 group-hover/work:text-muted-foreground/70 size-3.5 flex-none transition-[transform,color]', open && 'rotate-90') })] }) }));
30
+ export function TurnWorkAccordion({ label, durationMs, open, onToggle, contentId, }) {
31
+ return (_jsx("div", { className: cn('flex items-center', open && 'border-border/60 border-b pb-2'), children: _jsxs("button", { type: "button", "aria-expanded": open, "aria-controls": open ? contentId : undefined, onClick: onToggle, className: cn('group/work text-muted-foreground/70 hover:text-muted-foreground flex min-w-0 cursor-pointer items-center gap-2', 'focus-visible:ring-ring/50 rounded-sm text-left text-sm transition-colors select-none focus-visible:ring-2 focus-visible:outline-none'), children: [_jsx("span", { className: "min-w-0 truncate tabular-nums", children: label ?? workedForLabel(durationMs) }), _jsx(CaretRightIcon, { "aria-hidden": true, className: cn('text-muted-foreground/40 group-hover/work:text-muted-foreground/70 size-3.5 flex-none transition-[transform,color]', open && 'rotate-90') })] }) }));
32
32
  }
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { attachmentMime } from '../../internal/lib/attachment-mime.js';
4
4
  import { AttachmentPreview } from './attachment-preview.js';
5
5
  import { getFileCategory } from '../../files/viewer/preview-policy.js';
6
- import { remindersHref } from '../../internal/lib/capability-tab-routes.js';
6
+ import { triggerHref } from '../../internal/lib/capability-tab-routes.js';
7
+ import { useTriggersPageOpen } from '../../internal/layout/project-settings-nav.js';
7
8
  import { MessageSenderAbove } from '../participants/session-participants.js';
8
9
  import { MessageAuthorLabel } from './message-author-label.js';
9
10
  import { MESSAGE_TEXT_CLASS, RowToolbar } from './message-row.js';
@@ -127,8 +128,8 @@ function PlatformPromptMessage({ pill, text, actions, ...data }) {
127
128
  }
128
129
  /**
129
130
  * A loop fire (`[REMINDER reminder.<id> …]`, the wire name). The pill says
130
- * Loop and whether it repeats; its card carries the id and a link to the
131
- * project's Loops page, filtered to this session.
131
+ * Loop and whether it repeats; its card carries the id and a Manage link to
132
+ * the loop's own row on the Triggers page (`?id=<reminder id>`).
132
133
  */
133
134
  /**
134
135
  * A voice call's turn the voice answered itself (voice-turn.ts): the caller's words as their own bubble under a Call
@@ -141,8 +142,9 @@ function VoiceTurnMessage({ info, actions }) {
141
142
  function ReminderMessage({ info, actions }) {
142
143
  const t = useTranslations('reminders');
143
144
  const ids = useSessionIds();
144
- const loopsHref = ids.projectId ? remindersHref(ids.projectId) : null;
145
- const manageHref = loopsHref && ids.sessionId ? `${loopsHref}?session=${ids.sessionId}` : null;
145
+ // The loop's own row on the Triggers page, shown only to a caller that page lets in.
146
+ const canOpenTriggers = useTriggersPageOpen(ids.projectId ?? undefined);
147
+ const manageHref = ids.projectId && canOpenTriggers ? triggerHref(ids.projectId, info.id) : null;
146
148
  return (_jsx(PlatformPromptMessage, { "data-testid": "reminder-turn", "data-reminder-id": info.id, text: info.prompt, actions: actions, pill: _jsx(SourcePill, { mark: _jsx(AlarmIcon, { className: "size-3 shrink-0", "aria-hidden": true }), source: t('cardLabel'), sender: info.recurring ? t('cardRecurring') : t('cardOneTime'), card: _jsx(SourceCard, { mark: _jsx(AlarmIcon, { className: "size-3.5 shrink-0", "aria-hidden": true }), title: t('cardLabel'), footer: _jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx("span", { className: "text-muted-foreground truncate font-mono", children: info.id }), manageHref && (_jsx(HoverPrefetchLink, { href: manageHref, className: "text-foreground shrink-0 font-medium underline-offset-2 hover:underline", children: t('cardManage') }))] }) }) }) }));
147
149
  }
148
150
  /** A trigger fire (`<trigger_event>{…}</trigger_event>`): the trigger's name in the pill, the prompt in the bubble. */