@agent-native/core 0.154.4 → 0.155.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +1 -1
- package/corpus/templates/analytics/.agents/skills/account-health/SKILL.md +76 -0
- package/corpus/templates/analytics/.agents/skills/bigquery/SKILL.md +3 -0
- package/corpus/templates/analytics/.agents/skills/cross-source-analysis/SKILL.md +2 -1
- package/corpus/templates/analytics/.agents/skills/data-querying/SKILL.md +6 -5
- package/corpus/templates/analytics/AGENTS.md +3 -0
- package/corpus/templates/analytics/actions/account-deep-dive.ts +3 -2
- package/corpus/templates/analytics/actions/bigquery.ts +1 -1
- package/corpus/templates/analytics/app/components/dashboard/SqlChart.tsx +4 -1
- package/corpus/templates/analytics/app/components/layout/NewDashboardDialog.tsx +1 -0
- package/corpus/templates/analytics/app/pages/adhoc/explorer/components/PropertyCombobox.tsx +12 -4
- package/corpus/templates/analytics/app/pages/adhoc/explorer/components/PropertyValueCombobox.tsx +5 -2
- package/corpus/templates/analytics/app/pages/adhoc/explorer/property-label.ts +32 -0
- package/corpus/templates/analytics/changelog/2026-08-13-account-health-readouts-verify-customer-scope-and-contract-metrics.md +7 -0
- package/corpus/templates/analytics/server/jobs/analytics-bigquery-backfill.ts +43 -17
- package/corpus/templates/analytics/server/lib/analytics-query-catalog.ts +17 -0
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +4 -0
- package/corpus/templates/calendar/AGENTS.md +2 -0
- package/corpus/templates/calendar/DEVELOPING.md +4 -4
- package/corpus/templates/calendar/actions/get-settings.ts +4 -11
- package/corpus/templates/calendar/actions/update-availability.ts +15 -4
- package/corpus/templates/calendar/actions/update-settings.ts +15 -4
- package/corpus/templates/calendar/app/components/booking/DatePicker.tsx +9 -3
- package/corpus/templates/calendar/app/components/calendar/CreateEventDialog.tsx +21 -19
- package/corpus/templates/calendar/app/components/calendar/EventDetailPopover.tsx +9 -6
- package/corpus/templates/calendar/app/components/calendar/FindTimePanel.tsx +25 -3
- package/corpus/templates/calendar/app/components/calendar/InlineEventPickers.tsx +10 -3
- package/corpus/templates/calendar/app/components/calendar/MonthView.tsx +9 -9
- package/corpus/templates/calendar/app/components/calendar/WeekView.tsx +11 -3
- package/corpus/templates/calendar/app/components/layout/Sidebar.tsx +10 -4
- package/corpus/templates/calendar/app/i18n-data.ts +30 -0
- package/corpus/templates/calendar/app/lib/availability-schedule.ts +53 -0
- package/corpus/templates/calendar/app/lib/event-form-utils.ts +5 -0
- package/corpus/templates/calendar/app/pages/AvailabilitySettings.tsx +90 -28
- package/corpus/templates/calendar/app/pages/BookingLinksPage.tsx +135 -61
- package/corpus/templates/calendar/app/pages/BookingPage.tsx +2 -0
- package/corpus/templates/calendar/app/pages/CalendarView.tsx +30 -15
- package/corpus/templates/calendar/app/pages/Settings.tsx +60 -1
- package/corpus/templates/calendar/changelog/2026-08-13-find-a-time-now-closes-from-a-clear-header-action.md +6 -0
- package/corpus/templates/calendar/server/handlers/bookings.ts +2 -1
- package/corpus/templates/calendar/server/handlers/settings.ts +12 -16
- package/corpus/templates/calendar/shared/api.ts +1 -0
- package/corpus/templates/calendar/shared/availability-schedule.ts +64 -0
- package/corpus/templates/calendar/shared/calendar-week.ts +21 -0
- package/corpus/templates/calendar/shared/settings.ts +44 -0
- package/corpus/templates/clips/AGENTS.md +2 -0
- package/corpus/templates/clips/actions/add-comment.ts +5 -2
- package/corpus/templates/clips/actions/finalize-recording.ts +31 -1
- package/corpus/templates/clips/actions/get-recording-player-data.ts +9 -0
- package/corpus/templates/clips/actions/lib/ensure-seekable-video.ts +21 -1
- package/corpus/templates/clips/actions/reply-to-comment.ts +5 -2
- package/corpus/templates/clips/actions/update-comment.ts +9 -2
- package/corpus/templates/clips/app/components/library/search-bar.tsx +26 -13
- package/corpus/templates/clips/app/components/meetings/share-meeting-dialog.tsx +135 -3
- package/corpus/templates/clips/app/components/player/comments-panel.tsx +5 -99
- package/corpus/templates/clips/app/components/player/playback-comment-overlay.tsx +7 -3
- package/corpus/templates/clips/app/components/player/video-player.tsx +84 -24
- package/corpus/templates/clips/app/components/workspace/notifications-list.tsx +11 -3
- package/corpus/templates/clips/app/i18n/en-US.ts +12 -0
- package/corpus/templates/clips/app/lib/public-meeting.ts +11 -3
- package/corpus/templates/clips/app/lib/search-focus.ts +15 -0
- package/corpus/templates/clips/app/root.tsx +2 -1
- package/corpus/templates/clips/app/routes/_app.meetings._index.tsx +94 -26
- package/corpus/templates/clips/app/routes/_app.settings._index.tsx +24 -7
- package/corpus/templates/clips/app/routes/embed.$shareId.tsx +8 -4
- package/corpus/templates/clips/app/routes/r.$recordingId.tsx +14 -7
- package/corpus/templates/clips/app/routes/share.$shareId.tsx +8 -4
- package/corpus/templates/clips/app/routes/share.meeting.$meetingId.tsx +72 -26
- package/corpus/templates/clips/changelog/2026-08-13-inline-markdown-comments.md +6 -0
- package/corpus/templates/clips/changelog/2026-08-13-private-meeting-agent-links.md +6 -0
- package/corpus/templates/clips/desktop/src/app.tsx +116 -19
- package/corpus/templates/clips/desktop/src/lib/recorder.ts +13 -29
- package/corpus/templates/clips/desktop/src/lib/recording-request.ts +39 -0
- package/corpus/templates/clips/desktop/src/lib/settings-navigation.ts +11 -0
- package/corpus/templates/clips/desktop/src/lib/whisper-model-picker.ts +7 -0
- package/corpus/templates/clips/desktop/src/styles.css +117 -0
- package/corpus/templates/clips/server/db/index.ts +10 -0
- package/corpus/templates/clips/server/db/schema.ts +1 -0
- package/corpus/templates/clips/server/lib/recordings.ts +3 -1
- package/corpus/templates/clips/server/lib/seekable-media-state.ts +90 -0
- package/corpus/templates/clips/server/plugins/db.ts +5 -0
- package/corpus/templates/clips/server/routes/api/public-meeting.get.ts +37 -4
- package/corpus/templates/clips/server/routes/api/public-recording.get.ts +16 -5
- package/corpus/templates/clips/shared/clips-ai-prefs.ts +3 -0
- package/corpus/templates/clips/shared/meeting-agent-access.ts +5 -0
- package/corpus/templates/content/.agents/skills/content/SKILL.md +2 -2
- package/corpus/templates/content/.agents/skills/document-editing/references/databases.md +20 -4
- package/corpus/templates/content/actions/_database-row-mutation.ts +1490 -0
- package/corpus/templates/content/actions/_database-utils.ts +44 -0
- package/corpus/templates/content/actions/_property-utils.ts +4 -1
- package/corpus/templates/content/actions/add-comment.ts +2 -1
- package/corpus/templates/content/actions/add-database-item.ts +62 -240
- package/corpus/templates/content/actions/configure-document-property.ts +165 -1
- package/corpus/templates/content/actions/delete-document-property.ts +18 -0
- package/corpus/templates/content/actions/set-document-property.ts +78 -1
- package/corpus/templates/content/actions/update-comment.ts +1 -1
- package/corpus/templates/content/actions/update-database-item.ts +62 -0
- package/corpus/templates/content/actions/upsert-database-item-by-key.ts +43 -796
- package/corpus/templates/content/app/components/editor/CommentsSidebar.tsx +24 -15
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +10 -8
- package/corpus/templates/content/app/hooks/use-content-database.ts +33 -32
- package/corpus/templates/content/changelog/2026-08-10-database-row-actions-now-validate-exact-schemas-and-safe-ret.md +6 -0
- package/corpus/templates/content/parity/matrix.md +1 -1
- package/corpus/templates/content/parity/matrix.ts +2 -0
- package/corpus/templates/content/server/db/schema.ts +39 -3
- package/corpus/templates/content/server/plugins/db.ts +30 -0
- package/corpus/templates/content/shared/api.ts +75 -2
- package/corpus/templates/design/actions/generate-design.ts +10 -7
- package/corpus/templates/design/actions/present-design-variants.ts +35 -6
- package/corpus/templates/design/actions/run-design-audit.ts +33 -0
- package/corpus/templates/design/changelog/2026-08-13-the-design-audit-now-catches-a-screen-that-renders-behind-an.md +6 -0
- package/corpus/templates/design/shared/design-review.ts +1 -0
- package/corpus/templates/design/shared/html-integrity.ts +66 -0
- package/corpus/templates/dispatch/.env.example +5 -0
- package/corpus/templates/dispatch/AGENTS.md +24 -19
- package/corpus/templates/dispatch/app/i18n-data.ts +20 -0
- package/corpus/templates/dispatch/server/lib/identity-sso.ts +21 -90
- package/corpus/templates/dispatch/server/plugins/identity-sso.ts +3 -12
- package/corpus/templates/dispatch/shared/feature-flags.ts +4 -0
- package/corpus/templates/factory/AGENTS.md +5 -1
- package/corpus/templates/factory/README.md +23 -0
- package/corpus/templates/factory/actions/view-screen.ts +17 -0
- package/corpus/templates/factory/app/components/factory/FactoryAgentsView.tsx +239 -0
- package/corpus/templates/factory/app/components/factory/FactoryCanvas.tsx +2 -0
- package/corpus/templates/factory/app/components/factory/FactoryInspector.tsx +130 -7
- package/corpus/templates/factory/app/i18n/en-US.ts +20 -0
- package/corpus/templates/factory/app/routes/factory.tsx +41 -0
- package/corpus/templates/factory/package.json +1 -0
- package/corpus/templates/factory/server/factory-graph/contracts.ts +2 -0
- package/corpus/templates/factory/server/plugins/agent-chat.ts +9 -0
- package/corpus/templates/factory/server/plugins/dispatch-db.ts +1 -0
- package/corpus/templates/factory/server/plugins/setup-dispatch.ts +3 -0
- package/corpus/templates/mail/app/lib/native-mcp-exclusions.ts +3 -0
- package/corpus/templates/mail/vite.config.ts +7 -0
- package/corpus/templates/plan/actions/reply-to-plan-comment.ts +7 -2
- package/corpus/templates/plan/actions/resolve-plan-comment.ts +2 -2
- package/corpus/templates/plan/actions/update-visual-plan.ts +1 -1
- package/corpus/templates/plan/app/pages/PlansPage.tsx +29 -20
- package/corpus/templates/slides/actions/add-slide-comment.ts +1 -1
- package/corpus/templates/slides/actions/update-slide-comment.ts +1 -1
- package/corpus/templates/slides/app/components/comments/SlideCommentsPanel.tsx +9 -6
- package/dist/action.d.ts +22 -0
- package/dist/action.js +27 -0
- package/dist/agent/production-agent.js +5 -1
- package/dist/agent/thread-data-builder.js +17 -1
- package/dist/cli/skills-content/help.js +6 -4
- package/dist/cli/skills.js +17 -2
- package/dist/cli/workspacify.d.ts +5 -0
- package/dist/cli/workspacify.js +65 -8
- package/dist/client/AgentPanel.d.ts +5 -0
- package/dist/client/AgentPanel.js +20 -4
- package/dist/client/AssistantChat.d.ts +21 -0
- package/dist/client/AssistantChat.js +66 -68
- package/dist/client/active-run-state.d.ts +14 -1
- package/dist/client/active-run-state.js +0 -0
- package/dist/client/agent-chat-adapter.js +107 -5
- package/dist/client/analytics.js +9 -2
- package/dist/client/chat/tool-call-display.js +4 -4
- package/dist/client/chat-first/apps-rail.js +9 -4
- package/dist/client/chat-first/primary-nav.d.ts +2 -1
- package/dist/client/chat-first/primary-nav.js +3 -3
- package/dist/client/chat-first/types.d.ts +5 -1
- package/dist/client/markdown/InlineMarkdown.d.ts +23 -0
- package/dist/client/markdown/InlineMarkdown.js +65 -0
- package/dist/client/markdown/index.d.ts +1 -0
- package/dist/client/markdown/index.js +1 -0
- package/dist/client/review/ReviewThreadPanel.js +2 -1
- package/dist/client/run-stream-ownership.d.ts +39 -0
- package/dist/client/run-stream-ownership.js +65 -0
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/feature-flags/index.d.ts +1 -1
- package/dist/feature-flags/index.js +1 -1
- package/dist/feature-flags/store.d.ts +10 -0
- package/dist/feature-flags/store.js +112 -1
- package/dist/guards/no-env-credentials.js +4 -0
- package/dist/index.browser.d.ts +1 -1
- package/dist/index.browser.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/integrations/adapters/slack.js +5 -1
- package/dist/localization/default-messages.d.ts +1 -0
- package/dist/localization/default-messages.js +1 -0
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/observability/routes.d.ts +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +11 -11
- package/dist/provider-api/actions/provider-api.d.ts +15 -15
- package/dist/resources/agents.js +40 -5
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/resources/metadata.d.ts +10 -0
- package/dist/resources/metadata.js +7 -3
- package/dist/review/actions/create-review-comment.js +1 -1
- package/dist/review/actions/reply-review-comment.js +1 -1
- package/dist/review/actions/resolve-review-thread.js +1 -1
- package/dist/server/action-routes.js +42 -8
- package/dist/server/agent-discovery.js +14 -3
- package/dist/server/core-routes-plugin.js +1 -1
- package/dist/server/identity-sso-migrations.d.ts +7 -0
- package/dist/server/identity-sso-migrations.js +36 -0
- package/dist/server/identity-sso-store.d.ts +3 -2
- package/dist/server/identity-sso-store.js +8 -3
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/server/release-migrations.js +4 -0
- package/dist/tracking/providers.js +13 -3
- package/dist/workspace-files/tool.js +1 -1
- package/package.json +3 -2
|
@@ -35,6 +35,7 @@ import { GuidedQuestionFlow, useGuidedQuestionFlow, } from "./guided-questions.j
|
|
|
35
35
|
import { buildSignInReturnHref } from "./require-session.js";
|
|
36
36
|
import { addMcpConnectionCompleteListener, consumeMcpConnectionResume, } from "./resources/mcp-connection-resume.js";
|
|
37
37
|
import { McpConnectionSuggestion } from "./resources/McpConnectionSuggestion.js";
|
|
38
|
+
import { claimRunStream, createRunStreamToken, ownsRunStream, releaseRunStream, } from "./run-stream-ownership.js";
|
|
38
39
|
import { AgentAutoContinueSignal, readSSEStreamRaw, settleInterruptedToolCalls, } from "./sse-event-processor.js";
|
|
39
40
|
import { useAgentEngineConfigured } from "./use-agent-engine-configured.js";
|
|
40
41
|
import { useDevMode } from "./use-dev-mode.js";
|
|
@@ -786,6 +787,27 @@ function trimReconnectTextAlreadyRendered(content, renderedAssistantText, option
|
|
|
786
787
|
}
|
|
787
788
|
return changed ? next : content;
|
|
788
789
|
}
|
|
790
|
+
/**
|
|
791
|
+
* Whether the reconnect overlay — a SECOND fold of a run, rendered as a sibling
|
|
792
|
+
* of the message list — may appear.
|
|
793
|
+
*
|
|
794
|
+
* The adapter runtime and the reconnect reader both fold the same SSE events
|
|
795
|
+
* into their own accumulator. Whenever both are on screen the user sees the
|
|
796
|
+
* turn twice: duplicate tool cards (one spinning, one static) and the final
|
|
797
|
+
* message streaming in two places. Content-similarity dedupe cannot reliably
|
|
798
|
+
* hide the second copy, because the two readers disagree on tool-call identity
|
|
799
|
+
* (id-less activity cards get reader-local ids) and on how a turn is split
|
|
800
|
+
* across assistant messages.
|
|
801
|
+
*
|
|
802
|
+
* So ownership decides visibility, not similarity: if a runtime owns the turn,
|
|
803
|
+
* the overlay does not render. Keep this a pure function — it is the invariant
|
|
804
|
+
* the duplicate-render bug kept violating, and it must stay falsifiable.
|
|
805
|
+
*/
|
|
806
|
+
export function shouldShowReconnectOverlay(state) {
|
|
807
|
+
if (state.isRuntimeRunning)
|
|
808
|
+
return false;
|
|
809
|
+
return state.isReconnecting || state.reconnectFrozen;
|
|
810
|
+
}
|
|
789
811
|
export function dedupeReconnectContentAgainstMessages(content, messages, options) {
|
|
790
812
|
if (content.length === 0)
|
|
791
813
|
return content;
|
|
@@ -1605,7 +1627,6 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1605
1627
|
const [reconnectFrozen, setReconnectFrozen] = useState(false);
|
|
1606
1628
|
// Adapter took over while reconnect still had visible tool cards — keep the
|
|
1607
1629
|
// overlay until the adapter message catches up so we don't flash an empty gap.
|
|
1608
|
-
const [adapterHandoffPending, setAdapterHandoffPending] = useState(false);
|
|
1609
1630
|
const reconnectRunIdRef = useRef(null);
|
|
1610
1631
|
const reconnectTurnIdRef = useRef(null);
|
|
1611
1632
|
const reconnectTailOnlyRef = useRef(false);
|
|
@@ -1624,7 +1645,6 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1624
1645
|
setIsReconnecting(false);
|
|
1625
1646
|
setReconnectFrozen(false);
|
|
1626
1647
|
setReconnectContent([]);
|
|
1627
|
-
setAdapterHandoffPending(false);
|
|
1628
1648
|
setPendingReconnectRecovery(null);
|
|
1629
1649
|
resetRunningActivity();
|
|
1630
1650
|
}, [resetRunningActivity]);
|
|
@@ -1702,14 +1722,9 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1702
1722
|
isReconnecting,
|
|
1703
1723
|
hasReconnectContent: reconnectContent.length > 0,
|
|
1704
1724
|
});
|
|
1705
|
-
const reconnectActivityContent = useMemo(() => isReconnecting || reconnectFrozen
|
|
1725
|
+
const reconnectActivityContent = useMemo(() => isReconnecting || reconnectFrozen
|
|
1706
1726
|
? reconnectActivityFallbackContent(runningActivityTool)
|
|
1707
|
-
: [], [
|
|
1708
|
-
adapterHandoffPending,
|
|
1709
|
-
isReconnecting,
|
|
1710
|
-
reconnectFrozen,
|
|
1711
|
-
runningActivityTool,
|
|
1712
|
-
]);
|
|
1727
|
+
: [], [isReconnecting, reconnectFrozen, runningActivityTool]);
|
|
1713
1728
|
const lastBroadcastRunningRef = useRef(isRunning);
|
|
1714
1729
|
const tiptapRef = useRef(null);
|
|
1715
1730
|
const focusComposerAfterConnectRef = useRef(false);
|
|
@@ -2010,6 +2025,13 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
2010
2025
|
if (isRuntimeRunningRef.current || isAutoResumingRef.current) {
|
|
2011
2026
|
return false;
|
|
2012
2027
|
}
|
|
2028
|
+
// The refs above lag a render and are per-component-instance, while
|
|
2029
|
+
// MultiTabAssistantChat mounts several instances against one run. The
|
|
2030
|
+
// claim is the actual mutual exclusion: module-scoped, synchronous, and
|
|
2031
|
+
// re-checked on every state write below.
|
|
2032
|
+
const ownershipToken = createRunStreamToken(`reconnect:${runId}`);
|
|
2033
|
+
if (!claimRunStream(threadId, runId, ownershipToken))
|
|
2034
|
+
return false;
|
|
2013
2035
|
// SUPERSEDE THE PREVIOUS RECONNECT GENERATION. A turn that keeps failing
|
|
2014
2036
|
// (e.g. repeated stale_run at "Contacting model") produces a new runId
|
|
2015
2037
|
// every few seconds; each call here used to OVERWRITE the single-slot
|
|
@@ -2050,7 +2072,6 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
2050
2072
|
});
|
|
2051
2073
|
setIsReconnecting(true);
|
|
2052
2074
|
setReconnectFrozen(false);
|
|
2053
|
-
setAdapterHandoffPending(false);
|
|
2054
2075
|
setReconnectContent([]);
|
|
2055
2076
|
window.dispatchEvent(new CustomEvent("agentNative.chatRunning", {
|
|
2056
2077
|
detail: { isRunning: true, tabId: tabId || threadId },
|
|
@@ -2197,7 +2218,8 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
2197
2218
|
requestAnimationFrame(() => {
|
|
2198
2219
|
rafPending = false;
|
|
2199
2220
|
if (!reconnectOwnerMountedRef.current ||
|
|
2200
|
-
reconnectRunIdRef.current !== runId
|
|
2221
|
+
reconnectRunIdRef.current !== runId ||
|
|
2222
|
+
!ownsRunStream(threadId, runId, ownershipToken)) {
|
|
2201
2223
|
return;
|
|
2202
2224
|
}
|
|
2203
2225
|
setReconnectContent(latestSnapshot);
|
|
@@ -2205,9 +2227,14 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
2205
2227
|
};
|
|
2206
2228
|
try {
|
|
2207
2229
|
await readSSEStreamRaw(sseRes.body, content, toolCallCounter, tabId, scheduleUpdate, (seq, isProgress) => {
|
|
2230
|
+
// The adapter can preempt this reader mid-stream. Advancing
|
|
2231
|
+
// the cursor after that would move a run this reader no
|
|
2232
|
+
// longer represents.
|
|
2233
|
+
if (!ownsRunStream(threadId, runId, ownershipToken))
|
|
2234
|
+
return;
|
|
2208
2235
|
markReconnectProgress();
|
|
2209
2236
|
reconnectRetryCount = 0;
|
|
2210
|
-
updateActiveRunSeq(seq, isProgress);
|
|
2237
|
+
updateActiveRunSeq(threadId, runId, seq, isProgress);
|
|
2211
2238
|
}, { preparingActionState });
|
|
2212
2239
|
if (reconnectAfterSeq === 0) {
|
|
2213
2240
|
setReconnectContent([...content]);
|
|
@@ -2255,6 +2282,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
2255
2282
|
threadPollEngine?.stop();
|
|
2256
2283
|
watchdog.stop();
|
|
2257
2284
|
clearInterval(idleCheck);
|
|
2285
|
+
releaseRunStream(threadId, runId, ownershipToken);
|
|
2258
2286
|
}
|
|
2259
2287
|
// A newer reader, live adapter, stop action, or component unmount took
|
|
2260
2288
|
// ownership while this async loop was unwinding. Do not let the stale
|
|
@@ -3192,11 +3220,14 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
3192
3220
|
prevIsRuntimeRunningRef.current = isRuntimeRunning;
|
|
3193
3221
|
if (isRuntimeRunning && !wasRunning) {
|
|
3194
3222
|
// SINGLE-READER OWNERSHIP: the adapter runtime just took over (a new run
|
|
3195
|
-
// started or an adopted run resumed)
|
|
3196
|
-
//
|
|
3197
|
-
// UI
|
|
3223
|
+
// started or an adopted run resumed), so it is now the only owner of this
|
|
3224
|
+
// turn's rendering. The overlay used to be kept alive here for up to
|
|
3225
|
+
// 2500ms so the UI would not flash a gap — but that deliberately put two
|
|
3226
|
+
// independent folds of the same run on screen at once, and the only thing
|
|
3227
|
+
// hiding the second was content-similarity guessing that fails whenever
|
|
3228
|
+
// the two readers disagree (id-less activity cards, a turn split across
|
|
3229
|
+
// several assistant messages). One owner, one surface: drop the overlay.
|
|
3198
3230
|
if (reconnectRunIdRef.current !== null) {
|
|
3199
|
-
const keepOverlay = reconnectContent.length > 0;
|
|
3200
3231
|
reconnectRunIdRef.current = null;
|
|
3201
3232
|
reconnectAbortRef.current?.abort();
|
|
3202
3233
|
reconnectAbortRef.current = null;
|
|
@@ -3204,56 +3235,18 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
3204
3235
|
setReconnectFrozen(false);
|
|
3205
3236
|
reconnectCanMaterializeRef.current = false;
|
|
3206
3237
|
reconnectTailOnlyRef.current = false;
|
|
3207
|
-
|
|
3208
|
-
setAdapterHandoffPending(true);
|
|
3209
|
-
}
|
|
3210
|
-
else {
|
|
3211
|
-
setReconnectContent([]);
|
|
3212
|
-
setAdapterHandoffPending(false);
|
|
3213
|
-
}
|
|
3238
|
+
setReconnectContent([]);
|
|
3214
3239
|
}
|
|
3215
3240
|
else if (reconnectFrozen) {
|
|
3216
3241
|
setReconnectFrozen(false);
|
|
3217
3242
|
setReconnectContent([]);
|
|
3218
|
-
setAdapterHandoffPending(false);
|
|
3219
3243
|
reconnectCanMaterializeRef.current = false;
|
|
3220
3244
|
}
|
|
3221
3245
|
if (forceStopped) {
|
|
3222
3246
|
setForceStopped(false);
|
|
3223
3247
|
}
|
|
3224
3248
|
}
|
|
3225
|
-
}, [
|
|
3226
|
-
isRuntimeRunning,
|
|
3227
|
-
reconnectFrozen,
|
|
3228
|
-
forceStopped,
|
|
3229
|
-
reconnectContent.length,
|
|
3230
|
-
]);
|
|
3231
|
-
// Release the deferred reconnect overlay once thread messages have caught
|
|
3232
|
-
// up enough that dedupe would hide the overlay, or after a short timeout so
|
|
3233
|
-
// a stuck handoff cannot leave duplicate tool cards forever.
|
|
3234
|
-
useEffect(() => {
|
|
3235
|
-
if (!adapterHandoffPending)
|
|
3236
|
-
return;
|
|
3237
|
-
if (!isRuntimeRunning) {
|
|
3238
|
-
setReconnectContent([]);
|
|
3239
|
-
setAdapterHandoffPending(false);
|
|
3240
|
-
return;
|
|
3241
|
-
}
|
|
3242
|
-
const stillNeeded = dedupeReconnectContentAgainstMessages(reconnectContent, messages, {
|
|
3243
|
-
suppressToolRepeats: true,
|
|
3244
|
-
trimTailTextOverlap: true,
|
|
3245
|
-
}).length > 0;
|
|
3246
|
-
if (!stillNeeded) {
|
|
3247
|
-
setReconnectContent([]);
|
|
3248
|
-
setAdapterHandoffPending(false);
|
|
3249
|
-
return;
|
|
3250
|
-
}
|
|
3251
|
-
const timer = window.setTimeout(() => {
|
|
3252
|
-
setReconnectContent([]);
|
|
3253
|
-
setAdapterHandoffPending(false);
|
|
3254
|
-
}, 2500);
|
|
3255
|
-
return () => window.clearTimeout(timer);
|
|
3256
|
-
}, [adapterHandoffPending, isRuntimeRunning, messages, reconnectContent]);
|
|
3249
|
+
}, [isRuntimeRunning, reconnectFrozen, forceStopped]);
|
|
3257
3250
|
// Same transition guard for isReconnecting: only clear forceStopped on
|
|
3258
3251
|
// the false→true edge (a new reconnect starting on page load).
|
|
3259
3252
|
const prevIsReconnectingRef = useRef(isReconnecting);
|
|
@@ -3270,7 +3263,6 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
3270
3263
|
if (!reconnectCanMaterializeRef.current) {
|
|
3271
3264
|
setReconnectFrozen(false);
|
|
3272
3265
|
setReconnectContent([]);
|
|
3273
|
-
setAdapterHandoffPending(false);
|
|
3274
3266
|
return;
|
|
3275
3267
|
}
|
|
3276
3268
|
try {
|
|
@@ -3316,7 +3308,6 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
3316
3308
|
threadRuntime.import(ensureMessageMetadata(repo));
|
|
3317
3309
|
setReconnectFrozen(false);
|
|
3318
3310
|
setReconnectContent([]);
|
|
3319
|
-
setAdapterHandoffPending(false);
|
|
3320
3311
|
reconnectCanMaterializeRef.current = false;
|
|
3321
3312
|
reconnectTurnIdRef.current = null;
|
|
3322
3313
|
}
|
|
@@ -3453,7 +3444,6 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
3453
3444
|
reconnectAbortRef.current = null;
|
|
3454
3445
|
reconnectRunIdRef.current = null;
|
|
3455
3446
|
setIsReconnecting(false);
|
|
3456
|
-
setAdapterHandoffPending(false);
|
|
3457
3447
|
const shouldFreezeReconnectContent = !reconnectTailOnlyRef.current &&
|
|
3458
3448
|
reconnectCanMaterializeRef.current &&
|
|
3459
3449
|
reconnectContent.length > 0;
|
|
@@ -3844,8 +3834,19 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
3844
3834
|
// an ahead-of-the-thread reconnect copy visible creates the familiar
|
|
3845
3835
|
// two-card stack while the adapter catches up, so prefer one row and
|
|
3846
3836
|
// let the live message advance in place.
|
|
3847
|
-
suppressToolRepeats:
|
|
3848
|
-
trimTailTextOverlap:
|
|
3837
|
+
suppressToolRepeats: isReconnecting || reconnectFrozen,
|
|
3838
|
+
trimTailTextOverlap: reconnectTailOnlyRef.current,
|
|
3839
|
+
});
|
|
3840
|
+
// The reconnect overlay is a SECOND fold of the same run, rendered as a
|
|
3841
|
+
// sibling of the message list. It may only appear while no adapter runtime
|
|
3842
|
+
// owns the turn. Deriving it from `isRuntimeRunning` at render time — rather
|
|
3843
|
+
// than relying on an effect to clear the overlay's own flags afterwards —
|
|
3844
|
+
// is what makes two streaming copies structurally impossible instead of
|
|
3845
|
+
// merely unlikely; the effect below runs a frame too late to prevent it.
|
|
3846
|
+
const showReconnectOverlay = shouldShowReconnectOverlay({
|
|
3847
|
+
isRuntimeRunning,
|
|
3848
|
+
isReconnecting,
|
|
3849
|
+
reconnectFrozen,
|
|
3849
3850
|
});
|
|
3850
3851
|
const latestMessage = messages[messages.length - 1];
|
|
3851
3852
|
const reconnectStatusContent = visibleReconnectContent.length > 0
|
|
@@ -4039,7 +4040,8 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
4039
4040
|
getApprovalResolution,
|
|
4040
4041
|
onApprovalResolved: recordApprovalResolution,
|
|
4041
4042
|
onApprove: (approvalKey) => {
|
|
4042
|
-
void addToQueue("Approved. Go ahead and run the requested action.", undefined, undefined, undefined, undefined, "queued", undefined, false, false, false,
|
|
4043
|
+
void addToQueue("Approved. Go ahead and run the requested action.", undefined, undefined, undefined, undefined, "queued", undefined, false, false, false, true, // hideUserMessage: this is a protocol continuation, not a new prompt
|
|
4044
|
+
undefined, [approvalKey]);
|
|
4043
4045
|
},
|
|
4044
4046
|
...(approvalActions?.onDeny ? { onDeny: approvalActions.onDeny } : {}),
|
|
4045
4047
|
...(approvalActions?.onAlwaysAllow
|
|
@@ -4126,12 +4128,8 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
4126
4128
|
setDismissedRunErrorKey(visibleRunErrorKey);
|
|
4127
4129
|
}
|
|
4128
4130
|
setRunErrorInfo(null);
|
|
4129
|
-
} }) })),
|
|
4130
|
-
reconnectFrozen
|
|
4131
|
-
adapterHandoffPending) &&
|
|
4132
|
-
visibleReconnectContent.length > 0 && (_jsx(MessageScrollerItem, { children: _jsx(ReconnectStreamMessage, { content: visibleReconnectContent, allowActivitySpinner: !reconnectFrozen }) })), (isReconnecting ||
|
|
4133
|
-
reconnectFrozen ||
|
|
4134
|
-
adapterHandoffPending) &&
|
|
4131
|
+
} }) })), showReconnectOverlay &&
|
|
4132
|
+
visibleReconnectContent.length > 0 && (_jsx(MessageScrollerItem, { children: _jsx(ReconnectStreamMessage, { content: visibleReconnectContent, allowActivitySpinner: !reconnectFrozen }) })), showReconnectOverlay &&
|
|
4135
4133
|
visibleReconnectContent.length === 0 &&
|
|
4136
4134
|
reconnectContent.length === 0 &&
|
|
4137
4135
|
reconnectActivityContent.length > 0 && (_jsx(MessageScrollerItem, { children: _jsx(ReconnectStreamMessage, { content: reconnectActivityContent, allowActivitySpinner: !reconnectFrozen }) })), showGlobalRunningStatus && (_jsx(MessageScrollerItem, { children: _jsx(RunningActivityStatus, { label: runningStatusLabel }) })), visibleQueuedMessages.length > 0 && (_jsx(MessageScrollerItem, { children: _jsxs("div", { className: "flex items-center justify-end gap-1.5 pr-0.5 text-xs text-muted-foreground", children: [_jsx(IconClock, { className: "h-3 w-3" }), _jsxs("span", { children: [visibleQueuedMessages.length, " ", "queued"] })] }) })), visibleQueuedMessages.map((msg) => {
|
|
@@ -17,11 +17,24 @@ export interface PendingTurnState {
|
|
|
17
17
|
}
|
|
18
18
|
export declare function setActiveRun(state: ActiveRunState): void;
|
|
19
19
|
export declare function getActiveRun(): ActiveRunState | null;
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Advance one run's resume cursor. Identity is required: the previous
|
|
22
|
+
* signature took only `seq` and wrote into whichever run happened to occupy
|
|
23
|
+
* the shared slot, so a second concurrent run silently corrupted the first
|
|
24
|
+
* run's cursor. An unknown run is ignored rather than created — a cursor with
|
|
25
|
+
* no matching stream is indistinguishable from a real one at replay time.
|
|
26
|
+
*/
|
|
27
|
+
export declare function updateActiveRunSeq(threadId: string, runId: string, seq: number, isProgress?: boolean): void;
|
|
21
28
|
/** Whether this browser has received real progress for the matching run recently. */
|
|
22
29
|
export declare function hasRecentActiveRunProgress(threadId: string | null | undefined, runId: string | null | undefined, thresholdMs: number, now?: number): boolean;
|
|
23
30
|
export declare function updateActiveRunActivity(toolName: string | null | undefined): void;
|
|
24
31
|
export declare function getActiveRunActivityTool(threadId: string, runId: string): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Drop the focused-run pointer. The run's resume cursor is intentionally kept:
|
|
34
|
+
* callers fire this from many unrelated teardown paths, and deleting the
|
|
35
|
+
* cursor here is what previously made a later reconnect replay the run from
|
|
36
|
+
* its first event.
|
|
37
|
+
*/
|
|
25
38
|
export declare function clearActiveRun(): void;
|
|
26
39
|
export declare function clearActiveRunIfMatches(threadId: string, runId: string): void;
|
|
27
40
|
export declare function setPendingTurn(state: PendingTurnState): void;
|
|
Binary file
|
|
@@ -6,6 +6,7 @@ import { getOrCreateAnalyticsSessionId } from "./analytics-session.js";
|
|
|
6
6
|
import { captureError } from "./analytics.js";
|
|
7
7
|
import { agentNativePath } from "./api-path.js";
|
|
8
8
|
import { formatChatErrorText, normalizeChatError } from "./error-format.js";
|
|
9
|
+
import { createRunStreamToken, preemptRunStream, releaseRunStream, } from "./run-stream-ownership.js";
|
|
9
10
|
import { AgentAutoContinueSignal, INTERRUPTED_TOOL_RESULT, appendMissingFinalResponseWarning, readSSEStream, settleInterruptedToolCalls, } from "./sse-event-processor.js";
|
|
10
11
|
import { isDelegatedAgentToolCall, isToolCallInFlight, } from "./tool-display.js";
|
|
11
12
|
const TEXT_ATTACHMENT_CONTENT_TYPES = new Set([
|
|
@@ -1006,6 +1007,26 @@ function snapshotContent(content) {
|
|
|
1006
1007
|
? { ...part }
|
|
1007
1008
|
: { ...part, args: { ...part.args } });
|
|
1008
1009
|
}
|
|
1010
|
+
function hasMissingFinalResponseAfterTool(content) {
|
|
1011
|
+
const warning = appendMissingFinalResponseWarning(snapshotContent(content));
|
|
1012
|
+
return warning?.errorCode === "final_response_missing_after_tool";
|
|
1013
|
+
}
|
|
1014
|
+
function missingFinalResponseWarningFromResult(result) {
|
|
1015
|
+
const metadata = result.metadata;
|
|
1016
|
+
const custom = metadata?.custom;
|
|
1017
|
+
if (!custom || typeof custom !== "object")
|
|
1018
|
+
return null;
|
|
1019
|
+
const warning = custom.runWarning;
|
|
1020
|
+
if (!warning || typeof warning !== "object")
|
|
1021
|
+
return null;
|
|
1022
|
+
const warningRecord = warning;
|
|
1023
|
+
if (warningRecord.errorCode !== "final_response_missing_after_tool") {
|
|
1024
|
+
return null;
|
|
1025
|
+
}
|
|
1026
|
+
return {
|
|
1027
|
+
message: typeof warningRecord.message === "string" ? warningRecord.message : "",
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1009
1030
|
function stableJson(value) {
|
|
1010
1031
|
try {
|
|
1011
1032
|
return JSON.stringify(value);
|
|
@@ -1618,7 +1639,19 @@ export function createAgentChatAdapter(options) {
|
|
|
1618
1639
|
activeRun.threadId === threadId &&
|
|
1619
1640
|
activeRun.runId === runId));
|
|
1620
1641
|
};
|
|
1642
|
+
// The adapter's own stream outranks AssistantChat's reconnect fallback:
|
|
1643
|
+
// when it attaches to a run, any reconnect reader folding the same run
|
|
1644
|
+
// must stop writing UI state or both folds render at once.
|
|
1645
|
+
const streamOwnershipToken = createRunStreamToken(`adapter:${turnId}`);
|
|
1646
|
+
const takeRunStreamOwnership = () => {
|
|
1647
|
+
if (threadId && runId) {
|
|
1648
|
+
preemptRunStream(threadId, runId, streamOwnershipToken);
|
|
1649
|
+
}
|
|
1650
|
+
};
|
|
1621
1651
|
const settleTerminalChatRun = () => {
|
|
1652
|
+
if (threadId && runId) {
|
|
1653
|
+
releaseRunStream(threadId, runId, streamOwnershipToken);
|
|
1654
|
+
}
|
|
1622
1655
|
if (!ownsActiveRunState())
|
|
1623
1656
|
return;
|
|
1624
1657
|
if (threadId && runId) {
|
|
@@ -1972,10 +2005,12 @@ export function createAgentChatAdapter(options) {
|
|
|
1972
2005
|
break;
|
|
1973
2006
|
}
|
|
1974
2007
|
updateCurrentRunDispatchMode(reconnectRes.headers.get("X-Dispatch-Mode"));
|
|
2008
|
+
takeRunStreamOwnership();
|
|
1975
2009
|
for await (const result of readSSEStream(reconnectRes.body, content, toolCallCounter, tabId, (seq, isProgress) => {
|
|
1976
2010
|
rememberRunSeq(seq);
|
|
1977
|
-
if (threadId)
|
|
1978
|
-
updateActiveRunSeq(seq, isProgress);
|
|
2011
|
+
if (threadId && runId) {
|
|
2012
|
+
updateActiveRunSeq(threadId, runId, seq, isProgress);
|
|
2013
|
+
}
|
|
1979
2014
|
}, runId, currentSSEOptions())) {
|
|
1980
2015
|
const nextResult = withRequestModeMetadata(result);
|
|
1981
2016
|
if (isTerminalChatModelRunResult(nextResult)) {
|
|
@@ -2311,20 +2346,45 @@ export function createAgentChatAdapter(options) {
|
|
|
2311
2346
|
}
|
|
2312
2347
|
attached = true;
|
|
2313
2348
|
updateCurrentRunDispatchMode(eventsRes.headers.get("X-Dispatch-Mode"));
|
|
2349
|
+
takeRunStreamOwnership();
|
|
2350
|
+
let missingFinalResponseResult = null;
|
|
2314
2351
|
for await (const result of readSSEStream(eventsRes.body, content, toolCallCounter, tabId, (seq, isProgress) => {
|
|
2315
2352
|
rememberRunSeq(seq);
|
|
2316
|
-
if (threadId)
|
|
2317
|
-
updateActiveRunSeq(seq, isProgress);
|
|
2353
|
+
if (threadId && runId) {
|
|
2354
|
+
updateActiveRunSeq(threadId, runId, seq, isProgress);
|
|
2355
|
+
}
|
|
2318
2356
|
}, runId, currentSSEOptions({
|
|
2319
2357
|
noProgressTimeoutMs: BACKGROUND_FOLLOW_ATTACH_WATCHDOG_MS,
|
|
2320
2358
|
actionPreparationStallTimeoutMs: BACKGROUND_FOLLOW_ATTACH_WATCHDOG_MS,
|
|
2321
2359
|
}))) {
|
|
2322
2360
|
const nextResult = withRequestModeMetadata(result);
|
|
2361
|
+
if (isDurableBackgroundDispatch() &&
|
|
2362
|
+
missingFinalResponseWarningFromResult(nextResult)) {
|
|
2363
|
+
missingFinalResponseResult = nextResult;
|
|
2364
|
+
continue;
|
|
2365
|
+
}
|
|
2323
2366
|
if (isTerminalChatModelRunResult(nextResult)) {
|
|
2324
2367
|
settleTerminalChatRun();
|
|
2325
2368
|
}
|
|
2326
2369
|
yield nextResult;
|
|
2327
2370
|
}
|
|
2371
|
+
if (missingFinalResponseResult) {
|
|
2372
|
+
const warning = missingFinalResponseWarningFromResult(missingFinalResponseResult);
|
|
2373
|
+
const lastContentPart = content.at(-1);
|
|
2374
|
+
if (warning?.message &&
|
|
2375
|
+
lastContentPart?.type === "text" &&
|
|
2376
|
+
lastContentPart.text === warning.message) {
|
|
2377
|
+
content.pop();
|
|
2378
|
+
}
|
|
2379
|
+
if (continueAfterMissingFinalResponse()) {
|
|
2380
|
+
await delay(250, abortSignal);
|
|
2381
|
+
return "client_continue";
|
|
2382
|
+
}
|
|
2383
|
+
settleTerminalChatRun();
|
|
2384
|
+
yield missingFinalResponseResult;
|
|
2385
|
+
clearActiveRun();
|
|
2386
|
+
return "completed";
|
|
2387
|
+
}
|
|
2328
2388
|
// readSSEStream returned normally: a terminal done/error was
|
|
2329
2389
|
// consumed and rendered — the turn is over.
|
|
2330
2390
|
clearActiveRun();
|
|
@@ -2614,6 +2674,11 @@ export function createAgentChatAdapter(options) {
|
|
|
2614
2674
|
continue;
|
|
2615
2675
|
}
|
|
2616
2676
|
}
|
|
2677
|
+
if (hasMissingFinalResponseAfterTool(content) &&
|
|
2678
|
+
continueAfterMissingFinalResponse()) {
|
|
2679
|
+
await delay(250, abortSignal);
|
|
2680
|
+
return "client_continue";
|
|
2681
|
+
}
|
|
2617
2682
|
yield* emitBackgroundTerminalOutcome(active);
|
|
2618
2683
|
return "completed";
|
|
2619
2684
|
}
|
|
@@ -2642,6 +2707,9 @@ export function createAgentChatAdapter(options) {
|
|
|
2642
2707
|
}
|
|
2643
2708
|
const seqBeforeAttach = lastSeq;
|
|
2644
2709
|
const attach = yield* followAttachOnce();
|
|
2710
|
+
if (attach === "client_continue") {
|
|
2711
|
+
return "client_continue";
|
|
2712
|
+
}
|
|
2645
2713
|
if (attach === "completed" || attach === "aborted") {
|
|
2646
2714
|
return "completed";
|
|
2647
2715
|
}
|
|
@@ -2964,6 +3032,17 @@ export function createAgentChatAdapter(options) {
|
|
|
2964
3032
|
nonAdvancing: !advanced,
|
|
2965
3033
|
};
|
|
2966
3034
|
};
|
|
3035
|
+
const continueAfterMissingFinalResponse = () => {
|
|
3036
|
+
const continuation = prepareAutoContinuation(new AgentAutoContinueSignal({ reason: "stream_ended" }));
|
|
3037
|
+
if (!continuation.ok)
|
|
3038
|
+
return false;
|
|
3039
|
+
if (typeof window !== "undefined") {
|
|
3040
|
+
window.dispatchEvent(new CustomEvent("agent-chat:auto-continue", {
|
|
3041
|
+
detail: { tabId },
|
|
3042
|
+
}));
|
|
3043
|
+
}
|
|
3044
|
+
return true;
|
|
3045
|
+
};
|
|
2967
3046
|
while (true) {
|
|
2968
3047
|
try {
|
|
2969
3048
|
runId = null;
|
|
@@ -3221,18 +3300,41 @@ export function createAgentChatAdapter(options) {
|
|
|
3221
3300
|
clearPendingTurnIfMatches(threadId, turnId);
|
|
3222
3301
|
setActiveRun({ threadId, runId, turnId, lastSeq: -1 });
|
|
3223
3302
|
}
|
|
3303
|
+
takeRunStreamOwnership();
|
|
3304
|
+
let missingFinalResponseResult = null;
|
|
3224
3305
|
for await (const result of readSSEStream(res.body, content, toolCallCounter, tabId, (seq, isProgress) => {
|
|
3225
3306
|
rememberRunSeq(seq);
|
|
3226
3307
|
if (runId && threadId) {
|
|
3227
|
-
updateActiveRunSeq(seq, isProgress);
|
|
3308
|
+
updateActiveRunSeq(threadId, runId, seq, isProgress);
|
|
3228
3309
|
}
|
|
3229
3310
|
}, runId, currentSSEOptions())) {
|
|
3230
3311
|
const nextResult = withRequestModeMetadata(result);
|
|
3312
|
+
if (isDurableBackgroundDispatch() &&
|
|
3313
|
+
missingFinalResponseWarningFromResult(nextResult)) {
|
|
3314
|
+
missingFinalResponseResult = nextResult;
|
|
3315
|
+
continue;
|
|
3316
|
+
}
|
|
3231
3317
|
if (isTerminalChatModelRunResult(nextResult)) {
|
|
3232
3318
|
settleTerminalChatRun();
|
|
3233
3319
|
}
|
|
3234
3320
|
yield nextResult;
|
|
3235
3321
|
}
|
|
3322
|
+
if (isDurableBackgroundDispatch() && missingFinalResponseResult) {
|
|
3323
|
+
const warning = missingFinalResponseWarningFromResult(missingFinalResponseResult);
|
|
3324
|
+
const lastContentPart = content.at(-1);
|
|
3325
|
+
if (warning?.message &&
|
|
3326
|
+
lastContentPart?.type === "text" &&
|
|
3327
|
+
lastContentPart.text === warning.message) {
|
|
3328
|
+
content.pop();
|
|
3329
|
+
}
|
|
3330
|
+
if (continueAfterMissingFinalResponse()) {
|
|
3331
|
+
continue;
|
|
3332
|
+
}
|
|
3333
|
+
settleTerminalChatRun();
|
|
3334
|
+
yield missingFinalResponseResult;
|
|
3335
|
+
clearActiveRun();
|
|
3336
|
+
return;
|
|
3337
|
+
}
|
|
3236
3338
|
// Run completed normally — clear active run state
|
|
3237
3339
|
clearActiveRun();
|
|
3238
3340
|
return;
|
package/dist/client/analytics.js
CHANGED
|
@@ -1030,6 +1030,12 @@ function exceptionEventProperties(event) {
|
|
|
1030
1030
|
...(event.extra ? { exceptionExtra: event.extra } : {}),
|
|
1031
1031
|
};
|
|
1032
1032
|
}
|
|
1033
|
+
function amplitudeEventProperties(name, properties) {
|
|
1034
|
+
if (name !== AGENT_NATIVE_EXCEPTION_EVENT_NAME)
|
|
1035
|
+
return properties;
|
|
1036
|
+
const { exceptionTags: _exceptionTags, exceptionExtra: _exceptionExtra, ...stableProperties } = properties;
|
|
1037
|
+
return stableProperties;
|
|
1038
|
+
}
|
|
1033
1039
|
/**
|
|
1034
1040
|
* Resolve browser PostHog config, or `undefined` when error capture should not
|
|
1035
1041
|
* reach PostHog. Reads the SSR-injected shell config first, then Vite env for
|
|
@@ -1557,13 +1563,14 @@ export function trackEvent(name, params) {
|
|
|
1557
1563
|
return;
|
|
1558
1564
|
ensureSentry();
|
|
1559
1565
|
const props = resolveProps(name, params);
|
|
1566
|
+
const amplitudeProps = amplitudeEventProperties(name, props);
|
|
1560
1567
|
window.gtag?.("event", name.replace(/\s+/g, "_"), props);
|
|
1561
1568
|
if (ensureAmplitude()) {
|
|
1562
|
-
_amplitudeModule?.track(name,
|
|
1569
|
+
_amplitudeModule?.track(name, amplitudeProps);
|
|
1563
1570
|
}
|
|
1564
1571
|
else if (_amplitudeApiKey) {
|
|
1565
1572
|
if (_pendingAmplitudeEvents.length < 100) {
|
|
1566
|
-
_pendingAmplitudeEvents.push([name,
|
|
1573
|
+
_pendingAmplitudeEvents.push([name, amplitudeProps]);
|
|
1567
1574
|
}
|
|
1568
1575
|
}
|
|
1569
1576
|
sendAgentNativeAnalytics(name, props);
|
|
@@ -258,19 +258,19 @@ function ApprovalAffordance({ toolName, toolCallId, approval, }) {
|
|
|
258
258
|
if (resolution === "denied") {
|
|
259
259
|
return (_jsxs("div", { className: "mt-1.5 text-xs text-muted-foreground", children: ["Denied. ", toolName, " did not run."] }));
|
|
260
260
|
}
|
|
261
|
-
return (_jsxs("div", { className: "mt-1.5 flex items-center gap-2 rounded-md border border-border bg-muted/40 px-2.5 py-1.5", children: [_jsx(IconShieldCheck, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }), _jsxs("span", { className: "
|
|
261
|
+
return (_jsxs("div", { className: "mt-1.5 flex min-w-0 flex-wrap items-center gap-2 rounded-md border border-border bg-muted/40 px-2.5 py-1.5", children: [_jsx(IconShieldCheck, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }), _jsxs("span", { className: "min-w-0 flex-1 text-xs text-muted-foreground", children: ["Approve to run ", toolName, "?"] }), ctx && (_jsxs("button", { type: "button", onClick: () => {
|
|
262
262
|
setLocalResolution("approved");
|
|
263
263
|
ctx.onApprovalResolved?.(approval.approvalKey, "approved", toolCallId);
|
|
264
264
|
ctx.onApprove(approval.approvalKey);
|
|
265
|
-
}, className: cn("inline-flex items-center gap-1 rounded-md px-2.5 py-1 text-xs font-medium transition-colors", "bg-foreground text-background hover:bg-foreground/90"), children: [_jsx(IconCheck, { className: "h-3.5 w-3.5" }), "Approve"] })), ctx?.onAlwaysAllow && (_jsxs("button", { type: "button", onClick: () => {
|
|
265
|
+
}, className: cn("inline-flex shrink-0 items-center gap-1 rounded-md px-2.5 py-1 text-xs font-medium transition-colors", "bg-foreground text-background hover:bg-foreground/90"), children: [_jsx(IconCheck, { className: "h-3.5 w-3.5" }), "Approve"] })), ctx?.onAlwaysAllow && (_jsxs("button", { type: "button", onClick: () => {
|
|
266
266
|
setLocalResolution("approved");
|
|
267
267
|
ctx.onApprovalResolved?.(approval.approvalKey, "approved", toolCallId);
|
|
268
268
|
ctx.onAlwaysAllow?.(approval.approvalKey);
|
|
269
|
-
}, title: "Approve and always allow this exact command", className: cn("inline-flex items-center gap-1 rounded-md border border-border px-2.5 py-1 text-xs font-medium transition-colors", "text-foreground hover:bg-muted"), children: [_jsx(IconShieldCheck, { className: "h-3.5 w-3.5" }), "Always allow"] })), _jsxs("button", { type: "button", onClick: () => {
|
|
269
|
+
}, title: "Approve and always allow this exact command", className: cn("inline-flex shrink-0 items-center gap-1 rounded-md border border-border px-2.5 py-1 text-xs font-medium transition-colors", "text-foreground hover:bg-muted"), children: [_jsx(IconShieldCheck, { className: "h-3.5 w-3.5" }), "Always allow"] })), _jsxs("button", { type: "button", onClick: () => {
|
|
270
270
|
setLocalResolution("denied");
|
|
271
271
|
ctx?.onApprovalResolved?.(approval.approvalKey, "denied", toolCallId);
|
|
272
272
|
ctx?.onDeny?.(approval.approvalKey);
|
|
273
|
-
}, className: cn("inline-flex items-center gap-1 rounded-md border border-border px-2.5 py-1 text-xs font-medium transition-colors", "text-foreground hover:bg-muted"), children: [_jsx(IconX, { className: "h-3.5 w-3.5" }), "Deny"] })] }));
|
|
273
|
+
}, className: cn("inline-flex shrink-0 items-center gap-1 rounded-md border border-border px-2.5 py-1 text-xs font-medium transition-colors", "text-foreground hover:bg-muted"), children: [_jsx(IconX, { className: "h-3.5 w-3.5" }), "Deny"] })] }));
|
|
274
274
|
}
|
|
275
275
|
// ─── ToolCallDisplay ──────────────────────────────────────────────────────────
|
|
276
276
|
export function ToolCallDisplay({ toolName, toolCallId, argsText, args, result, mcpApp, chatUI, isRunning, outcome, structuredMeta, activity, approval, repeatCount, isLatestRunning = isRunning, isActiveTail, }) {
|
|
@@ -5,6 +5,11 @@ import { memo, useMemo, useState } from "react";
|
|
|
5
5
|
import { orderChatFirstAppIds, readChatFirstAppLayout, writeChatFirstAppLayout, } from "../chat-first.js";
|
|
6
6
|
import { cn } from "../utils.js";
|
|
7
7
|
import { defaultChatFirstCopy } from "./copy.js";
|
|
8
|
+
function ChatFirstRailAppIcon({ app, activeAppId, renderIcon, }) {
|
|
9
|
+
const isActive = activeAppId !== undefined && activeAppId === app.id;
|
|
10
|
+
const isInactive = activeAppId !== undefined && !isActive;
|
|
11
|
+
return (_jsx("span", { "data-chat-first-app-icon": true, className: cn("transition-[filter]", isInactive && "grayscale"), children: renderIcon(app, { isActive, isInactive }) }));
|
|
12
|
+
}
|
|
8
13
|
function AppRows({ apps, activeAppId, layout, onDragStart, onDrop, onDragEnd, onOpenApp, onRemoveApp, onTogglePinned, onMove, renderIcon, copy, }) {
|
|
9
14
|
const orderedIds = orderChatFirstAppIds(apps.map((app) => app.id), layout);
|
|
10
15
|
const appsById = new Map(apps.map((app) => [app.id, app]));
|
|
@@ -16,7 +21,7 @@ function AppRows({ apps, activeAppId, layout, onDragStart, onDrop, onDragEnd, on
|
|
|
16
21
|
const pinned = layout.pinnedIds.includes(app.id);
|
|
17
22
|
const index = orderedApps.indexOf(app);
|
|
18
23
|
return (_jsxs(ContextMenu, { children: [_jsx(ContextMenuTrigger, { asChild: true, children: _jsxs("li", { draggable: true, "data-chat-first-app": true, "data-app-id": app.id, className: cn("group flex h-8 w-full min-w-0 items-center gap-1 rounded-md px-0 text-sm", active
|
|
19
|
-
? "
|
|
24
|
+
? "font-medium text-sidebar-foreground"
|
|
20
25
|
: "text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"), onDragStart: (event) => {
|
|
21
26
|
event.dataTransfer.effectAllowed = "move";
|
|
22
27
|
onDragStart(app.id);
|
|
@@ -31,7 +36,7 @@ function AppRows({ apps, activeAppId, layout, onDragStart, onDrop, onDragEnd, on
|
|
|
31
36
|
event.preventDefault();
|
|
32
37
|
onMove(app.id, 1);
|
|
33
38
|
}
|
|
34
|
-
}, "aria-keyshortcuts": "Alt+ArrowUp Alt+ArrowDown", "aria-label": copy("openApp", { name: app.name }), children: [
|
|
39
|
+
}, "aria-keyshortcuts": "Alt+ArrowUp Alt+ArrowDown", "aria-label": copy("openApp", { name: app.name }), children: [_jsx(ChatFirstRailAppIcon, { app: app, activeAppId: activeAppId, renderIcon: renderIcon }), _jsx("span", { className: "truncate", children: app.name })] }), _jsx("button", { type: "button", className: cn("flex size-6 shrink-0 items-center justify-center rounded text-sidebar-foreground/45 opacity-0 hover:bg-sidebar-accent hover:text-sidebar-foreground group-hover:opacity-100 focus-visible:opacity-100", pinned && "text-sidebar-foreground/70 opacity-100"), "aria-label": copy(pinned ? "unpinApp" : "pinApp", {
|
|
35
40
|
name: app.name,
|
|
36
41
|
}), "aria-pressed": pinned, onClick: () => onTogglePinned(app.id), children: _jsx(IconPin, { size: 13, strokeWidth: pinned ? 2.2 : 1.6, "aria-hidden": "true" }) }), _jsx("span", { className: "sr-only", children: `${index + 1} of ${orderedApps.length}` })] }) }), _jsxs(ContextMenuContent, { children: [_jsxs(ContextMenuItem, { onSelect: () => onTogglePinned(app.id), children: [_jsx(IconPin, { size: 14, "aria-hidden": "true" }), pinned ? copy("removePinned") : copy("pinTop")] }), _jsx(ContextMenuSeparator, {}), _jsxs(ContextMenuItem, { disabled: index === 0, onSelect: () => onMove(app.id, -1), children: [_jsx(IconChevronUp, { size: 14, "aria-hidden": "true" }), copy("moveUp")] }), _jsxs(ContextMenuItem, { disabled: index === orderedApps.length - 1, onSelect: () => onMove(app.id, 1), children: [_jsx(IconChevronDown, { size: 14, "aria-hidden": "true" }), copy("moveDown")] }), onRemoveApp ? (_jsxs(_Fragment, { children: [_jsx(ContextMenuSeparator, {}), _jsxs(ContextMenuItem, { onSelect: () => onRemoveApp(app), className: "text-destructive focus:text-destructive", children: [_jsx(IconTrash, { size: 14, "aria-hidden": "true" }), copy("removeApp")] })] })) : null] })] }, app.id));
|
|
37
42
|
}) }));
|
|
@@ -96,8 +101,8 @@ export const ChatFirstAppsRail = memo(function ChatFirstAppsRail({ apps, activeA
|
|
|
96
101
|
return (_jsxs("section", { "data-chat-first-apps-rail": true, className: "flex flex-col items-center gap-1 px-1.5 pt-2", "aria-label": copy("workspaceApps"), children: [createTrigger, loading && apps.length === 0
|
|
97
102
|
? [0, 1, 2].map((index) => (_jsx(Skeleton, { className: "size-9 rounded-md" }, index)))
|
|
98
103
|
: visibleApps.map((app) => (_jsx("button", { type: "button", "data-chat-first-app": true, "data-app-id": app.id, className: cn("flex size-9 items-center justify-center rounded-md", activeAppId === app.id
|
|
99
|
-
? "
|
|
100
|
-
: "text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"), onClick: () => onOpenApp(app), "aria-label": copy("openApp", { name: app.name }), title: app.name, children:
|
|
104
|
+
? "text-sidebar-foreground"
|
|
105
|
+
: "text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"), onClick: () => onOpenApp(app), "aria-label": copy("openApp", { name: app.name }), title: app.name, children: _jsx(ChatFirstRailAppIcon, { app: app, activeAppId: activeAppId, renderIcon: renderIcon }) }, app.id))), onOpenAllApps ? (_jsx("button", { type: "button", "data-chat-first-all-apps": true, className: "flex size-9 items-center justify-center rounded-md text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground", onClick: onOpenAllApps, "aria-label": copy("allApps"), title: copy("allApps"), children: _jsx(IconApps, { size: 16, "aria-hidden": "true" }) })) : null, error ? (_jsx("span", { className: "size-1.5 rounded-full bg-destructive", title: error, "aria-label": error })) : null] }));
|
|
101
106
|
}
|
|
102
107
|
return (_jsxs("section", { "data-chat-first-apps-rail": true, className: "mt-3 px-2 pb-2 pt-2", "aria-label": copy("workspaceApps"), children: [_jsxs("div", { className: "mb-1 flex items-center gap-1.5 px-2 text-[11px] font-medium text-sidebar-foreground/50", children: [_jsx("span", { children: copy("workspaceApps") }), _jsx("span", { className: "ml-auto", children: createTrigger })] }), loading && apps.length === 0 ? (_jsx("div", { className: "space-y-0.5 px-2", children: [0, 1, 2].map((index) => (_jsx(Skeleton, { className: "h-8 w-full rounded-md" }, index))) })) : apps.length === 0 ? (_jsxs("div", { className: "px-2", children: [_jsx("p", { className: "text-xs text-sidebar-foreground/55", children: copy("noWorkspaceApps") }), createAppTrigger ? (createTrigger) : onCreateApp ? (_jsxs("button", { type: "button", className: "mt-1 inline-flex h-6 items-center gap-1.5 rounded-md border border-sidebar-border px-2 text-xs text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-foreground", onClick: onCreateApp, children: [_jsx(IconPlus, { size: 13, "aria-hidden": "true" }), copy("createApp")] })) : (createTrigger)] })) : (_jsx(AppRows, { apps: visibleApps, activeAppId: activeAppId, layout: layout, onDragStart: setDraggedAppId, onDrop: reorderApps, onDragEnd: () => setDraggedAppId(null), onOpenApp: onOpenApp, onRemoveApp: onRemoveApp, onTogglePinned: togglePinned, onMove: moveApp, renderIcon: renderIcon, copy: copy })), hasMoreApps || showAllApps ? (_jsxs("button", { type: "button", className: "mt-0.5 flex h-8 w-full items-center gap-2 rounded-md px-2 text-xs text-sidebar-foreground/50 hover:bg-sidebar-accent hover:text-sidebar-foreground", onClick: () => setShowAllApps((value) => !value), children: [showAllApps ? (_jsx(IconChevronUp, { size: 14, "aria-hidden": "true" })) : (_jsx(IconChevronDown, { size: 14, "aria-hidden": "true" })), showAllApps ? copy("showLess") : copy("showMore")] })) : null, onOpenAllApps ? (_jsx("div", { className: "mt-1 border-t border-sidebar-border/60 pt-1", children: _jsxs("button", { type: "button", "data-chat-first-all-apps": true, className: "flex h-8 w-full items-center gap-2 rounded-md px-2 text-xs text-sidebar-foreground/55 hover:bg-sidebar-accent hover:text-sidebar-foreground", onClick: onOpenAllApps, children: [_jsx(IconApps, { size: 14, "aria-hidden": "true" }), _jsx("span", { children: copy("allApps") })] }) })) : null, error ? (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs("button", { type: "button", className: "mt-1 flex items-center gap-1 px-2 text-[10px] text-destructive/80", onClick: onRetry, "aria-label": error, children: [_jsx("span", { className: "size-1.5 rounded-full bg-destructive" }), onRetry ? copy("retry") : copy("appsLoadError")] }) }), _jsx(TooltipContent, { side: "right", children: error })] })) : null] }));
|
|
103
108
|
});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ChatFirstCopy } from "./types.js";
|
|
2
2
|
export type ChatFirstPrimaryTab = "new-chat" | "integrations" | "scheduled";
|
|
3
|
-
export declare function ChatFirstPrimaryNavigation({ onNewChat, onOpenIntegrations, onOpenScheduled, onSearch, activeTab, stickyNewChat, copy, }: {
|
|
3
|
+
export declare function ChatFirstPrimaryNavigation({ onNewChat, onOpenIntegrations, onOpenScheduled, onSearch, activeTab, collapsed, stickyNewChat, copy, }: {
|
|
4
4
|
onNewChat?: () => void;
|
|
5
5
|
onOpenIntegrations: () => void;
|
|
6
6
|
onOpenScheduled: () => void;
|
|
7
7
|
onSearch?: () => void;
|
|
8
8
|
activeTab?: ChatFirstPrimaryTab;
|
|
9
|
+
collapsed?: boolean;
|
|
9
10
|
stickyNewChat?: boolean;
|
|
10
11
|
copy?: ChatFirstCopy;
|
|
11
12
|
}): import("react").JSX.Element;
|