@kortix/ui 0.15.10 → 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 (93) hide show
  1. package/dist/_vendor/kortix-shared.js +396 -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/pasted-content.d.ts +0 -4
  8. package/dist/_vendor/shared/pixel-mark.d.ts +0 -17
  9. package/dist/_vendor/shared/project-glyphs.d.ts +0 -1
  10. package/dist/customize/agents/agent-model-view.d.ts +11 -1
  11. package/dist/customize/agents/agent-model-view.js +12 -1
  12. package/dist/customize/agents/agent-page.js +19 -6
  13. package/dist/customize/agents/agent-tabs.d.ts +2 -0
  14. package/dist/customize/agents/agent-tabs.js +2 -0
  15. package/dist/customize/connectors/detail/connector-triggers.js +1 -1
  16. package/dist/customize/connectors/use-agent-access.d.ts +1 -0
  17. package/dist/customize/sections/component/teams-byo-wizard.js +4 -1
  18. package/dist/customize/triggers/runtime-triggers.js +13 -2
  19. package/dist/customize/triggers/schedule/event-trigger-copy.js +1 -1
  20. package/dist/customize/triggers/schedule/schedule-detail-sheet.js +5 -4
  21. package/dist/customize/triggers/schedule/then-fields.d.ts +5 -1
  22. package/dist/customize/triggers/schedule/then-fields.js +23 -3
  23. package/dist/customize/triggers/schedule/trigger-callouts.js +1 -1
  24. package/dist/customize/triggers/schedule/trigger-composer-logic.d.ts +27 -0
  25. package/dist/customize/triggers/schedule/trigger-composer-logic.js +51 -5
  26. package/dist/customize/triggers/schedule/trigger-composer.js +19 -13
  27. package/dist/customize/triggers/schedule/trigger-edit-logic.js +25 -5
  28. package/dist/customize/triggers/schedule/trigger-filter.d.ts +10 -3
  29. package/dist/customize/triggers/schedule/trigger-filter.js +7 -6
  30. package/dist/customize/triggers/schedule/trigger-readonly.js +1 -1
  31. package/dist/customize/triggers/schedule/trigger-runs-panel.js +1 -1
  32. package/dist/customize/triggers/schedule/when-event.js +1 -1
  33. package/dist/customize/triggers/schedule/when-schedule.d.ts +5 -1
  34. package/dist/customize/triggers/schedule/when-schedule.js +16 -1
  35. package/dist/customize/triggers/schedule-view.js +4 -2
  36. package/dist/i18n/en.d.ts +49 -0
  37. package/dist/i18n/en.js +57 -8
  38. package/dist/internal/layout/project-settings-nav.d.ts +17 -0
  39. package/dist/internal/layout/project-settings-nav.js +24 -0
  40. package/dist/internal/lib/capability-tab-routes.d.ts +8 -0
  41. package/dist/internal/lib/capability-tab-routes.js +11 -0
  42. package/dist/internal/stores/composer-prefill-store.d.ts +7 -0
  43. package/dist/internal/stores/composer-prefill-store.js +1 -0
  44. package/dist/session/actions/session-label.js +2 -2
  45. package/dist/session/agents/agent-strip.d.ts +10 -5
  46. package/dist/session/agents/agent-strip.js +40 -12
  47. package/dist/session/agents/held-messages.d.ts +6 -2
  48. package/dist/session/agents/held-messages.js +6 -3
  49. package/dist/session/composer/ComposerCard.js +4 -1
  50. package/dist/session/composer/agent-selector.d.ts +2 -0
  51. package/dist/session/composer/agent-selector.js +5 -0
  52. package/dist/session/composer/composer-chat-input.d.ts +1 -0
  53. package/dist/session/composer/composer-logic.d.ts +7 -0
  54. package/dist/session/composer/composer-logic.js +18 -0
  55. package/dist/session/composer/composer-reset.d.ts +8 -14
  56. package/dist/session/composer/composer-toolbar.d.ts +3 -1
  57. package/dist/session/composer/composer-toolbar.js +3 -3
  58. package/dist/session/composer/composer.d.ts +7 -0
  59. package/dist/session/composer/composer.js +17 -3
  60. package/dist/session/composer/editor/composer-editor.js +6 -4
  61. package/dist/session/header/session-site-header.d.ts +3 -1
  62. package/dist/session/header/session-site-header.js +3 -2
  63. package/dist/session/models/connect-model-step.d.ts +29 -0
  64. package/dist/session/models/connect-model-step.js +50 -0
  65. package/dist/session/models/use-workspace-model-gate.d.ts +11 -0
  66. package/dist/session/models/use-workspace-model-gate.js +62 -0
  67. package/dist/session/models/workspace-model-gate.d.ts +46 -0
  68. package/dist/session/models/workspace-model-gate.js +66 -0
  69. package/dist/session/prompts/session-connect-card.d.ts +63 -0
  70. package/dist/session/prompts/{session-connect-prompt.js → session-connect-card.js} +53 -42
  71. package/dist/session/thread/session-chat.js +294 -298
  72. package/dist/session/thread/transcript.d.ts +2 -1
  73. package/dist/session/thread/transcript.js +7 -3
  74. package/dist/session/tool/tool-part-renderer.js +7 -2
  75. package/dist/session/tool/tools/kortix-action-tool.js +10 -2
  76. package/dist/session/turn/turn-viewport.d.ts +66 -10
  77. package/dist/session/turn/turn-viewport.js +92 -12
  78. package/dist/session/turn/user-message.js +7 -5
  79. package/dist/styles.css +1 -1
  80. package/dist/test-utils/intl.d.ts +49 -0
  81. package/dist/workspace/admin/project-admin-dashboard.js +2 -4
  82. package/dist/workspace/home/existing-repo-setup-prompt.d.ts +5 -8
  83. package/dist/workspace/home/existing-repo-setup-prompt.js +16 -42
  84. package/dist/workspace/home/no-agent-home.d.ts +3 -1
  85. package/dist/workspace/home/no-agent-home.js +2 -2
  86. package/dist/workspace/layout/project-home.js +16 -9
  87. package/dist/workspace/sidebar/session-grouping.d.ts +1 -1
  88. package/dist/workspace/sidebar/session-grouping.js +1 -1
  89. package/dist/workspace/spaces/space-details-panel.js +2 -2
  90. package/dist/workspace/spaces/space-triggers.js +2 -2
  91. package/dist/workspace/spaces/space-view.js +11 -5
  92. package/package.json +15 -3
  93. package/dist/session/prompts/session-connect-prompt.d.ts +0 -40
@@ -345,7 +345,8 @@ declare function useTurnSegments({ blocks, answeredQuestionCallsById, shouldUseI
345
345
  /**
346
346
  * The segments a messages-only thread (`TranscriptRows.messagesOnly`) draws:
347
347
  * the agent's words and the deliverables it showed on purpose (`show`,
348
- * `image_gen`), plus a call that waits on the person's permission. Never a
348
+ * `image_gen`), plus a call that waits on the person's permission or started a
349
+ * connector sign-in (its Connect card). Never a
349
350
  * burst (tools, thinking) or another standalone call (a sub-agent card).
350
351
  * Settled, the interim sentences are work too: only the deliverables and the
351
352
  * final text stay, the rule of the "Worked for" fold (`splitSessionLogTurnWork`).
@@ -15,7 +15,7 @@ import { detectCommandFromText } from './detect-command.js';
15
15
  import { GenuiTelemetryContext } from '../../markdown/genui/block-telemetry.js';
16
16
  import { copyGenuiText } from '../../markdown/genui/to-markdown.js';
17
17
  import { useLocale, useTranslations } from '../../i18n/index.js';
18
- import { isSessionLogRestoreNote, sessionLogActivityText, sessionLogAnsweredQuestionCall, sessionLogBurstSteps, sessionLogOpenCall, sessionLogTurnSegments, sessionPromptActions, splitSessionLogTurnWork, sessionLogAgentRunLabel, isNoGroupActivityTool, toolCallMetadata, toolKind, } from '@kortix/sdk';
18
+ import { isSessionLogRestoreNote, sessionLogActivityText, sessionLogAnsweredQuestionCall, sessionLogBurstSteps, sessionLogOpenCall, sessionLogTurnSegments, sessionPromptActions, splitSessionLogTurnWork, sessionLogAgentRunLabel, isNoGroupActivityTool, toolCallMetadata, toolCallConnectorSignIns, toolKind, } from '@kortix/sdk';
19
19
  import { WarningIcon as AlertTriangle, CheckCircleIcon as CheckCircle, CheckIcon, CaretDownIcon as ChevronDown, ArrowSquareOutIcon as ExternalLink, StopCircleIcon, } from '@phosphor-icons/react';
20
20
  import { AnimatePresence, m } from 'motion/react';
21
21
  import { memo, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from 'react';
@@ -1203,7 +1203,8 @@ function segmentRendersSomething(segment) {
1203
1203
  /**
1204
1204
  * The segments a messages-only thread (`TranscriptRows.messagesOnly`) draws:
1205
1205
  * the agent's words and the deliverables it showed on purpose (`show`,
1206
- * `image_gen`), plus a call that waits on the person's permission. Never a
1206
+ * `image_gen`), plus a call that waits on the person's permission or started a
1207
+ * connector sign-in (its Connect card). Never a
1207
1208
  * burst (tools, thinking) or another standalone call (a sub-agent card).
1208
1209
  * Settled, the interim sentences are work too: only the deliverables and the
1209
1210
  * final text stay, the rule of the "Worked for" fold (`splitSessionLogTurnWork`).
@@ -1220,7 +1221,10 @@ export function messageOnlySegments(segments, options) {
1220
1221
  return segment.block.text.trim() !== '';
1221
1222
  if (segment.kind === 'show-group')
1222
1223
  return true;
1223
- return isNoGroupActivityTool(segment.block.name) || !!getPermissionForTool(options.permissions, segment.block.call_id);
1224
+ return (isNoGroupActivityTool(segment.block.name) ||
1225
+ !!getPermissionForTool(options.permissions, segment.block.call_id) ||
1226
+ // The call that started a connector sign-in: its Connect card waits on the person.
1227
+ toolCallConnectorSignIns(segment.block).length > 0);
1224
1228
  };
1225
1229
  const split = options.working ? null : splitSessionLogTurnWork(visible, { working: false });
1226
1230
  return (split ? [...split.hoisted, ...split.final] : visible).filter(kept);
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Button } from '../../primitives/button.js';
4
4
  import { STATUS_TEXT } from '../../primitives/status.js';
5
5
  import { QuestionPrompt } from '../prompts/question-prompt.js';
6
+ import { SessionConnectCard } from '../prompts/session-connect-card.js';
6
7
  import { GenericTool } from './generic-tool.js';
7
8
  import { BasicTool, BoundActivateContext, partOutcome, StalePendingContext, ToolActivateContext, ToolDurationContext, ToolNavigationContext, ToolOutcomeContext, ToolRunningContext, ToolSurfaceContext, TurnLiveContext, } from './shared/infrastructure.js';
8
9
  import { ToolRegistry } from './shared/registry.js';
@@ -14,7 +15,7 @@ import { partError, partMetadata, partStreamingInput } from './shared/infrastruc
14
15
  import { kortixCardTool, parseKortixToolResult } from './tools/kortix-tool-card.js';
15
16
  import { isWorkflowTool, parseWorkflowRun } from './tools/workflow-run.js';
16
17
  import { PERMISSION_LABELS, getChildSessionId, shouldShowToolPart, } from '../../internal/session-types/index.js';
17
- import { sessionLogCallStatus, sessionLogOpenCall, toolKind } from '@kortix/sdk';
18
+ import { sessionLogCallStatus, sessionLogOpenCall, toolCallConnectorSignIns, toolKind, } from '@kortix/sdk';
18
19
  import { useTranslations } from '../../i18n/index.js';
19
20
  import { memo, useCallback, useContext, useEffect, useMemo, useState } from 'react';
20
21
  function PermissionPromptInline({ permission, onReply }) {
@@ -70,6 +71,10 @@ function ToolPartRendererImpl({ call: given, sessionId, permission, question, on
70
71
  // tool that threw as far as the reader is concerned, so it must look
71
72
  // identical on the row too.
72
73
  const outcome = useMemo(() => partOutcome(call), [call]);
74
+ // The connector sign-ins this call started (`kortix connectors connect`, the
75
+ // `kortix_connectors` tool): their Connect card draws under the row. A call
76
+ // that failed (an error, a shell exit other than 0) started none.
77
+ const signIns = useMemo(() => toolCallConnectorSignIns(call), [call]);
73
78
  // The SDK's verdict on tools that never render (a todo read, context bookkeeping).
74
79
  if (!shouldShowToolPart(call))
75
80
  return null;
@@ -143,7 +148,7 @@ function ToolPartRendererImpl({ call: given, sessionId, permission, question, on
143
148
  // whole class of call permanently closed and unopenable on the panel — the
144
149
  // one surface where a single call IS the view.
145
150
  _jsx(GenericTool, { call: call, defaultOpen: defaultOpen, forceOpen: forceOpen, locked: isLocked }));
146
- return (_jsx(ToolNavigationContext.Provider, { value: !disableNavigation, children: _jsx(ToolRunningContext.Provider, { value: isRunning, children: _jsx(ToolOutcomeContext.Provider, { value: outcome, children: _jsx(ToolDurationContext.Provider, { value: toolDurationMs, children: _jsx(StalePendingContext.Provider, { value: isStalePending, children: _jsx(BoundActivateContext.Provider, { value: boundActivate, children: _jsxs("div", { className: cn('relative', fillsPanel && 'h-full'), children: [toolElement, permission && onPermissionReply && (_jsx("div", { className: "mt-1.5", children: _jsx(PermissionPromptInline, { permission: permission, onReply: onPermissionReply }) })), question && onQuestionReply && onQuestionReject && (_jsx("div", { className: "mt-1.5", children: _jsx(QuestionPrompt, { request: question, onReply: onQuestionReply, onReject: onQuestionReject }) }))] }) }) }) }) }) }) }));
151
+ return (_jsx(ToolNavigationContext.Provider, { value: !disableNavigation, children: _jsx(ToolRunningContext.Provider, { value: isRunning, children: _jsx(ToolOutcomeContext.Provider, { value: outcome, children: _jsx(ToolDurationContext.Provider, { value: toolDurationMs, children: _jsx(StalePendingContext.Provider, { value: isStalePending, children: _jsx(BoundActivateContext.Provider, { value: boundActivate, children: _jsxs("div", { className: cn('relative', fillsPanel && 'h-full'), children: [toolElement, signIns.length > 0 && _jsx(SessionConnectCard, { calls: signIns, className: "mt-1.5" }), permission && onPermissionReply && (_jsx("div", { className: "mt-1.5", children: _jsx(PermissionPromptInline, { permission: permission, onReply: onPermissionReply }) })), question && onQuestionReply && onQuestionReject && (_jsx("div", { className: "mt-1.5", children: _jsx(QuestionPrompt, { request: question, onReply: onQuestionReply, onReject: onQuestionReject }) }))] }) }) }) }) }) }) }));
147
152
  }
148
153
  /**
149
154
  * The tools whose rows are an agent's work: they open in place, never in the side panel.
@@ -15,7 +15,8 @@ import { UiLink } from '../../../providers/ui-provider.js';
15
15
  import { ArrowRightIcon, ArrowSquareOutIcon, CalendarDotsIcon, CaretRightIcon, ChartBarIcon, ChatsCircleIcon, CheckIcon, GitPullRequestIcon, SunDimIcon, HandPointingIcon, LockKeyIcon, PlugIcon, RobotIcon, UsersIcon, WarningIcon, } from '@phosphor-icons/react';
16
16
  import { useContext, useMemo } from 'react';
17
17
  import { MULTI_AGENT_ICON, multiAgentBody, PeerSendRow, runningKey } from './multi-agent-tool-bodies.js';
18
- import { parsePeerSend } from '@kortix/sdk';
18
+ import { parsePeerSend, toolCallConnectorSignIns } from '@kortix/sdk';
19
+ import { useSessionConnectRequests } from '../../prompts/session-connect-card.js';
19
20
  import { KORTIX_PLATFORM_TOOLS, isReadAction, kortixCardTool, kortixPlatformTool, multiAgentTool, parseKortixToolResult, } from './kortix-tool-card.js';
20
21
  const TOOL_META = {
21
22
  kortix_agents: { icon: RobotIcon, object: 'agents' },
@@ -96,6 +97,10 @@ export function KortixActionTool(props) {
96
97
  const settled = status === 'completed' || status === 'error';
97
98
  const raw = status === 'error' ? (partError(call) ?? '') : partRawOutput(call);
98
99
  const result = useMemo(() => (settled ? parseKortixToolResult(raw, call.name) : null), [settled, raw, call.name]);
100
+ // A `connect` in a session that finishes sign-ins: the Connect card under this
101
+ // row (`SessionConnectCard`) is the way in, so the raw provider link is not
102
+ // a second one.
103
+ const connectCardShown = useSessionConnectRequests() !== null && toolCallConnectorSignIns(call).length > 0;
99
104
  if (!tool || (settled && !result)) {
100
105
  return _jsx(GenericTool, { call: call, defaultOpen: defaultOpen, forceOpen: forceOpen, locked: locked });
101
106
  }
@@ -107,7 +112,10 @@ export function KortixActionTool(props) {
107
112
  : tMulti(`running.${runningKey(multi)}`);
108
113
  return (_jsx(BasicTool, { icon: icon, trigger: _jsx(CardTrigger, { title: title, live: running }), defaultOpen: defaultOpen, forceOpen: forceOpen, locked: locked }));
109
114
  }
110
- const { card, error } = result;
115
+ const { error } = result;
116
+ const card = connectCardShown
117
+ ? { ...result.card, links: result.card.links.filter((link) => !link.external) }
118
+ : result.card;
111
119
  // A message to another agent is one plain row with the receiver's face, sent or not.
112
120
  if (multi === 'send_message') {
113
121
  const send = parsePeerSend(result.data);
@@ -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
  }
@@ -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. */