@firstpick/pi-package-webui 0.8.4 → 0.8.6
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/README.md +24 -2
- package/bin/pi-webui.mjs +383 -31
- package/index.ts +8 -1
- package/lib/git-workflow-preferences.mjs +3 -0
- package/lib/session-summary-core.mjs +4 -3
- package/lib/trust-boundaries.mjs +13 -0
- package/lib/workspace-session-summaries.mjs +400 -0
- package/package.json +2 -2
- package/public/app.js +1242 -267
- package/public/index.html +77 -4
- package/public/service-worker.js +3 -1
- package/public/stream-output-controller.mjs +327 -0
- package/public/styles.css +249 -70
- package/public/theme-contract.mjs +244 -0
- package/session-summary.ts +164 -4
- package/tests/aur-review-widget-static.test.mjs +2 -1
- package/tests/boot-failure-diagnostics.test.mjs +2 -2
- package/tests/browser/interaction-continuity.spec.mjs +2 -2
- package/tests/browser/session-summary.spec.mjs +131 -3
- package/tests/browser/stream-output-isolation.spec.mjs +510 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/composer-action-grid-reorder-static.test.mjs +2 -2
- package/tests/fast-mode-client-static.test.mjs +3 -2
- package/tests/feature-decision-output-popup-static.test.mjs +1 -1
- package/tests/fixtures/fake-pi.mjs +203 -2
- package/tests/git-workflow-preferences.test.mjs +7 -1
- package/tests/guided-git-aur-review.test.mjs +4 -3
- package/tests/http-endpoints-harness.test.mjs +224 -13
- package/tests/mobile-continuity-tablet-static.test.mjs +2 -2
- package/tests/mobile-foundation-static.test.mjs +3 -4
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +63 -29
- package/tests/native-parity.test.mjs +1 -1
- package/tests/open-issue-wizard-static.test.mjs +2 -3
- package/tests/optional-feature-migration-frontend.test.mjs +3 -0
- package/tests/persistent-ui-layout-static.test.mjs +2 -2
- package/tests/questionnaire-dialog.test.mjs +2 -2
- package/tests/remote-auth-settings-harness.test.mjs +9 -0
- package/tests/session-summary-core.test.mjs +183 -1
- package/tests/side-panel-section-reorder-static.test.mjs +2 -2
- package/tests/stream-lifecycle-core.test.mjs +134 -0
- package/tests/stream-output-controller.test.mjs +252 -0
- package/tests/stream-output-isolation-static.test.mjs +89 -0
- package/tests/streaming-ui-coupling.test.mjs +50 -0
- package/tests/subagent-gate-visibility.test.mjs +1 -1
- package/tests/subagent-launch-slots-static.test.mjs +1 -1
- package/tests/theme-contract.test.mjs +104 -0
- package/tests/theme-customizer-static.test.mjs +82 -0
- package/tests/theme-scheme-mode.test.mjs +15 -0
- package/tests/workspace-session-summaries.test.mjs +288 -0
package/public/app.js
CHANGED
|
@@ -9,6 +9,8 @@ import { buildIssuePayload, createIssueWizardCatalog, createIssueWizardState, ge
|
|
|
9
9
|
import { createIssueBotClient, readIssueBotRuntimeConfig } from "./issue-bot-client.mjs";
|
|
10
10
|
import { MOBILE_SHELL_STORAGE_KEY, TABLET_SHELL_STORAGE_KEY, createMobileShellState, isMobileShellV2Enabled, mobileNavigationTargetFromSearch, normalizeMobileNavigationTarget, reduceMobileShellState, resolveMobileShellFeatureMode, resolveTabletShellFeatureMode } from "./mobile-shell-state.mjs";
|
|
11
11
|
import { createTranscriptRenderer } from "./transcript-renderer.mjs";
|
|
12
|
+
import { createStreamOutputController } from "./stream-output-controller.mjs";
|
|
13
|
+
import { PI_THEME_EXPORT_FIELDS, THEME_TOKEN_GROUPS, canonicalizeTheme, serializeTheme, themeColorToRgb, validateTheme } from "./theme-contract.mjs";
|
|
12
14
|
|
|
13
15
|
const $ = (selector) => document.querySelector(selector);
|
|
14
16
|
|
|
@@ -18,9 +20,7 @@ const elements = {
|
|
|
18
20
|
webuiDevBadge: $("#webuiDevBadge"),
|
|
19
21
|
tabBar: $("#tabBar"),
|
|
20
22
|
terminalTabsToggleButton: $("#terminalTabsToggleButton"),
|
|
21
|
-
splitTabButton: $("#splitTabButton"),
|
|
22
23
|
workspaceSaveButton: $("#workspaceSaveButton"),
|
|
23
|
-
summaryHeaderButton: $("#summaryHeaderButton"),
|
|
24
24
|
newTabMenu: $("#newTabMenu"),
|
|
25
25
|
newTabButton: $("#newTabButton"),
|
|
26
26
|
newTabMenuPanel: $("#newTabMenuPanel"),
|
|
@@ -140,7 +140,6 @@ const elements = {
|
|
|
140
140
|
remoteMicStreamingConsentButton: $("#remoteMicStreamingConsentButton"),
|
|
141
141
|
newSessionButton: $("#newSessionButton"),
|
|
142
142
|
compactButton: $("#compactButton"),
|
|
143
|
-
summaryActionButton: $("#summaryActionButton"),
|
|
144
143
|
workflowModeControls: $("#workflowModeControls"),
|
|
145
144
|
workflowModeButton: $("#workflowModeButton"),
|
|
146
145
|
workflowOverlayOpenButton: $("#workflowOverlayOpenButton"),
|
|
@@ -218,6 +217,26 @@ const elements = {
|
|
|
218
217
|
themeSearchResults: $("#themeSearchResults"),
|
|
219
218
|
themeSelect: $("#themeSelect"),
|
|
220
219
|
themeSchemeToggle: $("#themeSchemeToggle"),
|
|
220
|
+
themeCustomizeButton: $("#themeCustomizeButton"),
|
|
221
|
+
themeCustomizerDialog: $("#themeCustomizerDialog"),
|
|
222
|
+
themeCustomizerName: $("#themeCustomizerName"),
|
|
223
|
+
themeCustomizerScope: $("#themeCustomizerScope"),
|
|
224
|
+
themeCustomizerProjectOption: $("#themeCustomizerProjectOption"),
|
|
225
|
+
themeCustomizerScopeHint: $("#themeCustomizerScopeHint"),
|
|
226
|
+
themeCustomizerSourceBadge: $("#themeCustomizerSourceBadge"),
|
|
227
|
+
themeCustomizerVisualFields: $("#themeCustomizerVisualFields"),
|
|
228
|
+
themeCustomizerThinkingMax: $("#themeCustomizerThinkingMax"),
|
|
229
|
+
themeCustomizerVars: $("#themeCustomizerVars"),
|
|
230
|
+
themeCustomizerExportFields: $("#themeCustomizerExportFields"),
|
|
231
|
+
themeCustomizerJson: $("#themeCustomizerJson"),
|
|
232
|
+
themeCustomizerPreview: $("#themeCustomizerPreview"),
|
|
233
|
+
themeCustomizerStatus: $("#themeCustomizerStatus"),
|
|
234
|
+
themeCustomizerOverwrite: $("#themeCustomizerOverwrite"),
|
|
235
|
+
themeCustomizerOverwriteMessage: $("#themeCustomizerOverwriteMessage"),
|
|
236
|
+
themeCustomizerOverwriteButton: $("#themeCustomizerOverwriteButton"),
|
|
237
|
+
themeCustomizerCancelButton: $("#themeCustomizerCancelButton"),
|
|
238
|
+
themeCustomizerResetButton: $("#themeCustomizerResetButton"),
|
|
239
|
+
themeCustomizerSaveButton: $("#themeCustomizerSaveButton"),
|
|
221
240
|
backgroundInput: $("#backgroundInput"),
|
|
222
241
|
backgroundChooseButton: $("#backgroundChooseButton"),
|
|
223
242
|
backgroundClearButton: $("#backgroundClearButton"),
|
|
@@ -543,8 +562,6 @@ let streamThinkingRawText = "";
|
|
|
543
562
|
let streamDerivedTextCache = { rawText: null, assistantText: "", thinkingFormat: null, finalText: "" };
|
|
544
563
|
let streamBubbleVisibleSince = 0;
|
|
545
564
|
let streamBubbleHideTimer = null;
|
|
546
|
-
let streamTextRenderTimer = null;
|
|
547
|
-
let streamTextRenderFrame = null;
|
|
548
565
|
let streamToolCallSeen = false;
|
|
549
566
|
let streamToolCallBubble = null;
|
|
550
567
|
let streamToolCallText = null;
|
|
@@ -568,6 +585,97 @@ let outputModeAcknowledged = false;
|
|
|
568
585
|
let eventSourceOutputModeRequest = "auto";
|
|
569
586
|
let eventSourceOutputModeFallbackAttempted = false;
|
|
570
587
|
const compactLiveScheduler = createSustainedFlushScheduler({ flush: () => flushCompactLiveOutput() });
|
|
588
|
+
const STREAM_ISOLATION_DEBUG_LIMIT = 4096;
|
|
589
|
+
const STREAM_ISOLATION_DEBUG_ENABLED = globalThis.__PI_STREAM_ISOLATION_DEBUG__ === true
|
|
590
|
+
|| new URLSearchParams(window.location.search).get("streamIsolationDebug") === "1";
|
|
591
|
+
const streamIsolationDebugLedger = STREAM_ISOLATION_DEBUG_ENABLED ? {
|
|
592
|
+
version: 1,
|
|
593
|
+
counters: {
|
|
594
|
+
receivedEvents: 0,
|
|
595
|
+
appliedEvents: 0,
|
|
596
|
+
sinkCalls: 0,
|
|
597
|
+
batches: 0,
|
|
598
|
+
barriers: 0,
|
|
599
|
+
overflows: 0,
|
|
600
|
+
unknownEvents: 0,
|
|
601
|
+
staleEvents: 0,
|
|
602
|
+
highWaterPendingCount: 0,
|
|
603
|
+
highWaterPendingBytes: 0,
|
|
604
|
+
},
|
|
605
|
+
receivedIndexes: [],
|
|
606
|
+
appliedIndexes: [],
|
|
607
|
+
records: [],
|
|
608
|
+
unknownEvidence: [],
|
|
609
|
+
} : null;
|
|
610
|
+
const UNKNOWN_TRANSCRIPT_EVIDENCE_LIMIT = 32;
|
|
611
|
+
const UNKNOWN_TRANSCRIPT_EVIDENCE_TEXT_LIMIT = 512;
|
|
612
|
+
const unknownTranscriptEvidence = [];
|
|
613
|
+
const unknownTranscriptOwnersPendingReconcile = new Set();
|
|
614
|
+
|
|
615
|
+
function appendBoundedStreamDiagnostic(list, value, limit = STREAM_ISOLATION_DEBUG_LIMIT) {
|
|
616
|
+
list.push(value);
|
|
617
|
+
if (list.length > limit) list.splice(0, list.length - limit);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
function recordStreamIsolationDiagnostic(record) {
|
|
621
|
+
const ledger = streamIsolationDebugLedger;
|
|
622
|
+
if (!ledger || !record) return;
|
|
623
|
+
const counters = ledger.counters;
|
|
624
|
+
if (record.type === "receipt") {
|
|
625
|
+
counters.receivedEvents += 1;
|
|
626
|
+
if (Number.isSafeInteger(record.index)) appendBoundedStreamDiagnostic(ledger.receivedIndexes, record.index);
|
|
627
|
+
} else if (record.type === "apply") {
|
|
628
|
+
if (record.applied) {
|
|
629
|
+
counters.appliedEvents += Number(record.sourceCount) || 0;
|
|
630
|
+
counters.sinkCalls += 1;
|
|
631
|
+
for (const index of record.sourceIndexes || []) {
|
|
632
|
+
if (Number.isSafeInteger(index)) appendBoundedStreamDiagnostic(ledger.appliedIndexes, index);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
if (record.kind === "unknown-message-update") counters.unknownEvents += Number(record.sourceCount) || 1;
|
|
636
|
+
} else if (record.type === "batch") {
|
|
637
|
+
counters.batches += 1;
|
|
638
|
+
} else if (record.type === "barrier") {
|
|
639
|
+
counters.barriers += 1;
|
|
640
|
+
} else if (record.type === "overflow") {
|
|
641
|
+
counters.overflows += 1;
|
|
642
|
+
} else if (record.type === "stale") {
|
|
643
|
+
counters.staleEvents += 1;
|
|
644
|
+
}
|
|
645
|
+
if (record.type === "queued") {
|
|
646
|
+
counters.highWaterPendingCount = Math.max(counters.highWaterPendingCount, Number(record.pendingCount) || 0);
|
|
647
|
+
counters.highWaterPendingBytes = Math.max(counters.highWaterPendingBytes, Number(record.pendingBytes) || 0);
|
|
648
|
+
}
|
|
649
|
+
appendBoundedStreamDiagnostic(ledger.records, {
|
|
650
|
+
...record,
|
|
651
|
+
sourceIndexes: Array.isArray(record.sourceIndexes) ? [...record.sourceIndexes] : undefined,
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
if (streamIsolationDebugLedger) {
|
|
656
|
+
Object.defineProperty(globalThis, "__piStreamIsolationDebug", {
|
|
657
|
+
configurable: true,
|
|
658
|
+
enumerable: false,
|
|
659
|
+
value: streamIsolationDebugLedger,
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
const streamOutputController = createStreamOutputController({
|
|
664
|
+
isOwnerCurrent: (owner) => owner === transcriptStreamOwner(),
|
|
665
|
+
applyTextUpdate: (event) => handleMessageUpdate(event),
|
|
666
|
+
applyThinkingUpdate: (event) => handleMessageUpdate(event),
|
|
667
|
+
applyToolCallUpdate: (event) => handleMessageUpdate(event),
|
|
668
|
+
applyToolExecutionUpdate: (event) => {
|
|
669
|
+
if (!compactOutputActive()) applyTranscriptToolExecutionUpdate(event);
|
|
670
|
+
},
|
|
671
|
+
applyStreamError: (event) => handleMessageUpdate(event),
|
|
672
|
+
applyFollowScroll: () => {
|
|
673
|
+
if (compactOutputActive()) flushCompactLiveOutput();
|
|
674
|
+
scheduleChatFollowScroll();
|
|
675
|
+
},
|
|
676
|
+
onUnknownStreamEvent: preserveUnknownTranscriptEvidence,
|
|
677
|
+
onDiagnostic: streamIsolationDebugLedger ? recordStreamIsolationDiagnostic : undefined,
|
|
678
|
+
});
|
|
571
679
|
let assistantErrorSurfacedThisRun = false;
|
|
572
680
|
let runIndicatorBubble = null;
|
|
573
681
|
let runIndicatorText = null;
|
|
@@ -577,6 +685,29 @@ let runIndicatorRenderFrame = null;
|
|
|
577
685
|
let runIndicatorRenderScroll = false;
|
|
578
686
|
let runIndicatorGraceCheckTimer = null;
|
|
579
687
|
let runIndicatorLastStateCheckAt = 0;
|
|
688
|
+
// Lifecycle ownership is deliberately separate from the transcript-owned
|
|
689
|
+
// activity label: the transcript ticker only repaints its own elapsed-time
|
|
690
|
+
// node, while this watchdog owns the low-frequency canonical state recheck.
|
|
691
|
+
let lifecycleStateWatchdogTimer = null;
|
|
692
|
+
let lifecycleComposerSignature = null;
|
|
693
|
+
// Bounded dedupe of semantic tool-boundary records (skill tags, event log),
|
|
694
|
+
// partitioned by agent-run epoch so provider tool IDs may be reused next turn.
|
|
695
|
+
const TOOL_BOUNDARY_RECORD_LIMIT = 400;
|
|
696
|
+
const recordedToolBoundaryKeys = new Set();
|
|
697
|
+
const toolBoundaryRunEpochByTab = new Map();
|
|
698
|
+
// Dirty flags owned by the coalesced semantic reconciler. Requests remain
|
|
699
|
+
// partitioned by originating tab generation; raw stream deltas never reach it.
|
|
700
|
+
const SEMANTIC_RECONCILE_FLAGS = Object.freeze([
|
|
701
|
+
"messages",
|
|
702
|
+
"state",
|
|
703
|
+
"footer",
|
|
704
|
+
"footerData",
|
|
705
|
+
"feedback",
|
|
706
|
+
"usage",
|
|
707
|
+
"workflow",
|
|
708
|
+
]);
|
|
709
|
+
const semanticReconcilePending = new Map();
|
|
710
|
+
let semanticReconcileFrame = null;
|
|
580
711
|
let runIndicatorLocallyActive = false;
|
|
581
712
|
let runIndicatorRemovalDeferred = false;
|
|
582
713
|
let runIndicatorStartedAt = null;
|
|
@@ -624,6 +755,7 @@ let nativeCommandTabId = null;
|
|
|
624
755
|
let nativeSettingsDirty = false;
|
|
625
756
|
let sessionSummaryOverlayTabId = null;
|
|
626
757
|
let sessionSummaryOverlayFocusReturn = null;
|
|
758
|
+
let sessionSummaryOverlayFocusReturnKey = "";
|
|
627
759
|
const sessionSummaryByTab = new Map();
|
|
628
760
|
let pathPickerState = null;
|
|
629
761
|
let firstTerminalCwdPromptShown = false;
|
|
@@ -656,6 +788,7 @@ let optionsMenuOpen = false;
|
|
|
656
788
|
let availableCommands = [];
|
|
657
789
|
let rawAvailableCommands = [];
|
|
658
790
|
const commandCatalogsByTab = new Map();
|
|
791
|
+
const commandCatalogRefreshesByTab = new Map();
|
|
659
792
|
let commandSuggestions = [];
|
|
660
793
|
let pathSuggestions = [];
|
|
661
794
|
let bangSuggestions = [];
|
|
@@ -787,9 +920,6 @@ let chatFollowFrame = null;
|
|
|
787
920
|
let chatFollowSettleTimer = null;
|
|
788
921
|
let chatFollowNeedsSettle = false;
|
|
789
922
|
let liveWidgetRenderFrame = null;
|
|
790
|
-
let liveTodoProgressSyncFrame = null;
|
|
791
|
-
let liveTodoProgressPendingText = "";
|
|
792
|
-
let liveTodoProgressPendingTabId = null;
|
|
793
923
|
let lastChatProgrammaticScrollAt = 0;
|
|
794
924
|
let chatUserScrollIntentUntil = 0;
|
|
795
925
|
let chatUserScrollAwayIntentUntil = 0;
|
|
@@ -1020,6 +1150,9 @@ const THEME_LIGHT_DEFAULT = "catppuccin-latte";
|
|
|
1020
1150
|
const THEME_DARK_DEFAULT = "catppuccin-mocha";
|
|
1021
1151
|
const THEME_SCHEME_MODES = new Set(["light", "dark", "auto"]);
|
|
1022
1152
|
let themeSchemeMode = "light"; // "light" | "dark" | "auto"; finalized in initializeThemes
|
|
1153
|
+
let themeCatalogScopes = { global: { available: true }, project: { available: false, trusted: false } };
|
|
1154
|
+
let themeCustomizerGeneration = 0;
|
|
1155
|
+
let themeCustomizerState = null;
|
|
1023
1156
|
const TERMINAL_TABS_LAYOUTS = new Set(["top", "left"]);
|
|
1024
1157
|
const TERMINAL_TABS_LAYOUT_LABELS = { top: "Top bar", left: "Left sidebar" };
|
|
1025
1158
|
const SUBAGENT_OPEN_MODES = new Set(["overlay", "tab"]);
|
|
@@ -1054,9 +1187,7 @@ const ABORT_LONG_PRESS_TICK_MS = 100;
|
|
|
1054
1187
|
const ABORT_LONG_PRESS_RELEASE_GRACE_MS = 350;
|
|
1055
1188
|
const EMPTY_PROMPT_ESCAPE_AFTER_ABORT_GRACE_MS = 1000;
|
|
1056
1189
|
const STREAM_OUTPUT_HIDE_DELAY_MS = 300;
|
|
1057
|
-
const STREAM_OUTPUT_TOOLCALL_GUARD_MS = 220;
|
|
1058
1190
|
const STREAM_OUTPUT_MIN_VISIBLE_MS = 900;
|
|
1059
|
-
const TOOL_LIVE_UPDATE_THROTTLE_MS = 80;
|
|
1060
1191
|
const UNEXPOSED_THINKING_TEXT = "No thinking content was exposed by the provider.";
|
|
1061
1192
|
const THINKING_FORMAT_OPEN_TAG_REGEX = /^<think\b[^>]*>/i;
|
|
1062
1193
|
const THINKING_FORMAT_CLOSE_TAG_REGEX = /<\/think\s*>/i;
|
|
@@ -2204,8 +2335,6 @@ const appRunnerContextLineDraftByRun = new Map();
|
|
|
2204
2335
|
const scopedScrollContinuityByKey = new Map();
|
|
2205
2336
|
const liveToolRuns = new Map();
|
|
2206
2337
|
const liveToolCards = new Map();
|
|
2207
|
-
const liveToolRenderQueue = new Map();
|
|
2208
|
-
let liveToolRenderTimer = null;
|
|
2209
2338
|
// Optional feature detection intentionally checks loaded Pi capabilities (RPC-visible
|
|
2210
2339
|
// commands and live widget events), not npm package folders. This keeps local dev
|
|
2211
2340
|
// symlinks and independently installed packages working.
|
|
@@ -2857,6 +2986,7 @@ const optionalFeatureInstallMessages = new Map();
|
|
|
2857
2986
|
const optionalFeatureInstallStates = new Map();
|
|
2858
2987
|
const optionalFeatureInstallProgressTimers = new Map();
|
|
2859
2988
|
const optionalFeatureMigrationResultEvents = new Set();
|
|
2989
|
+
const OPTIONAL_FEATURE_READY_AUTO_DISMISS_MS = 5_000;
|
|
2860
2990
|
let optionalFeatureBatchState = null;
|
|
2861
2991
|
let optionalFeatureMigrationSnapshot = {
|
|
2862
2992
|
phase: "checking",
|
|
@@ -2870,6 +3000,9 @@ let optionalFeatureMigrationSnapshot = {
|
|
|
2870
3000
|
};
|
|
2871
3001
|
let optionalFeatureMigrationCheckingStartedAt = Date.now();
|
|
2872
3002
|
let optionalFeatureMigrationRenderTimer = null;
|
|
3003
|
+
let optionalFeatureMigrationReadyDismissTimer = null;
|
|
3004
|
+
let optionalFeatureMigrationPendingReadyDismissKey = "";
|
|
3005
|
+
let optionalFeatureMigrationDismissedReadyKey = "";
|
|
2873
3006
|
let optionalFeatureMigrationDialogState = null;
|
|
2874
3007
|
let optionalFeatureMigrationLastPhase = "";
|
|
2875
3008
|
let optionalFeatureMigrationCompletionFocusKey = "";
|
|
@@ -2880,7 +3013,7 @@ const gitFooterPayloadRefreshInFlightByTab = new Set();
|
|
|
2880
3013
|
const gitFooterPayloadStateByTab = new Map();
|
|
2881
3014
|
const gitFooterPayloadSettlementTimersByTab = new Map();
|
|
2882
3015
|
const gitFooterPayloadRequestSerialByTab = new Map();
|
|
2883
|
-
const
|
|
3016
|
+
const gitFooterSyncInFlightByTab = new Set();
|
|
2884
3017
|
const gitFooterPiCalibrationInFlightByTab = new Set();
|
|
2885
3018
|
let gitFooterVisibilityApplyInFlight = false;
|
|
2886
3019
|
let gitFooterVisibilityDirty = false;
|
|
@@ -5057,7 +5190,7 @@ function bindTerminalTabDragAndDrop(element, { sourceTabId = "", target = null }
|
|
|
5057
5190
|
element.draggable = true;
|
|
5058
5191
|
element.dataset.dragTabId = sourceTabId;
|
|
5059
5192
|
element.addEventListener("dragstart", (event) => {
|
|
5060
|
-
if (event.target?.closest?.(".terminal-tab-close, .terminal-tab-group-add")) {
|
|
5193
|
+
if (event.target?.closest?.(".terminal-tab-close, .terminal-tab-actions, .terminal-tab-group-add")) {
|
|
5061
5194
|
event.preventDefault();
|
|
5062
5195
|
return;
|
|
5063
5196
|
}
|
|
@@ -5598,29 +5731,31 @@ function trackSkillsFromText(tabId, text, { kind = "used", source = "" } = {}) {
|
|
|
5598
5731
|
}
|
|
5599
5732
|
|
|
5600
5733
|
function trackSkillsFromValue(tabId, value, { keyHint = "", kind = "used", source = "", depth = 0 } = {}) {
|
|
5601
|
-
if (!tabId || value === undefined || value === null || depth > 5) return;
|
|
5734
|
+
if (!tabId || value === undefined || value === null || depth > 5) return 0;
|
|
5602
5735
|
if (Array.isArray(value)) {
|
|
5603
|
-
|
|
5604
|
-
return;
|
|
5736
|
+
return value.reduce((count, item) => count + trackSkillsFromValue(tabId, item, { keyHint, kind, source, depth: depth + 1 }), 0);
|
|
5605
5737
|
}
|
|
5606
5738
|
if (typeof value === "string") {
|
|
5607
5739
|
const skillInfo = skillInfoFromPath(value);
|
|
5608
|
-
if (skillInfo)
|
|
5609
|
-
|
|
5740
|
+
if (!skillInfo) return 0;
|
|
5741
|
+
trackSkillUsage(tabId, skillInfo.name, "read", source, { path: skillInfo.path });
|
|
5742
|
+
return 1;
|
|
5610
5743
|
}
|
|
5611
|
-
if (typeof value !== "object") return;
|
|
5744
|
+
if (typeof value !== "object") return 0;
|
|
5745
|
+
let tracked = 0;
|
|
5612
5746
|
for (const [key, nested] of Object.entries(value)) {
|
|
5613
5747
|
const hint = String(key || "").toLowerCase();
|
|
5614
|
-
trackSkillsFromValue(tabId, nested, { keyHint: hint, kind, source, depth: depth + 1 });
|
|
5748
|
+
tracked += trackSkillsFromValue(tabId, nested, { keyHint: hint, kind, source, depth: depth + 1 });
|
|
5615
5749
|
}
|
|
5750
|
+
return tracked;
|
|
5616
5751
|
}
|
|
5617
5752
|
|
|
5618
5753
|
function trackSkillsFromToolInvocation(tabId, toolName, args, { sourcePrefix = "tool" } = {}) {
|
|
5619
|
-
if (!tabId) return;
|
|
5754
|
+
if (!tabId) return false;
|
|
5620
5755
|
const name = String(toolName || "").trim();
|
|
5621
|
-
if (name.toLowerCase() !== "read") return;
|
|
5756
|
+
if (name.toLowerCase() !== "read") return false;
|
|
5622
5757
|
const source = `${sourcePrefix}:${name}`;
|
|
5623
|
-
trackSkillsFromValue(tabId, args, { kind: "read", source });
|
|
5758
|
+
return trackSkillsFromValue(tabId, args, { kind: "read", source }) > 0;
|
|
5624
5759
|
}
|
|
5625
5760
|
|
|
5626
5761
|
function trackSkillsFromMessage(tabId, message) {
|
|
@@ -5647,26 +5782,67 @@ function assistantMessageUpdateType(event) {
|
|
|
5647
5782
|
return event?.assistantMessageEvent?.type || "";
|
|
5648
5783
|
}
|
|
5649
5784
|
|
|
5785
|
+
// Skill usage is recorded only at semantic tool boundaries. Argument/output
|
|
5786
|
+
// delta cadence (`toolcall_*`, `tool_execution_update`) must never enter skill
|
|
5787
|
+
// tracking: those raw fragments are transcript-owned stream content.
|
|
5650
5788
|
function eventMayAffectSkillUsage(event) {
|
|
5651
5789
|
const type = event?.type || "";
|
|
5652
|
-
return ["tool_execution_start", "
|
|
5653
|
-
|| (type === "message_update" && assistantMessageUpdateType(event) === "toolcall_start")
|
|
5790
|
+
return ["tool_execution_start", "tool_execution_end"].includes(type)
|
|
5654
5791
|
|| (type === "response" && event.command === "new_session");
|
|
5655
5792
|
}
|
|
5656
5793
|
|
|
5794
|
+
function beginToolBoundaryRun(event) {
|
|
5795
|
+
const tabId = event?.tabId || activeTabId || "";
|
|
5796
|
+
if (!tabId || event?.replayed === true) return;
|
|
5797
|
+
toolBoundaryRunEpochByTab.set(tabId, (toolBoundaryRunEpochByTab.get(tabId) || 0) + 1);
|
|
5798
|
+
}
|
|
5799
|
+
|
|
5800
|
+
function toolBoundaryRunIdentity(event, tabId) {
|
|
5801
|
+
const explicit = String(event?.agentRunId || event?.turnId || "").trim();
|
|
5802
|
+
return explicit || `epoch-${toolBoundaryRunEpochByTab.get(tabId) || 0}`;
|
|
5803
|
+
}
|
|
5804
|
+
|
|
5805
|
+
function toolBoundaryRecordKey(event, phase) {
|
|
5806
|
+
const tabId = event?.tabId || activeTabId || "";
|
|
5807
|
+
const toolCallId = String(event?.toolCallId || event?.id || "").trim();
|
|
5808
|
+
if (!toolCallId) return "";
|
|
5809
|
+
return `${tabId}:${toolBoundaryRunIdentity(event, tabId)}:${toolCallId}:${phase}`;
|
|
5810
|
+
}
|
|
5811
|
+
|
|
5812
|
+
function rememberToolBoundaryRecordKey(key) {
|
|
5813
|
+
if (!key || recordedToolBoundaryKeys.has(key)) return false;
|
|
5814
|
+
recordedToolBoundaryKeys.add(key);
|
|
5815
|
+
while (recordedToolBoundaryKeys.size > TOOL_BOUNDARY_RECORD_LIMIT) {
|
|
5816
|
+
const oldest = recordedToolBoundaryKeys.values().next().value;
|
|
5817
|
+
if (oldest === undefined) break;
|
|
5818
|
+
recordedToolBoundaryKeys.delete(oldest);
|
|
5819
|
+
}
|
|
5820
|
+
return true;
|
|
5821
|
+
}
|
|
5822
|
+
|
|
5823
|
+
// One record per tool boundary within an agent run. Redelivered or replayed
|
|
5824
|
+
// boundaries must not duplicate skill tags or event-log lines.
|
|
5825
|
+
function claimToolBoundaryRecord(event, phase) {
|
|
5826
|
+
const key = toolBoundaryRecordKey(event, phase);
|
|
5827
|
+
return key ? rememberToolBoundaryRecordKey(key) : true;
|
|
5828
|
+
}
|
|
5829
|
+
|
|
5657
5830
|
function trackSkillsFromEvent(event) {
|
|
5658
5831
|
const tabId = event?.tabId || activeTabId;
|
|
5659
5832
|
if (!tabId || !event) return;
|
|
5660
|
-
if (["tool_execution_start", "
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
const
|
|
5666
|
-
trackSkillsFromToolInvocation(tabId,
|
|
5833
|
+
if (["tool_execution_start", "tool_execution_end"].includes(event.type)) {
|
|
5834
|
+
// Start is preferred, but unusable start args do not consume the claim;
|
|
5835
|
+
// completion may still provide the authoritative invocation arguments.
|
|
5836
|
+
const key = toolBoundaryRecordKey(event, "skills");
|
|
5837
|
+
if (key && recordedToolBoundaryKeys.has(key)) return;
|
|
5838
|
+
const args = event.args ?? event.arguments ?? event.invocation?.args;
|
|
5839
|
+
const tracked = trackSkillsFromToolInvocation(tabId, event.toolName, args, { sourcePrefix: `event:${event.type}` });
|
|
5840
|
+
if (tracked && key) rememberToolBoundaryRecordKey(key);
|
|
5667
5841
|
return;
|
|
5668
5842
|
}
|
|
5669
5843
|
if (event.type === "response" && event.command === "new_session") {
|
|
5844
|
+
recordedToolBoundaryKeys.clear();
|
|
5845
|
+
toolBoundaryRunEpochByTab.delete(tabId);
|
|
5670
5846
|
clearSkillUsageForTab(tabId);
|
|
5671
5847
|
}
|
|
5672
5848
|
}
|
|
@@ -9266,7 +9442,6 @@ function renderOptionalFeatureDependentDisplays() {
|
|
|
9266
9442
|
renderWidgets();
|
|
9267
9443
|
renderStatus();
|
|
9268
9444
|
renderCommands();
|
|
9269
|
-
cancelStreamingAssistantTextRender();
|
|
9270
9445
|
cancelStreamBubbleHide();
|
|
9271
9446
|
streamBubble?.remove();
|
|
9272
9447
|
streamBubble = null;
|
|
@@ -9331,7 +9506,14 @@ function displayThemeName(name) {
|
|
|
9331
9506
|
}
|
|
9332
9507
|
|
|
9333
9508
|
function resolveThemeValue(theme, value, fallback, seen = new Set()) {
|
|
9334
|
-
|
|
9509
|
+
if (Number.isInteger(value)) {
|
|
9510
|
+
try {
|
|
9511
|
+
return themeColorToRgb(value, theme?.vars || {}, fallback);
|
|
9512
|
+
} catch {
|
|
9513
|
+
return fallback;
|
|
9514
|
+
}
|
|
9515
|
+
}
|
|
9516
|
+
const raw = String(value ?? "").trim();
|
|
9335
9517
|
if (!raw) return fallback;
|
|
9336
9518
|
if (/^(#|rgb\(|rgba\(|hsl\(|hsla\()/i.test(raw)) return raw;
|
|
9337
9519
|
if (seen.has(raw)) return fallback;
|
|
@@ -9642,7 +9824,10 @@ function renderThemeSearchResults(themes = []) {
|
|
|
9642
9824
|
button.title = themeSearchText(theme);
|
|
9643
9825
|
const title = make("span", "theme-search-result-title");
|
|
9644
9826
|
title.append(make("span", "model-search-result-main", themeDisplayLabel(theme)));
|
|
9645
|
-
|
|
9827
|
+
const badges = make("span", "theme-search-result-badges");
|
|
9828
|
+
badges.append(make("span", `theme-search-result-scheme ${themeIsLight(theme) ? "light" : "dark"}`, themeIsLight(theme) ? "Light" : "Dark"));
|
|
9829
|
+
if (theme.custom) badges.append(make("span", `theme-scope-badge ${theme.scope}`, themeScopeLabel(theme.scope)));
|
|
9830
|
+
title.append(badges);
|
|
9646
9831
|
button.append(title);
|
|
9647
9832
|
button.addEventListener("click", () => {
|
|
9648
9833
|
if (elements.themeSelect) elements.themeSelect.value = theme.name;
|
|
@@ -9692,6 +9877,422 @@ function toggleThemeSearchInput() {
|
|
|
9692
9877
|
else hideThemeSearchInput();
|
|
9693
9878
|
}
|
|
9694
9879
|
|
|
9880
|
+
function themeScopeLabel(scope) {
|
|
9881
|
+
if (scope === "project") return "Project";
|
|
9882
|
+
if (scope === "global") return "Global";
|
|
9883
|
+
return "Bundled";
|
|
9884
|
+
}
|
|
9885
|
+
|
|
9886
|
+
function cloneThemeDraft(theme) {
|
|
9887
|
+
return JSON.parse(JSON.stringify(theme));
|
|
9888
|
+
}
|
|
9889
|
+
|
|
9890
|
+
function themeDraftFromCatalog(theme, name = theme?.name) {
|
|
9891
|
+
return {
|
|
9892
|
+
name,
|
|
9893
|
+
...(theme?.vars && Object.keys(theme.vars).length ? { vars: cloneThemeDraft(theme.vars) } : {}),
|
|
9894
|
+
colors: cloneThemeDraft(theme?.colors || {}),
|
|
9895
|
+
...(theme?.export && Object.keys(theme.export).length ? { export: cloneThemeDraft(theme.export) } : {}),
|
|
9896
|
+
};
|
|
9897
|
+
}
|
|
9898
|
+
|
|
9899
|
+
function themeCustomizerValue(raw) {
|
|
9900
|
+
const value = String(raw ?? "").trim();
|
|
9901
|
+
if (/^(?:0|[1-9]\d{0,2})$/.test(value)) return Number(value);
|
|
9902
|
+
return value;
|
|
9903
|
+
}
|
|
9904
|
+
|
|
9905
|
+
function themeCustomizerDraftSignature(state = themeCustomizerState) {
|
|
9906
|
+
if (!state?.validTheme) return "";
|
|
9907
|
+
return JSON.stringify({
|
|
9908
|
+
scope: elements.themeCustomizerScope?.value || "",
|
|
9909
|
+
fileName: `${elements.themeCustomizerName?.value.trim() || ""}.json`,
|
|
9910
|
+
theme: state.validTheme,
|
|
9911
|
+
});
|
|
9912
|
+
}
|
|
9913
|
+
|
|
9914
|
+
function setThemeCustomizerStatus(message, kind = "muted") {
|
|
9915
|
+
if (!elements.themeCustomizerStatus) return;
|
|
9916
|
+
const urgent = kind === "error";
|
|
9917
|
+
elements.themeCustomizerStatus.textContent = message;
|
|
9918
|
+
elements.themeCustomizerStatus.className = `theme-customizer-status ${kind}`;
|
|
9919
|
+
elements.themeCustomizerStatus.setAttribute("role", urgent ? "alert" : "status");
|
|
9920
|
+
elements.themeCustomizerStatus.setAttribute("aria-live", urgent ? "assertive" : "polite");
|
|
9921
|
+
}
|
|
9922
|
+
|
|
9923
|
+
function invalidateThemeCustomizerOverwrite() {
|
|
9924
|
+
if (themeCustomizerState) themeCustomizerState.overwrite = null;
|
|
9925
|
+
if (elements.themeCustomizerOverwrite) elements.themeCustomizerOverwrite.hidden = true;
|
|
9926
|
+
}
|
|
9927
|
+
|
|
9928
|
+
function updateThemeCustomizerActions() {
|
|
9929
|
+
const state = themeCustomizerState;
|
|
9930
|
+
const name = elements.themeCustomizerName?.value.trim() || "";
|
|
9931
|
+
const validName = /^[A-Za-z0-9][A-Za-z0-9._-]{0,74}$/.test(name) && !name.includes("..");
|
|
9932
|
+
const scope = elements.themeCustomizerScope?.value;
|
|
9933
|
+
const projectUnavailable = scope === "project" && !themeCatalogScopes.project?.trusted;
|
|
9934
|
+
if (elements.themeCustomizerSaveButton) {
|
|
9935
|
+
elements.themeCustomizerSaveButton.disabled = !state?.draftValid || !validName || projectUnavailable || !!state?.saving || !!state?.overwrite;
|
|
9936
|
+
elements.themeCustomizerSaveButton.textContent = state?.saving ? "Saving…" : "Save theme";
|
|
9937
|
+
}
|
|
9938
|
+
if (elements.themeCustomizerOverwriteButton) elements.themeCustomizerOverwriteButton.disabled = !!state?.saving;
|
|
9939
|
+
if (elements.themeCustomizerCancelButton) elements.themeCustomizerCancelButton.disabled = !!state?.saving;
|
|
9940
|
+
if (elements.themeCustomizerResetButton) elements.themeCustomizerResetButton.disabled = !!state?.saving;
|
|
9941
|
+
if (!validName) setThemeCustomizerStatus("Use 1–75 letters, numbers, dots, underscores, or hyphens; consecutive dots are not allowed.", "error");
|
|
9942
|
+
else if (projectUnavailable) setThemeCustomizerStatus("This project is not saved as trusted in Pi. Choose Global themes or trust the project in Pi first.", "warn");
|
|
9943
|
+
}
|
|
9944
|
+
|
|
9945
|
+
function themeCustomizerColor(theme, token) {
|
|
9946
|
+
try {
|
|
9947
|
+
return themeColorToRgb(theme.colors[token], theme.vars || {}, "#000000");
|
|
9948
|
+
} catch {
|
|
9949
|
+
return "#000000";
|
|
9950
|
+
}
|
|
9951
|
+
}
|
|
9952
|
+
|
|
9953
|
+
function renderThemeCustomizerVisualFields(theme) {
|
|
9954
|
+
const container = elements.themeCustomizerVisualFields;
|
|
9955
|
+
if (!container || !theme) return;
|
|
9956
|
+
const groups = THEME_TOKEN_GROUPS.map((group) => {
|
|
9957
|
+
const fieldset = make("fieldset", "theme-token-group");
|
|
9958
|
+
fieldset.dataset.themeTokenGroup = group.id;
|
|
9959
|
+
fieldset.append(make("legend", undefined, group.label));
|
|
9960
|
+
const grid = make("div", "theme-token-grid");
|
|
9961
|
+
for (const { name, label } of group.tokens) {
|
|
9962
|
+
const row = make("div", "theme-token-row");
|
|
9963
|
+
row.dataset.themeToken = name;
|
|
9964
|
+
const inputId = `theme-token-${name}`;
|
|
9965
|
+
const copy = document.createElement("label");
|
|
9966
|
+
copy.className = "theme-token-label";
|
|
9967
|
+
copy.htmlFor = inputId;
|
|
9968
|
+
copy.append(document.createTextNode(label), make("code", undefined, name));
|
|
9969
|
+
const swatch = document.createElement("input");
|
|
9970
|
+
swatch.className = "theme-token-swatch";
|
|
9971
|
+
swatch.type = "color";
|
|
9972
|
+
const value = document.createElement("input");
|
|
9973
|
+
value.id = inputId;
|
|
9974
|
+
value.className = "theme-token-value";
|
|
9975
|
+
value.type = "text";
|
|
9976
|
+
value.autocomplete = "off";
|
|
9977
|
+
value.spellcheck = false;
|
|
9978
|
+
value.value = String(theme.colors[name] ?? "");
|
|
9979
|
+
value.setAttribute("aria-label", `${label} value`);
|
|
9980
|
+
const swatchNote = make("span", "theme-token-swatch-note");
|
|
9981
|
+
const syncSwatch = () => {
|
|
9982
|
+
const raw = value.value.trim();
|
|
9983
|
+
const directValue = themeCustomizerValue(raw);
|
|
9984
|
+
const direct = /^#[0-9a-f]{6}$/i.test(raw) || (typeof directValue === "number" && directValue >= 0 && directValue <= 255);
|
|
9985
|
+
swatch.disabled = !direct;
|
|
9986
|
+
swatch.value = direct ? themeColorToRgb(directValue, {}, "#000000") : themeCustomizerColor(theme, name);
|
|
9987
|
+
swatch.setAttribute("aria-label", direct
|
|
9988
|
+
? `Choose ${label} color`
|
|
9989
|
+
: `${label} uses ${raw ? `variable ${raw}` : "the terminal default"}. Edit the raw value to replace it with a color.`);
|
|
9990
|
+
swatchNote.hidden = direct;
|
|
9991
|
+
swatchNote.textContent = raw ? `Variable ${raw}; edit the value to replace it.` : "Terminal default; edit the value to replace it.";
|
|
9992
|
+
};
|
|
9993
|
+
value.addEventListener("input", () => {
|
|
9994
|
+
syncSwatch();
|
|
9995
|
+
updateThemeCustomizerFromVisual();
|
|
9996
|
+
});
|
|
9997
|
+
swatch.addEventListener("input", () => {
|
|
9998
|
+
value.value = swatch.value;
|
|
9999
|
+
syncSwatch();
|
|
10000
|
+
updateThemeCustomizerFromVisual();
|
|
10001
|
+
});
|
|
10002
|
+
syncSwatch();
|
|
10003
|
+
row.append(copy, swatch, value, swatchNote);
|
|
10004
|
+
grid.append(row);
|
|
10005
|
+
}
|
|
10006
|
+
fieldset.append(grid);
|
|
10007
|
+
return fieldset;
|
|
10008
|
+
});
|
|
10009
|
+
container.replaceChildren(...groups);
|
|
10010
|
+
}
|
|
10011
|
+
|
|
10012
|
+
function renderThemeCustomizerOptionalFields(theme) {
|
|
10013
|
+
if (!theme) return;
|
|
10014
|
+
if (elements.themeCustomizerThinkingMax) elements.themeCustomizerThinkingMax.value = String(theme.colors.thinkingMax ?? "");
|
|
10015
|
+
if (elements.themeCustomizerVars) elements.themeCustomizerVars.value = JSON.stringify(theme.vars || {}, null, 2);
|
|
10016
|
+
if (elements.themeCustomizerExportFields) {
|
|
10017
|
+
const fields = PI_THEME_EXPORT_FIELDS.map((name) => {
|
|
10018
|
+
const label = document.createElement("label");
|
|
10019
|
+
label.textContent = name;
|
|
10020
|
+
const input = document.createElement("input");
|
|
10021
|
+
input.type = "text";
|
|
10022
|
+
input.autocomplete = "off";
|
|
10023
|
+
input.spellcheck = false;
|
|
10024
|
+
input.dataset.themeExport = name;
|
|
10025
|
+
input.value = String(theme.export?.[name] ?? "");
|
|
10026
|
+
input.addEventListener("input", updateThemeCustomizerFromVisual);
|
|
10027
|
+
label.append(input);
|
|
10028
|
+
return label;
|
|
10029
|
+
});
|
|
10030
|
+
elements.themeCustomizerExportFields.replaceChildren(...fields);
|
|
10031
|
+
}
|
|
10032
|
+
}
|
|
10033
|
+
|
|
10034
|
+
function themeCustomizerCandidateFromVisual() {
|
|
10035
|
+
const state = themeCustomizerState;
|
|
10036
|
+
if (!state?.validTheme) throw new Error("No valid theme draft is available.");
|
|
10037
|
+
const candidate = cloneThemeDraft(state.validTheme);
|
|
10038
|
+
candidate.name = elements.themeCustomizerName.value.trim();
|
|
10039
|
+
candidate.colors = { ...candidate.colors };
|
|
10040
|
+
for (const input of elements.themeCustomizerVisualFields.querySelectorAll("[data-theme-token] .theme-token-value")) {
|
|
10041
|
+
candidate.colors[input.closest("[data-theme-token]").dataset.themeToken] = themeCustomizerValue(input.value);
|
|
10042
|
+
}
|
|
10043
|
+
const thinkingMax = elements.themeCustomizerThinkingMax.value.trim();
|
|
10044
|
+
if (thinkingMax) candidate.colors.thinkingMax = themeCustomizerValue(thinkingMax);
|
|
10045
|
+
else delete candidate.colors.thinkingMax;
|
|
10046
|
+
let vars;
|
|
10047
|
+
try {
|
|
10048
|
+
vars = JSON.parse(elements.themeCustomizerVars.value || "{}");
|
|
10049
|
+
} catch (error) {
|
|
10050
|
+
throw new Error(`Variables JSON is invalid: ${error.message}`);
|
|
10051
|
+
}
|
|
10052
|
+
if (!vars || typeof vars !== "object" || Array.isArray(vars)) throw new Error("Variables must be a JSON object.");
|
|
10053
|
+
if (Object.keys(vars).length) candidate.vars = vars;
|
|
10054
|
+
else delete candidate.vars;
|
|
10055
|
+
const exportColors = {};
|
|
10056
|
+
for (const input of elements.themeCustomizerExportFields.querySelectorAll("[data-theme-export]")) {
|
|
10057
|
+
if (input.value.trim()) exportColors[input.dataset.themeExport] = themeCustomizerValue(input.value);
|
|
10058
|
+
}
|
|
10059
|
+
if (Object.keys(exportColors).length) candidate.export = exportColors;
|
|
10060
|
+
else delete candidate.export;
|
|
10061
|
+
return candidate;
|
|
10062
|
+
}
|
|
10063
|
+
|
|
10064
|
+
function acceptThemeCustomizerDraft(candidate, { syncJson = true, syncControls = false } = {}) {
|
|
10065
|
+
const state = themeCustomizerState;
|
|
10066
|
+
if (!state) return false;
|
|
10067
|
+
const validation = validateTheme(candidate, { allowWebuiExport: true });
|
|
10068
|
+
if (!validation.ok) {
|
|
10069
|
+
state.draftValid = false;
|
|
10070
|
+
invalidateThemeCustomizerOverwrite();
|
|
10071
|
+
setThemeCustomizerStatus(validation.issues.map(({ path, message }) => `${path}: ${message}`).join(" · "), "error");
|
|
10072
|
+
updateThemeCustomizerActions();
|
|
10073
|
+
return false;
|
|
10074
|
+
}
|
|
10075
|
+
const canonical = canonicalizeTheme(candidate, { allowWebuiExport: true });
|
|
10076
|
+
state.validTheme = canonical;
|
|
10077
|
+
state.draftValid = true;
|
|
10078
|
+
invalidateThemeCustomizerOverwrite();
|
|
10079
|
+
if (syncJson && elements.themeCustomizerJson) elements.themeCustomizerJson.value = serializeTheme(canonical, { allowWebuiExport: true });
|
|
10080
|
+
if (syncControls) {
|
|
10081
|
+
elements.themeCustomizerName.value = canonical.name;
|
|
10082
|
+
renderThemeCustomizerVisualFields(canonical);
|
|
10083
|
+
renderThemeCustomizerOptionalFields(canonical);
|
|
10084
|
+
}
|
|
10085
|
+
applyTheme(canonical, { persist: false });
|
|
10086
|
+
setThemeCustomizerStatus("Valid draft previewed. Nothing has been written to browser storage or disk.", "success");
|
|
10087
|
+
updateThemeCustomizerActions();
|
|
10088
|
+
return true;
|
|
10089
|
+
}
|
|
10090
|
+
|
|
10091
|
+
function updateThemeCustomizerFromVisual() {
|
|
10092
|
+
if (!themeCustomizerState) return;
|
|
10093
|
+
invalidateThemeCustomizerOverwrite();
|
|
10094
|
+
try {
|
|
10095
|
+
acceptThemeCustomizerDraft(themeCustomizerCandidateFromVisual(), { syncJson: true });
|
|
10096
|
+
} catch (error) {
|
|
10097
|
+
themeCustomizerState.draftValid = false;
|
|
10098
|
+
setThemeCustomizerStatus(error.message || String(error), "error");
|
|
10099
|
+
updateThemeCustomizerActions();
|
|
10100
|
+
}
|
|
10101
|
+
}
|
|
10102
|
+
|
|
10103
|
+
function updateThemeCustomizerFromJson() {
|
|
10104
|
+
if (!themeCustomizerState) return;
|
|
10105
|
+
invalidateThemeCustomizerOverwrite();
|
|
10106
|
+
let candidate;
|
|
10107
|
+
try {
|
|
10108
|
+
candidate = JSON.parse(elements.themeCustomizerJson.value);
|
|
10109
|
+
} catch (error) {
|
|
10110
|
+
themeCustomizerState.draftValid = false;
|
|
10111
|
+
setThemeCustomizerStatus(`Advanced JSON is invalid: ${error.message}. The last valid preview remains active.`, "error");
|
|
10112
|
+
updateThemeCustomizerActions();
|
|
10113
|
+
return;
|
|
10114
|
+
}
|
|
10115
|
+
acceptThemeCustomizerDraft(candidate, { syncJson: false, syncControls: true });
|
|
10116
|
+
}
|
|
10117
|
+
|
|
10118
|
+
function restoreThemeCustomizerOpeningState(generation) {
|
|
10119
|
+
const state = themeCustomizerState;
|
|
10120
|
+
if (!state || state.generation !== generation || state.restored) return;
|
|
10121
|
+
state.restored = true;
|
|
10122
|
+
applyTheme(state.opening.theme, { persist: false });
|
|
10123
|
+
setCustomBackgroundRecord(state.opening.background);
|
|
10124
|
+
customBackgroundLoading = false;
|
|
10125
|
+
applyCustomBackgroundOverride();
|
|
10126
|
+
renderThemeSelect();
|
|
10127
|
+
}
|
|
10128
|
+
|
|
10129
|
+
function closeThemeCustomizer({ restore = true } = {}) {
|
|
10130
|
+
const state = themeCustomizerState;
|
|
10131
|
+
if (!state) {
|
|
10132
|
+
if (elements.themeCustomizerDialog?.open) elements.themeCustomizerDialog.close();
|
|
10133
|
+
return;
|
|
10134
|
+
}
|
|
10135
|
+
if (state.saving) {
|
|
10136
|
+
setThemeCustomizerStatus("Wait for the theme save to finish before closing or switching tabs.", "warn");
|
|
10137
|
+
return false;
|
|
10138
|
+
}
|
|
10139
|
+
const generation = state.generation;
|
|
10140
|
+
state.closing = true;
|
|
10141
|
+
if (restore) restoreThemeCustomizerOpeningState(generation);
|
|
10142
|
+
themeCustomizerState = null;
|
|
10143
|
+
if (elements.themeCustomizerDialog?.open) elements.themeCustomizerDialog.close();
|
|
10144
|
+
return true;
|
|
10145
|
+
}
|
|
10146
|
+
|
|
10147
|
+
function themeCustomizerNameForSource(theme) {
|
|
10148
|
+
const raw = theme?.custom ? theme.name : `${theme?.name || "custom-theme"}-custom`;
|
|
10149
|
+
return raw.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^[^A-Za-z0-9]+/, "").slice(0, 75) || "custom-theme";
|
|
10150
|
+
}
|
|
10151
|
+
|
|
10152
|
+
function installThemeCatalog(data) {
|
|
10153
|
+
availableThemes = Array.isArray(data?.themes) ? data.themes : [];
|
|
10154
|
+
themeCatalogScopes = data?.scopes && typeof data.scopes === "object" ? data.scopes : themeCatalogScopes;
|
|
10155
|
+
optionalFeatureAvailability.themeBundle = availableThemes.length > 0;
|
|
10156
|
+
renderOptionalFeatureControls();
|
|
10157
|
+
renderThemeSelect();
|
|
10158
|
+
}
|
|
10159
|
+
|
|
10160
|
+
async function refreshThemeCatalog(tabContext = activeTabContext()) {
|
|
10161
|
+
const response = await api("/api/themes", { tabId: tabContext.tabId });
|
|
10162
|
+
if (tabContext.tabId && !isCurrentTabContext(tabContext)) return response.data;
|
|
10163
|
+
installThemeCatalog(response.data || {});
|
|
10164
|
+
return response.data || {};
|
|
10165
|
+
}
|
|
10166
|
+
|
|
10167
|
+
async function openThemeCustomizer() {
|
|
10168
|
+
if (!elements.themeCustomizerDialog || !availableThemes.length) return;
|
|
10169
|
+
const generation = ++themeCustomizerGeneration;
|
|
10170
|
+
const tabContext = activeTabContext();
|
|
10171
|
+
const openingTheme = availableThemes.find((theme) => theme.name === currentThemeName) || availableThemes[0];
|
|
10172
|
+
const opening = {
|
|
10173
|
+
theme: cloneThemeDraft(openingTheme),
|
|
10174
|
+
background: customBackground ? cloneThemeDraft(customBackground) : null,
|
|
10175
|
+
};
|
|
10176
|
+
themeCustomizerState = { generation, tabContext, opening, validTheme: null, draftValid: false, initialTheme: null, overwrite: null, saving: false, restored: false };
|
|
10177
|
+
setThemeCustomizerStatus("Loading project and global theme destinations…");
|
|
10178
|
+
try {
|
|
10179
|
+
await refreshThemeCatalog(tabContext);
|
|
10180
|
+
} catch (error) {
|
|
10181
|
+
if (themeCustomizerState?.generation === generation) setThemeCustomizerStatus(`Theme catalog refresh failed: ${error.message || String(error)}`, "warn");
|
|
10182
|
+
}
|
|
10183
|
+
if (themeCustomizerState?.generation !== generation) return;
|
|
10184
|
+
const source = availableThemes.find((theme) => theme.name === openingTheme.name) || openingTheme;
|
|
10185
|
+
const draft = canonicalizeTheme(themeDraftFromCatalog(source, themeCustomizerNameForSource(source)), { allowWebuiExport: true });
|
|
10186
|
+
themeCustomizerState.source = source;
|
|
10187
|
+
themeCustomizerState.initialTheme = cloneThemeDraft(draft);
|
|
10188
|
+
const projectTrusted = themeCatalogScopes.project?.trusted === true;
|
|
10189
|
+
elements.themeCustomizerProjectOption.disabled = !projectTrusted;
|
|
10190
|
+
elements.themeCustomizerScope.value = source.custom ? source.scope : projectTrusted ? "project" : "global";
|
|
10191
|
+
elements.themeCustomizerScopeHint.textContent = projectTrusted
|
|
10192
|
+
? "Project saves use this active trusted tab’s .pi/themes directory; global saves use Pi’s agent themes directory."
|
|
10193
|
+
: "This active project is not saved as trusted in Pi, so only Global themes is available.";
|
|
10194
|
+
elements.themeCustomizerSourceBadge.textContent = `${themeScopeLabel(source.scope)} source`;
|
|
10195
|
+
elements.themeCustomizerSourceBadge.className = `theme-scope-badge ${source.scope || "bundled"}`;
|
|
10196
|
+
elements.themeCustomizerName.value = draft.name;
|
|
10197
|
+
renderThemeCustomizerVisualFields(draft);
|
|
10198
|
+
renderThemeCustomizerOptionalFields(draft);
|
|
10199
|
+
elements.themeCustomizerJson.value = serializeTheme(draft, { allowWebuiExport: true });
|
|
10200
|
+
themeCustomizerState.validTheme = draft;
|
|
10201
|
+
themeCustomizerState.draftValid = true;
|
|
10202
|
+
invalidateThemeCustomizerOverwrite();
|
|
10203
|
+
applyTheme(draft, { persist: false });
|
|
10204
|
+
setThemeCustomizerStatus("Valid draft previewed. Nothing has been written to browser storage or disk.", "success");
|
|
10205
|
+
updateThemeCustomizerActions();
|
|
10206
|
+
if (!elements.themeCustomizerDialog.open) elements.themeCustomizerDialog.showModal();
|
|
10207
|
+
queueMicrotask(() => elements.themeCustomizerName?.focus({ preventScroll: true }));
|
|
10208
|
+
}
|
|
10209
|
+
|
|
10210
|
+
function showThemeCustomizerOverwrite(details) {
|
|
10211
|
+
const state = themeCustomizerState;
|
|
10212
|
+
if (!state) return;
|
|
10213
|
+
const scope = details?.scope;
|
|
10214
|
+
const fileName = details?.fileName;
|
|
10215
|
+
if (scope !== elements.themeCustomizerScope.value || fileName !== `${elements.themeCustomizerName.value.trim()}.json` || !Number.isFinite(details?.mtimeMs)) {
|
|
10216
|
+
setThemeCustomizerStatus("The server returned conflict details for a different target. Refresh the catalog and try again.", "error");
|
|
10217
|
+
return;
|
|
10218
|
+
}
|
|
10219
|
+
state.overwrite = { signature: themeCustomizerDraftSignature(state), scope, fileName, mtimeMs: details.mtimeMs };
|
|
10220
|
+
elements.themeCustomizerOverwriteMessage.textContent = `${themeScopeLabel(scope)} themes / ${fileName} already exists. Replace only this file with the current unchanged draft?`;
|
|
10221
|
+
elements.themeCustomizerOverwrite.hidden = false;
|
|
10222
|
+
setThemeCustomizerStatus("Review the exact target, then confirm replacement. Any draft, name, or destination change cancels this confirmation.", "warn");
|
|
10223
|
+
updateThemeCustomizerActions();
|
|
10224
|
+
elements.themeCustomizerOverwriteButton.focus();
|
|
10225
|
+
}
|
|
10226
|
+
|
|
10227
|
+
async function saveThemeCustomizer({ overwrite = false } = {}) {
|
|
10228
|
+
const state = themeCustomizerState;
|
|
10229
|
+
if (!state?.draftValid || !state.validTheme || state.saving) return;
|
|
10230
|
+
if (!isCurrentTabContext(state.tabContext)) {
|
|
10231
|
+
setThemeCustomizerStatus("The active tab changed. Cancel and reopen Customize so the project destination is bound to the intended tab.", "warn");
|
|
10232
|
+
return;
|
|
10233
|
+
}
|
|
10234
|
+
const confirmation = state.overwrite;
|
|
10235
|
+
if (overwrite && (!confirmation || confirmation.signature !== themeCustomizerDraftSignature(state))) {
|
|
10236
|
+
invalidateThemeCustomizerOverwrite();
|
|
10237
|
+
setThemeCustomizerStatus("The overwrite confirmation no longer matches this target and draft. Save again to request a fresh confirmation.", "warn");
|
|
10238
|
+
updateThemeCustomizerActions();
|
|
10239
|
+
return;
|
|
10240
|
+
}
|
|
10241
|
+
const name = elements.themeCustomizerName.value.trim();
|
|
10242
|
+
const scope = elements.themeCustomizerScope.value;
|
|
10243
|
+
state.saving = true;
|
|
10244
|
+
updateThemeCustomizerActions();
|
|
10245
|
+
try {
|
|
10246
|
+
const response = await api("/api/themes/custom", {
|
|
10247
|
+
method: "POST",
|
|
10248
|
+
tabId: state.tabContext.tabId,
|
|
10249
|
+
body: {
|
|
10250
|
+
scope,
|
|
10251
|
+
fileName: `${name}.json`,
|
|
10252
|
+
theme: state.validTheme,
|
|
10253
|
+
overwrite,
|
|
10254
|
+
expectedMtimeMs: overwrite ? confirmation.mtimeMs : null,
|
|
10255
|
+
},
|
|
10256
|
+
});
|
|
10257
|
+
if (themeCustomizerState?.generation !== state.generation) return;
|
|
10258
|
+
invalidateThemeCustomizerOverwrite();
|
|
10259
|
+
await refreshThemeCatalog(state.tabContext);
|
|
10260
|
+
if (themeCustomizerState?.generation !== state.generation) return;
|
|
10261
|
+
applyTheme(state.validTheme, { persist: false });
|
|
10262
|
+
elements.themeCustomizerSourceBadge.textContent = `${themeScopeLabel(scope)} saved`;
|
|
10263
|
+
elements.themeCustomizerSourceBadge.className = `theme-scope-badge ${scope}`;
|
|
10264
|
+
setThemeCustomizerStatus(`Saved ${response.data?.fileName || `${name}.json`} to ${themeScopeLabel(scope)} themes. The WebUI catalog is refreshed. In Pi TUI, run /reload or restart, then choose it with /theme. No Pi or browser theme setting was changed.`, "success");
|
|
10265
|
+
} catch (error) {
|
|
10266
|
+
if (themeCustomizerState?.generation !== state.generation) return;
|
|
10267
|
+
const code = error.data?.code;
|
|
10268
|
+
if (code === "THEME_EXISTS") showThemeCustomizerOverwrite(error.data?.details);
|
|
10269
|
+
else if (code === "THEME_CHANGED") {
|
|
10270
|
+
invalidateThemeCustomizerOverwrite();
|
|
10271
|
+
setThemeCustomizerStatus("The target changed after confirmation and was not overwritten. Review the current file, then save again for a fresh target-bound confirmation.", "error");
|
|
10272
|
+
} else {
|
|
10273
|
+
const issues = error.data?.details?.issues;
|
|
10274
|
+
setThemeCustomizerStatus(Array.isArray(issues) && issues.length
|
|
10275
|
+
? issues.map(({ path, message }) => `${path}: ${message}`).join(" · ")
|
|
10276
|
+
: error.message || String(error), "error");
|
|
10277
|
+
}
|
|
10278
|
+
} finally {
|
|
10279
|
+
if (themeCustomizerState?.generation === state.generation) {
|
|
10280
|
+
state.saving = false;
|
|
10281
|
+
updateThemeCustomizerActions();
|
|
10282
|
+
}
|
|
10283
|
+
}
|
|
10284
|
+
}
|
|
10285
|
+
|
|
10286
|
+
function resetThemeCustomizerDraft() {
|
|
10287
|
+
const state = themeCustomizerState;
|
|
10288
|
+
if (!state?.initialTheme) return;
|
|
10289
|
+
const reset = cloneThemeDraft(state.initialTheme);
|
|
10290
|
+
elements.themeCustomizerName.value = reset.name;
|
|
10291
|
+
renderThemeCustomizerVisualFields(reset);
|
|
10292
|
+
renderThemeCustomizerOptionalFields(reset);
|
|
10293
|
+
acceptThemeCustomizerDraft(reset, { syncJson: true });
|
|
10294
|
+
}
|
|
10295
|
+
|
|
9695
10296
|
function renderThemeSelect({ unavailableLabel = "Theme bundle unavailable" } = {}) {
|
|
9696
10297
|
if (!elements.themeSelect) return;
|
|
9697
10298
|
elements.themeSelect.replaceChildren();
|
|
@@ -9700,6 +10301,7 @@ function renderThemeSelect({ unavailableLabel = "Theme bundle unavailable" } = {
|
|
|
9700
10301
|
option.value = "";
|
|
9701
10302
|
elements.themeSelect.append(option);
|
|
9702
10303
|
elements.themeSelect.disabled = true;
|
|
10304
|
+
if (elements.themeCustomizeButton) elements.themeCustomizeButton.disabled = true;
|
|
9703
10305
|
return;
|
|
9704
10306
|
}
|
|
9705
10307
|
if (!availableThemes.length) {
|
|
@@ -9707,11 +10309,14 @@ function renderThemeSelect({ unavailableLabel = "Theme bundle unavailable" } = {
|
|
|
9707
10309
|
option.value = "";
|
|
9708
10310
|
elements.themeSelect.append(option);
|
|
9709
10311
|
elements.themeSelect.disabled = true;
|
|
10312
|
+
if (elements.themeCustomizeButton) elements.themeCustomizeButton.disabled = true;
|
|
9710
10313
|
return;
|
|
9711
10314
|
}
|
|
9712
10315
|
elements.themeSelect.disabled = false;
|
|
10316
|
+
if (elements.themeCustomizeButton) elements.themeCustomizeButton.disabled = false;
|
|
9713
10317
|
for (const theme of availableThemes) {
|
|
9714
|
-
const
|
|
10318
|
+
const suffix = theme.custom ? ` · ${themeScopeLabel(theme.scope)}` : "";
|
|
10319
|
+
const option = make("option", undefined, `${theme.label || displayThemeName(theme.name) || theme.name}${suffix}`);
|
|
9715
10320
|
option.value = theme.name;
|
|
9716
10321
|
elements.themeSelect.append(option);
|
|
9717
10322
|
}
|
|
@@ -9746,6 +10351,7 @@ async function initializeThemes() {
|
|
|
9746
10351
|
throw error;
|
|
9747
10352
|
}
|
|
9748
10353
|
availableThemes = Array.isArray(response.data?.themes) ? response.data.themes : [];
|
|
10354
|
+
themeCatalogScopes = response.data?.scopes && typeof response.data.scopes === "object" ? response.data.scopes : themeCatalogScopes;
|
|
9749
10355
|
optionalFeatureAvailability.themeBundle = availableThemes.length > 0;
|
|
9750
10356
|
renderOptionalFeatureControls();
|
|
9751
10357
|
themeSchemeMode = storedThemeMode() ?? seedThemeSchemeFromStoredTheme();
|
|
@@ -9764,6 +10370,53 @@ function activeTabContext(tabId = activeTabId) {
|
|
|
9764
10370
|
return { tabId: tabId || null, generation: activeTabGeneration };
|
|
9765
10371
|
}
|
|
9766
10372
|
|
|
10373
|
+
function transcriptStreamOwner(tabId = activeTabId, generation = activeTabGeneration) {
|
|
10374
|
+
return `${tabId || ""}:${generation}`;
|
|
10375
|
+
}
|
|
10376
|
+
|
|
10377
|
+
function unknownTranscriptEvidenceText(event) {
|
|
10378
|
+
const update = event?.assistantMessageEvent || {};
|
|
10379
|
+
const value = update.delta ?? update.content ?? update.text ?? update.thinking ?? "";
|
|
10380
|
+
if (typeof value === "string") return value.slice(0, UNKNOWN_TRANSCRIPT_EVIDENCE_TEXT_LIMIT);
|
|
10381
|
+
try {
|
|
10382
|
+
return JSON.stringify(value).slice(0, UNKNOWN_TRANSCRIPT_EVIDENCE_TEXT_LIMIT);
|
|
10383
|
+
} catch {
|
|
10384
|
+
return "[unserializable transcript evidence]";
|
|
10385
|
+
}
|
|
10386
|
+
}
|
|
10387
|
+
|
|
10388
|
+
function preserveUnknownTranscriptEvidence(event, classification, owner) {
|
|
10389
|
+
const update = event?.assistantMessageEvent || {};
|
|
10390
|
+
const evidence = {
|
|
10391
|
+
owner: String(owner || ""),
|
|
10392
|
+
subtype: classification?.subtype || "(missing)",
|
|
10393
|
+
fields: Object.keys(update).slice(0, 16),
|
|
10394
|
+
text: unknownTranscriptEvidenceText(event),
|
|
10395
|
+
receivedAt: Date.now(),
|
|
10396
|
+
};
|
|
10397
|
+
appendBoundedStreamDiagnostic(unknownTranscriptEvidence, evidence, UNKNOWN_TRANSCRIPT_EVIDENCE_LIMIT);
|
|
10398
|
+
if (owner) {
|
|
10399
|
+
unknownTranscriptOwnersPendingReconcile.add(owner);
|
|
10400
|
+
while (unknownTranscriptOwnersPendingReconcile.size > UNKNOWN_TRANSCRIPT_EVIDENCE_LIMIT) {
|
|
10401
|
+
const oldest = unknownTranscriptOwnersPendingReconcile.values().next().value;
|
|
10402
|
+
if (oldest === undefined) break;
|
|
10403
|
+
unknownTranscriptOwnersPendingReconcile.delete(oldest);
|
|
10404
|
+
}
|
|
10405
|
+
}
|
|
10406
|
+
if (streamIsolationDebugLedger) {
|
|
10407
|
+
appendBoundedStreamDiagnostic(streamIsolationDebugLedger.unknownEvidence, evidence, UNKNOWN_TRANSCRIPT_EVIDENCE_LIMIT);
|
|
10408
|
+
}
|
|
10409
|
+
}
|
|
10410
|
+
|
|
10411
|
+
function reconcileUnknownTranscriptEvidenceAtBarrier(event) {
|
|
10412
|
+
const tabContext = activeTabContext(event?.tabId || activeTabId);
|
|
10413
|
+
const owner = transcriptStreamOwner(tabContext.tabId, tabContext.generation);
|
|
10414
|
+
if (!unknownTranscriptOwnersPendingReconcile.delete(owner)) return false;
|
|
10415
|
+
if (!isCurrentTabContext(tabContext)) return false;
|
|
10416
|
+
scheduleSemanticReconcile({ messages: true }, tabContext);
|
|
10417
|
+
return true;
|
|
10418
|
+
}
|
|
10419
|
+
|
|
9767
10420
|
function setActiveTabId(tabId, { remember = false } = {}) {
|
|
9768
10421
|
const nextTabId = tabId || null;
|
|
9769
10422
|
if (nextTabId !== activeTabId) {
|
|
@@ -12914,7 +13567,6 @@ function clearWidgetsForTab(tabId = activeTabId) {
|
|
|
12914
13567
|
|
|
12915
13568
|
function resetActiveTabUi() {
|
|
12916
13569
|
clearRefreshTimers();
|
|
12917
|
-
clearLiveToolRenderQueue();
|
|
12918
13570
|
eventSource?.close();
|
|
12919
13571
|
eventSource = null;
|
|
12920
13572
|
currentState = null;
|
|
@@ -12962,10 +13614,11 @@ function resetActiveTabUi() {
|
|
|
12962
13614
|
renderAppRunnerControls();
|
|
12963
13615
|
renderWidgets();
|
|
12964
13616
|
renderGitWorkflow();
|
|
12965
|
-
|
|
12966
|
-
|
|
12967
|
-
|
|
12968
|
-
|
|
13617
|
+
// renderMessages() is transcript-only, so tab-level chrome is rendered here
|
|
13618
|
+
// explicitly whether or not a cached transcript was restored.
|
|
13619
|
+
restoreCachedMessagesForActiveTab();
|
|
13620
|
+
renderFooter();
|
|
13621
|
+
renderFeedbackTray();
|
|
12969
13622
|
}
|
|
12970
13623
|
|
|
12971
13624
|
function tabGroupStatusRank(state) {
|
|
@@ -13887,7 +14540,7 @@ function renderTerminalTab(tab) {
|
|
|
13887
14540
|
applyStyledTooltip(button, terminalTabTooltip(tab), { ariaLabel: false, align: "start", description: true, variant: "workspace", targetKey: `terminal-tab:${tab.id}:switch` });
|
|
13888
14541
|
appendTerminalTabContent(button, { title: tab.title, indicator, meta: terminalTabMeta(tab, indicator), appRunnerRun, conversationModeActive, workflowModeActive, workflowCount });
|
|
13889
14542
|
button.addEventListener("click", () => switchTab(tab.id));
|
|
13890
|
-
wrapper.append(button);
|
|
14543
|
+
wrapper.append(button, createTerminalTabActions(tab));
|
|
13891
14544
|
|
|
13892
14545
|
if (tabs.length > 1) {
|
|
13893
14546
|
const close = make("button", "terminal-tab-close", "×");
|
|
@@ -13929,7 +14582,7 @@ function renderTerminalTabGroupItem(tab, group) {
|
|
|
13929
14582
|
event.stopPropagation();
|
|
13930
14583
|
switchTab(tab.id);
|
|
13931
14584
|
});
|
|
13932
|
-
item.append(button);
|
|
14585
|
+
item.append(button, createTerminalTabActions(tab));
|
|
13933
14586
|
|
|
13934
14587
|
if (tabs.length > 1) {
|
|
13935
14588
|
const close = make("button", "terminal-tab-close terminal-tab-group-item-close", "×");
|
|
@@ -14055,7 +14708,6 @@ function setNewTabMenuOpen(open) {
|
|
|
14055
14708
|
|
|
14056
14709
|
function initializeTerminalHeaderTooltips() {
|
|
14057
14710
|
applyStyledTooltip(elements.newTabButton, "Start a separate isolated Pi terminal", { ariaLabel: "Start a separate isolated Pi terminal" });
|
|
14058
|
-
applyStyledTooltip(elements.splitTabButton, "Split the active terminal to the right", { ariaLabel: "Split the active terminal to the right" });
|
|
14059
14711
|
applyStyledTooltip(elements.closeAllTabsButton, "Close all terminal tabs", { ariaLabel: "Close all terminal tabs" });
|
|
14060
14712
|
}
|
|
14061
14713
|
|
|
@@ -14100,6 +14752,8 @@ function terminalTabControlKey(node) {
|
|
|
14100
14752
|
const tabId = node?.closest?.("[data-tab-id]")?.dataset?.tabId;
|
|
14101
14753
|
if (tabId) {
|
|
14102
14754
|
if (node.classList.contains("terminal-tab-close")) return `terminal-tab:${tabId}:close`;
|
|
14755
|
+
if (node.classList.contains("terminal-tab-split-button")) return `terminal-tab:${tabId}:split`;
|
|
14756
|
+
if (node.classList.contains("terminal-tab-summary-button")) return `terminal-tab:${tabId}:summary`;
|
|
14103
14757
|
if (node.classList.contains("terminal-tab-button")) return `terminal-tab:${tabId}:switch`;
|
|
14104
14758
|
}
|
|
14105
14759
|
const groupKey = node?.closest?.("[data-group-key]")?.dataset?.groupKey;
|
|
@@ -14168,6 +14822,18 @@ function renderTabs() {
|
|
|
14168
14822
|
if (mobilePhoneExperienceInstalled && isMobileShellV2Active()) renderMobilePhoneExperience();
|
|
14169
14823
|
}
|
|
14170
14824
|
|
|
14825
|
+
function prefetchInactiveTabCommandCatalogs() {
|
|
14826
|
+
for (const tab of tabs) {
|
|
14827
|
+
if (!tab?.id || tab.id === activeTabId || commandCatalogsByTab.has(tab.id) || commandCatalogRefreshesByTab.has(tab.id)) continue;
|
|
14828
|
+
const refresh = refreshCommands(activeTabContext(tab.id))
|
|
14829
|
+
.catch(() => {})
|
|
14830
|
+
.finally(() => {
|
|
14831
|
+
if (commandCatalogRefreshesByTab.get(tab.id) === refresh) commandCatalogRefreshesByTab.delete(tab.id);
|
|
14832
|
+
});
|
|
14833
|
+
commandCatalogRefreshesByTab.set(tab.id, refresh);
|
|
14834
|
+
}
|
|
14835
|
+
}
|
|
14836
|
+
|
|
14171
14837
|
async function refreshTabs({ selectStored = false } = {}) {
|
|
14172
14838
|
const previousTabs = tabs;
|
|
14173
14839
|
const response = await api("/api/tabs", { scoped: false });
|
|
@@ -14192,6 +14858,7 @@ async function refreshTabs({ selectStored = false } = {}) {
|
|
|
14192
14858
|
}
|
|
14193
14859
|
renderSessionSkillTags(activeTabId);
|
|
14194
14860
|
renderTabs();
|
|
14861
|
+
prefetchInactiveTabCommandCatalogs();
|
|
14195
14862
|
return tabs;
|
|
14196
14863
|
}
|
|
14197
14864
|
|
|
@@ -14201,7 +14868,12 @@ async function switchTab(tabId) {
|
|
|
14201
14868
|
if (activeSubagentTerminalId) deactivateSubagentTerminalView({ focusParent: true });
|
|
14202
14869
|
return;
|
|
14203
14870
|
}
|
|
14871
|
+
if (themeCustomizerState?.saving) {
|
|
14872
|
+
setThemeCustomizerStatus("Wait for the theme save to finish before switching tabs.", "warn");
|
|
14873
|
+
return;
|
|
14874
|
+
}
|
|
14204
14875
|
if (activeSubagentTerminalId) deactivateSubagentTerminalView({ render: false });
|
|
14876
|
+
if (themeCustomizerState) closeThemeCustomizer({ restore: true });
|
|
14205
14877
|
clearOpenTerminalTabGroup(null, { force: true });
|
|
14206
14878
|
setFollowUpQueueOpen(false);
|
|
14207
14879
|
setFollowUpQueueStatus("");
|
|
@@ -14224,6 +14896,7 @@ async function switchTab(tabId) {
|
|
|
14224
14896
|
connectEvents(tabContext);
|
|
14225
14897
|
await refreshAll(tabContext);
|
|
14226
14898
|
if (isCurrentTabContext(tabContext)) markTabOutputSeen();
|
|
14899
|
+
await refreshThemeCatalog(tabContext).catch((error) => addEvent(`Custom theme catalog refresh failed: ${error.message || String(error)}`, "warn"));
|
|
14227
14900
|
if (!subagentLaunchSlotDraftIsDirty()) {
|
|
14228
14901
|
loadSubagentLaunchSlotConfig({ tabId }).catch(() => {});
|
|
14229
14902
|
} else {
|
|
@@ -14246,19 +14919,28 @@ function terminalSplitFrameUrl(tabId) {
|
|
|
14246
14919
|
return `${url.pathname}${url.search}`;
|
|
14247
14920
|
}
|
|
14248
14921
|
|
|
14922
|
+
function updateTerminalSplitControls(canShowSplit, splitTab = terminalSplitTab()) {
|
|
14923
|
+
elements.tabBar?.querySelectorAll(".terminal-tab-split-button").forEach((button) => {
|
|
14924
|
+
const tabId = button.closest("[data-tab-id]")?.dataset?.tabId || "";
|
|
14925
|
+
const tab = tabs.find((candidate) => candidate.id === tabId);
|
|
14926
|
+
const isOpenSplit = canShowSplit && tabId === splitTab?.id;
|
|
14927
|
+
button.disabled = embeddedSplitMode || isSidePanelOverlayView() || !tab;
|
|
14928
|
+
button.setAttribute("aria-pressed", isOpenSplit ? "true" : "false");
|
|
14929
|
+
button.dataset.splitState = isOpenSplit ? "unsplit" : "split";
|
|
14930
|
+
const label = isOpenSplit
|
|
14931
|
+
? `Close split view for ${tab?.title || "Pi terminal"}`
|
|
14932
|
+
: `Split ${tab?.title || "Pi terminal"} to the right`;
|
|
14933
|
+
applyStyledTooltip(button, label, { ariaLabel: label, targetKey: tabId ? `terminal-tab:${tabId}:split` : "" });
|
|
14934
|
+
});
|
|
14935
|
+
}
|
|
14936
|
+
|
|
14249
14937
|
function updateTerminalSplitUi() {
|
|
14250
14938
|
const tab = terminalSplitTab();
|
|
14251
14939
|
const canShowSplit = !!tab && !embeddedSplitMode && !isSidePanelOverlayView();
|
|
14252
14940
|
document.body.classList.toggle("terminal-split-open", canShowSplit);
|
|
14253
14941
|
if (elements.terminalSplitShell) elements.terminalSplitShell.hidden = !canShowSplit;
|
|
14254
14942
|
requestAnimationFrame(syncResizablePanelWidthsForViewport);
|
|
14255
|
-
|
|
14256
|
-
elements.splitTabButton.disabled = embeddedSplitMode || isSidePanelOverlayView() || !activeTab();
|
|
14257
|
-
elements.splitTabButton.setAttribute("aria-pressed", canShowSplit ? "true" : "false");
|
|
14258
|
-
elements.splitTabButton.dataset.splitState = canShowSplit ? "unsplit" : "split";
|
|
14259
|
-
const label = canShowSplit ? `Close split view for ${tab.title}` : "Split the active terminal to the right";
|
|
14260
|
-
applyStyledTooltip(elements.splitTabButton, label, { ariaLabel: label });
|
|
14261
|
-
}
|
|
14943
|
+
updateTerminalSplitControls(canShowSplit, tab);
|
|
14262
14944
|
if (!canShowSplit) return;
|
|
14263
14945
|
if (elements.terminalSplitTitle) elements.terminalSplitTitle.textContent = tab.title || "Split terminal";
|
|
14264
14946
|
if (elements.terminalSplitMeta) elements.terminalSplitMeta.textContent = [tab.running ? `pid ${tab.pid || "starting"}` : "stopped", normalizeDisplayPath(tab.cwd || "")].filter(Boolean).join(" · ");
|
|
@@ -14291,22 +14973,23 @@ function reconcileTerminalSplitState() {
|
|
|
14291
14973
|
updateTerminalSplitUi();
|
|
14292
14974
|
}
|
|
14293
14975
|
|
|
14294
|
-
async function
|
|
14976
|
+
async function splitTerminalTab(tabId, { triggerButton = null } = {}) {
|
|
14295
14977
|
if (embeddedSplitMode) return;
|
|
14296
|
-
if (splitTabId) {
|
|
14978
|
+
if (splitTabId === tabId) {
|
|
14297
14979
|
closeTerminalSplitView();
|
|
14298
14980
|
return;
|
|
14299
14981
|
}
|
|
14300
|
-
const sourceTab =
|
|
14301
|
-
|
|
14982
|
+
const sourceTab = tabs.find((tab) => tab.id === tabId);
|
|
14983
|
+
if (!sourceTab) return;
|
|
14984
|
+
if (splitTabId) closeTerminalSplitView();
|
|
14985
|
+
let resolvedCwd = sourceTab.cwd || latestWorkspace?.cwd || currentDirectoryForNewTab();
|
|
14302
14986
|
setMobileTabsExpanded(false);
|
|
14303
14987
|
setNewTabMenuOpen(false);
|
|
14304
14988
|
if (!resolvedCwd) {
|
|
14305
|
-
resolvedCwd = await pickCwd(sourceTab
|
|
14989
|
+
resolvedCwd = await pickCwd(sourceTab, "", { title: "Choose CWD for split terminal" });
|
|
14306
14990
|
if (!resolvedCwd) return;
|
|
14307
14991
|
}
|
|
14308
|
-
|
|
14309
|
-
for (const button of disabledButtons) button.disabled = true;
|
|
14992
|
+
if (triggerButton) triggerButton.disabled = true;
|
|
14310
14993
|
try {
|
|
14311
14994
|
const response = await api("/api/tabs", { method: "POST", body: { cwd: resolvedCwd }, scoped: false });
|
|
14312
14995
|
tabs = response.data?.tabs || tabs;
|
|
@@ -14315,12 +14998,12 @@ async function splitActiveTerminalTab({ triggerButton = elements.splitTabButton
|
|
|
14315
14998
|
if (tab?.id) {
|
|
14316
14999
|
setTerminalSplitTab(tab.id);
|
|
14317
15000
|
renderTabs();
|
|
14318
|
-
addEvent(`split ${sourceTab
|
|
15001
|
+
addEvent(`split ${sourceTab.title || "terminal"} into independent ${tab.title}`, "info");
|
|
14319
15002
|
}
|
|
14320
15003
|
} catch (error) {
|
|
14321
15004
|
addEvent(error.message, "error");
|
|
14322
15005
|
} finally {
|
|
14323
|
-
|
|
15006
|
+
if (triggerButton) triggerButton.disabled = false;
|
|
14324
15007
|
updateTerminalSplitUi();
|
|
14325
15008
|
}
|
|
14326
15009
|
}
|
|
@@ -14504,6 +15187,7 @@ async function initializeTabs() {
|
|
|
14504
15187
|
return [];
|
|
14505
15188
|
});
|
|
14506
15189
|
if (!saved.length) await createFirstTerminalTabFromChosenDirectory();
|
|
15190
|
+
await refreshThemeCatalog(activeTabContext()).catch((error) => addEvent(`Custom theme catalog refresh failed: ${error.message || String(error)}`, "warn"));
|
|
14507
15191
|
return;
|
|
14508
15192
|
}
|
|
14509
15193
|
focusPromptInput({ defer: true });
|
|
@@ -14515,6 +15199,7 @@ async function initializeTabs() {
|
|
|
14515
15199
|
if (!subagentLaunchSlotDraftIsDirty() || subagentLaunchSlotConfigTabId !== activeTabId) {
|
|
14516
15200
|
loadSubagentLaunchSlotConfig().catch(() => {});
|
|
14517
15201
|
}
|
|
15202
|
+
await refreshThemeCatalog(tabContext).catch((error) => addEvent(`Custom theme catalog refresh failed: ${error.message || String(error)}`, "warn"));
|
|
14518
15203
|
}
|
|
14519
15204
|
}
|
|
14520
15205
|
|
|
@@ -15629,7 +16314,7 @@ const GIT_FOOTER_TOOLTIP_COPY = {
|
|
|
15629
16314
|
cwd: "Active working directory for this Web UI tab.",
|
|
15630
16315
|
git: "Current Git branch. detached means HEAD is not on a branch; no repo means the cwd is outside a Git work tree.",
|
|
15631
16316
|
"git-state": "Active Git operation or detached state. Finish or abort rebase/merge/cherry-pick/revert/bisect before normal commits.",
|
|
15632
|
-
sync: "Remote tracking divergence. ↑ means local commits
|
|
16317
|
+
sync: "Remote tracking divergence. ↑ means local commits to push; ↓ means remote commits to pull. Incoming-only Sync pulls from origin; outgoing Sync uses the confirmed push flow, including the guarded force-with-lease fallback when needed.",
|
|
15633
16318
|
changes: "Working tree and fetched remote summary. 🟢 staged, ✏️ modified unstaged, ➕ untracked, ⚠️ conflicted; ⬇️ means fetched remote commits to pull; 🔄/✓/⚠️ fetch shows the tab git fetch state; ✅ means no changes.",
|
|
15634
16319
|
"git-extra": "Extra Git signals. 📦 stash, 🧩 dirty submodules, 🌳 worktrees, 🏷️ tag at HEAD, 🕒 last commit age, 🔓 signing mismatch.",
|
|
15635
16320
|
worktree: "Git worktree checkout for this tab. Use branch worktrees to work on branches in parallel without switching this checkout.",
|
|
@@ -15706,7 +16391,7 @@ const GIT_FOOTER_VISIBILITY_LABELS = Object.freeze({
|
|
|
15706
16391
|
"webui-context-auto-compaction": "Auto-compaction action",
|
|
15707
16392
|
"webui-branch-picker": "Branch/worktree picker",
|
|
15708
16393
|
"webui-git-init": "Git init affordance",
|
|
15709
|
-
"webui-sync-push": "Sync push action",
|
|
16394
|
+
"webui-sync-push": "Sync pull/push action",
|
|
15710
16395
|
"webui-changes-modal": "Changes modal",
|
|
15711
16396
|
"webui-git-tools-modal": "Git tools modal",
|
|
15712
16397
|
"webui-model-picker": "Model picker",
|
|
@@ -15743,7 +16428,7 @@ const GIT_FOOTER_VISIBILITY_HINTS = Object.freeze({
|
|
|
15743
16428
|
"webui-context-auto-compaction": "Click action on context chips for auto-compaction.",
|
|
15744
16429
|
"webui-branch-picker": "Click action on the git branch/worktree chips.",
|
|
15745
16430
|
"webui-git-init": "Git initialization affordance when a tab has no repository.",
|
|
15746
|
-
"webui-sync-push": "
|
|
16431
|
+
"webui-sync-push": "Compatibility visibility key for incoming pull and outgoing push actions on Sync chips.",
|
|
15747
16432
|
"webui-changes-modal": "Click action opening the changes/conflicts modal.",
|
|
15748
16433
|
"webui-git-tools-modal": "Click action opening extra git tools.",
|
|
15749
16434
|
"webui-model-picker": "Click action opening the footer model picker.",
|
|
@@ -16318,13 +17003,22 @@ function renderGitFooterPayloadMetric(chip, payload) {
|
|
|
16318
17003
|
return node;
|
|
16319
17004
|
}
|
|
16320
17005
|
|
|
16321
|
-
function
|
|
16322
|
-
const
|
|
16323
|
-
|
|
17006
|
+
function gitFooterSyncCounts(value) {
|
|
17007
|
+
const text = String(value || "");
|
|
17008
|
+
const aheadMatch = text.match(/[↑⇡]\s*(\d+)/u);
|
|
17009
|
+
const behindMatch = text.match(/[↓⇣]\s*(\d+)/u);
|
|
17010
|
+
return {
|
|
17011
|
+
ahead: aheadMatch ? Number.parseInt(aheadMatch[1] || "0", 10) || 0 : 0,
|
|
17012
|
+
behind: behindMatch ? Number.parseInt(behindMatch[1] || "0", 10) || 0 : 0,
|
|
17013
|
+
};
|
|
16324
17014
|
}
|
|
16325
17015
|
|
|
16326
|
-
function
|
|
16327
|
-
|
|
17016
|
+
function gitFooterSyncAction(chip) {
|
|
17017
|
+
if (chip?.key !== "sync") return "";
|
|
17018
|
+
const { ahead, behind } = gitFooterSyncCounts(chip.value);
|
|
17019
|
+
if (behind > 0 && ahead === 0) return "pull";
|
|
17020
|
+
if (ahead > 0) return "push";
|
|
17021
|
+
return "";
|
|
16328
17022
|
}
|
|
16329
17023
|
|
|
16330
17024
|
function gitFooterCurrentBranch() {
|
|
@@ -16333,9 +17027,31 @@ function gitFooterCurrentBranch() {
|
|
|
16333
17027
|
return value && value !== "no repo" ? cleanFooterPayloadText(gitChip.value, "") : "";
|
|
16334
17028
|
}
|
|
16335
17029
|
|
|
17030
|
+
async function pullGitFooterSync(tabId = activeTabId) {
|
|
17031
|
+
if (!tabId || gitFooterSyncInFlightByTab.has(tabId)) return;
|
|
17032
|
+
const tabContext = activeTabContext(tabId);
|
|
17033
|
+
hideFooterTooltip();
|
|
17034
|
+
gitFooterSyncInFlightByTab.add(tabId);
|
|
17035
|
+
if (isCurrentTabContext(tabContext)) renderFooter();
|
|
17036
|
+
try {
|
|
17037
|
+
const response = await api("/api/git-changes/pull", { method: "POST", body: { remote: "origin" }, tabId });
|
|
17038
|
+
if (!response.ok) {
|
|
17039
|
+
const detail = [response.error, response.hint, formatGitCommandResult(response.data)].filter(Boolean).join("\n\n").trim();
|
|
17040
|
+
throw new Error(detail || "git pull from origin failed");
|
|
17041
|
+
}
|
|
17042
|
+
addEvent("Pulled Git changes from origin.", "success");
|
|
17043
|
+
requestGitFooterWebuiPayload(tabContext, { force: true });
|
|
17044
|
+
} catch (error) {
|
|
17045
|
+
addEvent(error.message || String(error), "error");
|
|
17046
|
+
} finally {
|
|
17047
|
+
gitFooterSyncInFlightByTab.delete(tabId);
|
|
17048
|
+
if (isCurrentTabContext(tabContext)) renderFooter();
|
|
17049
|
+
}
|
|
17050
|
+
}
|
|
17051
|
+
|
|
16336
17052
|
async function pushGitFooterSync(tabId = activeTabId, syncValue = "") {
|
|
16337
|
-
if (!tabId ||
|
|
16338
|
-
const outgoing =
|
|
17053
|
+
if (!tabId || gitFooterSyncInFlightByTab.has(tabId)) return;
|
|
17054
|
+
const outgoing = gitFooterSyncCounts(syncValue).ahead;
|
|
16339
17055
|
if (outgoing <= 0) return;
|
|
16340
17056
|
const tabContext = activeTabContext(tabId);
|
|
16341
17057
|
const tab = tabs.find((item) => item.id === tabId);
|
|
@@ -16347,7 +17063,7 @@ async function pushGitFooterSync(tabId = activeTabId, syncValue = "") {
|
|
|
16347
17063
|
: "";
|
|
16348
17064
|
if (!(await appConfirmText(`Run git push for ${outgoing} outgoing commit${outgoing === 1 ? "" : "s"} in ${target}?${protectedWarning}`, { affected: `Remote Git branch ${branch || "current branch"}`, confirmLabel: "Push commits" }))) return;
|
|
16349
17065
|
|
|
16350
|
-
|
|
17066
|
+
gitFooterSyncInFlightByTab.add(tabId);
|
|
16351
17067
|
if (isCurrentTabContext(tabContext)) renderFooter();
|
|
16352
17068
|
try {
|
|
16353
17069
|
const response = await api("/api/git-workflow/push", { method: "POST", body: {}, tabId });
|
|
@@ -16389,7 +17105,7 @@ async function pushGitFooterSync(tabId = activeTabId, syncValue = "") {
|
|
|
16389
17105
|
} catch (error) {
|
|
16390
17106
|
addEvent(error.message || String(error), "error");
|
|
16391
17107
|
} finally {
|
|
16392
|
-
|
|
17108
|
+
gitFooterSyncInFlightByTab.delete(tabId);
|
|
16393
17109
|
if (isCurrentTabContext(tabContext)) renderFooter();
|
|
16394
17110
|
}
|
|
16395
17111
|
}
|
|
@@ -16410,13 +17126,19 @@ function renderGitFooterPayloadMeta(chip, tab, payload) {
|
|
|
16410
17126
|
} else if (chip.key === "worktree" && visible("webui-branch-picker")) {
|
|
16411
17127
|
options.onClick = () => setFooterBranchPickerOpen(!footerBranchPickerOpen);
|
|
16412
17128
|
action = "Click to manage branch worktrees for this repository.";
|
|
16413
|
-
} else if (chip.key === "sync" && visible("webui-sync-push")
|
|
17129
|
+
} else if (chip.key === "sync" && visible("webui-sync-push")) {
|
|
16414
17130
|
const tabId = tab?.id || activeTabId;
|
|
16415
|
-
const
|
|
16416
|
-
|
|
17131
|
+
const syncAction = gitFooterSyncAction(chip);
|
|
17132
|
+
const inFlight = tabId ? gitFooterSyncInFlightByTab.has(tabId) : false;
|
|
17133
|
+
if (syncAction === "pull") {
|
|
17134
|
+
options.onClick = () => pullGitFooterSync(tabId);
|
|
17135
|
+
action = inFlight ? "Pulling from origin." : "Click to pull from origin with fast-forward only.";
|
|
17136
|
+
} else if (syncAction === "push") {
|
|
17137
|
+
options.onClick = () => pushGitFooterSync(tabId, chip.value);
|
|
17138
|
+
action = inFlight ? "Pushing local commits to the configured remote." : "Click to push local commits to the configured remote.";
|
|
17139
|
+
}
|
|
16417
17140
|
options.ariaBusy = inFlight;
|
|
16418
17141
|
options.disabled = inFlight;
|
|
16419
|
-
action = inFlight ? "Pushing local commits to the configured remote." : "Click to push local commits to the configured remote.";
|
|
16420
17142
|
} else if (chip.key === "changes" && visible("webui-changes-modal")) {
|
|
16421
17143
|
options.onClick = () => openGitChangesDialog(tab?.id || activeTabId);
|
|
16422
17144
|
action = "Click to view the current git diff.";
|
|
@@ -16482,10 +17204,10 @@ function footerBranchPickerRenderKey() {
|
|
|
16482
17204
|
function gitFooterPickerStateKey(payload) {
|
|
16483
17205
|
const tabContext = activeTabContext();
|
|
16484
17206
|
const refreshInFlight = tabContext.tabId ? gitFooterPayloadRefreshInFlightByTab.has(tabContext.tabId) : false;
|
|
16485
|
-
const
|
|
17207
|
+
const syncInFlight = tabContext.tabId ? gitFooterSyncInFlightByTab.has(tabContext.tabId) : false;
|
|
16486
17208
|
const piCalibrationInFlight = tabContext.tabId ? gitFooterPiCalibrationInFlightByTab.has(tabContext.tabId) : false;
|
|
16487
17209
|
const refreshAvailable = hasLoadedRpcCommand("git-footer-refresh");
|
|
16488
|
-
return `${footerModelPickerOpen ? 1 : 0}|${footerThinkingPickerOpen ? 1 : 0}|${footerBranchPickerOpen ? 1 : 0}|${footerBranchPickerRenderKey()}|${mobileFooterExpanded ? 1 : 0}|${refreshInFlight ? 1 : 0}|${
|
|
17210
|
+
return `${footerModelPickerOpen ? 1 : 0}|${footerThinkingPickerOpen ? 1 : 0}|${footerBranchPickerOpen ? 1 : 0}|${footerBranchPickerRenderKey()}|${mobileFooterExpanded ? 1 : 0}|${refreshInFlight ? 1 : 0}|${syncInFlight ? 1 : 0}|${piCalibrationInFlight ? 1 : 0}|${refreshAvailable ? 1 : 0}|${gitFooterPayloadVisibilityKey(payload)}`;
|
|
16489
17211
|
}
|
|
16490
17212
|
|
|
16491
17213
|
function updateGitFooterChipNodeValue(node, chip, valueSelector) {
|
|
@@ -20319,6 +21041,84 @@ function scheduleRefreshFooter(delay = 300, tabContext = activeTabContext()) {
|
|
|
20319
21041
|
}, delay);
|
|
20320
21042
|
}
|
|
20321
21043
|
|
|
21044
|
+
function semanticReconcileContextKey(tabContext = {}) {
|
|
21045
|
+
return `${tabContext.tabId || ""}:${Number(tabContext.generation) || 0}`;
|
|
21046
|
+
}
|
|
21047
|
+
|
|
21048
|
+
function mergeSemanticReconcileRequest(pendingByContext, dirty = {}, tabContext = {}) {
|
|
21049
|
+
const key = semanticReconcileContextKey(tabContext);
|
|
21050
|
+
let request = pendingByContext.get(key);
|
|
21051
|
+
if (!request) {
|
|
21052
|
+
request = { tabContext: { tabId: tabContext.tabId || null, generation: Number(tabContext.generation) || 0 }, dirty: {} };
|
|
21053
|
+
}
|
|
21054
|
+
let requested = false;
|
|
21055
|
+
for (const flag of SEMANTIC_RECONCILE_FLAGS) {
|
|
21056
|
+
if (!dirty[flag]) continue;
|
|
21057
|
+
request.dirty[flag] = true;
|
|
21058
|
+
requested = true;
|
|
21059
|
+
}
|
|
21060
|
+
if (requested) pendingByContext.set(key, request);
|
|
21061
|
+
return requested;
|
|
21062
|
+
}
|
|
21063
|
+
|
|
21064
|
+
function takeSemanticReconcileRequests(pendingByContext) {
|
|
21065
|
+
const requests = Array.from(pendingByContext.values());
|
|
21066
|
+
pendingByContext.clear();
|
|
21067
|
+
return requests;
|
|
21068
|
+
}
|
|
21069
|
+
|
|
21070
|
+
// Coalesced semantic reconciliation. Lifecycle boundaries declare which
|
|
21071
|
+
// non-transcript surfaces became dirty; each tab generation retains its own
|
|
21072
|
+
// request until the frame flush. Raw stream deltas never reach here.
|
|
21073
|
+
function scheduleSemanticReconcile(dirty = {}, tabContext = activeTabContext()) {
|
|
21074
|
+
if (!mergeSemanticReconcileRequest(semanticReconcilePending, dirty, tabContext)) return;
|
|
21075
|
+
if (semanticReconcileFrame !== null) return;
|
|
21076
|
+
const flush = () => {
|
|
21077
|
+
semanticReconcileFrame = null;
|
|
21078
|
+
flushSemanticReconcile();
|
|
21079
|
+
};
|
|
21080
|
+
if (typeof requestAnimationFrame === "function") semanticReconcileFrame = requestAnimationFrame(flush);
|
|
21081
|
+
else semanticReconcileFrame = setTimeout(flush, 0);
|
|
21082
|
+
}
|
|
21083
|
+
|
|
21084
|
+
function flushSemanticReconcile() {
|
|
21085
|
+
for (const { dirty, tabContext } of takeSemanticReconcileRequests(semanticReconcilePending)) {
|
|
21086
|
+
// Originating-tab settlement work is never reassigned. Workflow continuation
|
|
21087
|
+
// is tab-scoped and may run after the user has switched away.
|
|
21088
|
+
if (dirty.workflow) reconcileGitWorkflowContinuation(tabContext.tabId);
|
|
21089
|
+
if (dirty.usage) {
|
|
21090
|
+
scheduleRefreshCodexUsage(2200);
|
|
21091
|
+
scheduleRefreshClaudeUsage(2200);
|
|
21092
|
+
}
|
|
21093
|
+
|
|
21094
|
+
// DOM and active-session fetches are valid only for the still-current tab
|
|
21095
|
+
// generation; resetActiveTabUi/refreshAll owns the newly active tab.
|
|
21096
|
+
if (!isCurrentTabContext(tabContext)) continue;
|
|
21097
|
+
if (dirty.messages) scheduleRefreshMessages(120, tabContext);
|
|
21098
|
+
if (dirty.state) scheduleRefreshState(120, tabContext);
|
|
21099
|
+
if (dirty.footerData) scheduleRefreshFooter(300, tabContext);
|
|
21100
|
+
if (dirty.footer) renderFooter();
|
|
21101
|
+
if (dirty.feedback) renderFeedbackTray();
|
|
21102
|
+
if (dirty.usage) {
|
|
21103
|
+
refreshCodexFastMode(tabContext).catch((error) => addEvent(`Codex Fast mode refresh failed: ${error.message || String(error)}`, "warn"));
|
|
21104
|
+
}
|
|
21105
|
+
}
|
|
21106
|
+
}
|
|
21107
|
+
|
|
21108
|
+
// Continue a guided git workflow that was waiting on the agent turn. This is a
|
|
21109
|
+
// settlement-boundary concern, not a streaming concern.
|
|
21110
|
+
function reconcileGitWorkflowContinuation(workflowTabId = activeTabId) {
|
|
21111
|
+
const workflow = gitWorkflowForTab(workflowTabId, { create: false });
|
|
21112
|
+
if (!workflow?.active) return;
|
|
21113
|
+
if (workflow.step === "generating") {
|
|
21114
|
+
loadGitWorkflowMessage({ requireFresh: true, generationId: workflow.messageGenerationId, runId: workflow.runId, tabId: workflowTabId });
|
|
21115
|
+
} else if (workflow.step === "branchNaming") {
|
|
21116
|
+
loadGitWorkflowBranchName({ requireFresh: true, retries: 3, runId: workflow.runId, tabId: workflowTabId });
|
|
21117
|
+
} else if (workflow.step === "prGenerating") {
|
|
21118
|
+
loadGitWorkflowPr({ requireFresh: true, retries: 3, runId: workflow.runId, tabId: workflowTabId });
|
|
21119
|
+
}
|
|
21120
|
+
}
|
|
21121
|
+
|
|
20322
21122
|
function formatCodexPlanType(value) {
|
|
20323
21123
|
const text = String(value || "").trim();
|
|
20324
21124
|
if (!text) return "unknown plan";
|
|
@@ -23068,10 +23868,10 @@ function liveTodoProgressWidgetLinesFromText(text, tabId = activeTabId) {
|
|
|
23068
23868
|
return lines;
|
|
23069
23869
|
}
|
|
23070
23870
|
|
|
23071
|
-
// Coalesce
|
|
23072
|
-
//
|
|
23073
|
-
//
|
|
23074
|
-
//
|
|
23871
|
+
// Coalesce widget rebuilds to one per animation frame. Todo-progress records
|
|
23872
|
+
// are now derived only at authoritative message reconciliation, but several
|
|
23873
|
+
// semantic boundaries can land in the same frame, so the widget area must
|
|
23874
|
+
// still never be torn down/rebuilt more than once per frame.
|
|
23075
23875
|
function scheduleLiveWidgetRender() {
|
|
23076
23876
|
if (liveWidgetRenderFrame !== null) return;
|
|
23077
23877
|
const flush = () => {
|
|
@@ -23082,20 +23882,25 @@ function scheduleLiveWidgetRender() {
|
|
|
23082
23882
|
else liveWidgetRenderFrame = setTimeout(flush, 0);
|
|
23083
23883
|
}
|
|
23084
23884
|
|
|
23085
|
-
|
|
23086
|
-
|
|
23087
|
-
|
|
23088
|
-
|
|
23089
|
-
|
|
23090
|
-
|
|
23091
|
-
const
|
|
23092
|
-
|
|
23093
|
-
|
|
23094
|
-
|
|
23095
|
-
|
|
23096
|
-
|
|
23097
|
-
|
|
23098
|
-
|
|
23885
|
+
// Authoritative source for the todo-progress record: the settled assistant
|
|
23886
|
+
// text that message reconciliation just fetched. Raw stream tokens never
|
|
23887
|
+
// reach this path, so widget records change at most once per reconciliation
|
|
23888
|
+
// and only when the parsed checklist value actually differs.
|
|
23889
|
+
function authoritativeTodoProgressSourceText(messages = latestMessages) {
|
|
23890
|
+
for (let index = (messages?.length || 0) - 1; index >= 0; index -= 1) {
|
|
23891
|
+
const message = messages[index];
|
|
23892
|
+
if (message?.role !== "assistant") continue;
|
|
23893
|
+
const text = textFromContent(message.content);
|
|
23894
|
+
if (String(text || "").trim()) return text;
|
|
23895
|
+
}
|
|
23896
|
+
return "";
|
|
23897
|
+
}
|
|
23898
|
+
|
|
23899
|
+
function reconcileTodoProgressFromMessages(messages = latestMessages, tabId = activeTabId) {
|
|
23900
|
+
if (!tabId) return false;
|
|
23901
|
+
const text = authoritativeTodoProgressSourceText(messages);
|
|
23902
|
+
if (!text) return false;
|
|
23903
|
+
return syncLiveTodoProgressWidgetFromText(text, tabId);
|
|
23099
23904
|
}
|
|
23100
23905
|
|
|
23101
23906
|
function syncLiveTodoProgressWidgetFromText(text, tabId = activeTabId) {
|
|
@@ -23105,7 +23910,7 @@ function syncLiveTodoProgressWidgetFromText(text, tabId = activeTabId) {
|
|
|
23105
23910
|
if (tabId && todoProgressSignatureByTab.get(tabId) === signature) return false;
|
|
23106
23911
|
// liveTodoProgressWidgetLinesFromText already short-circuits unless the
|
|
23107
23912
|
// feature is enabled, so detection is settled here. Do NOT run
|
|
23108
|
-
// updateOptionalFeatureAvailability()
|
|
23913
|
+
// updateOptionalFeatureAvailability() from this path: it triggers git-footer
|
|
23109
23914
|
// payload reconciliation and a full optional-feature control rebuild.
|
|
23110
23915
|
// Availability is reconciled on command/state refreshes and RPC widget
|
|
23111
23916
|
// updates instead, keeping streaming output decoupled from chrome UI.
|
|
@@ -23476,6 +24281,7 @@ function renderAurReviewWidget() {
|
|
|
23476
24281
|
if (!isOptionalFeatureEnabled("aurReview")) return null;
|
|
23477
24282
|
const payload = parseAurReviewPayload(getWidgetLines(AUR_REVIEW_RPC_WIDGET_KEY));
|
|
23478
24283
|
if (!payload || payload.decision.state === "closed") return null;
|
|
24284
|
+
if (payload.origin === "guided-git" && payload.scope === "staged" && payload.decision.state === "approved") return null;
|
|
23479
24285
|
|
|
23480
24286
|
const node = make("section", "widget aur-review-widget");
|
|
23481
24287
|
node.setAttribute("aria-label", "Manual repository review");
|
|
@@ -27552,10 +28358,11 @@ function renderGitWorkflow() {
|
|
|
27552
28358
|
elements.gitWorkflowSteps.replaceChildren();
|
|
27553
28359
|
elements.gitWorkflowActions.replaceChildren();
|
|
27554
28360
|
|
|
27555
|
-
|
|
27556
|
-
//
|
|
27557
|
-
//
|
|
27558
|
-
const reviewStepAvailable =
|
|
28361
|
+
const preferences = gitWorkflow.preferences || gitWorkflowPreferences || {};
|
|
28362
|
+
// The saved option controls new workflows, while an already-required review
|
|
28363
|
+
// remains visible and fail-closed if setup or extension availability changes.
|
|
28364
|
+
const reviewStepAvailable = (preferences.reviewProcessEnabled !== false && guidedGitReviewAvailable(activeTabId))
|
|
28365
|
+
|| gitWorkflow.guidedReviewRequired === true;
|
|
27559
28366
|
const standardProcesses = reviewStepAvailable ? GIT_WORKFLOW_PROCESSES : GIT_WORKFLOW_PROCESSES.filter((process) => process.value !== "review");
|
|
27560
28367
|
const processes = gitWorkflow.mode === "initRepo" ? GIT_INIT_WORKFLOW_PROCESSES : standardProcesses;
|
|
27561
28368
|
const activeIndexMap = gitWorkflow.mode === "initRepo" ? GIT_INIT_WORKFLOW_ACTIVE_INDEX : GIT_WORKFLOW_ACTIVE_INDEX;
|
|
@@ -27582,7 +28389,6 @@ function renderGitWorkflow() {
|
|
|
27582
28389
|
return;
|
|
27583
28390
|
}
|
|
27584
28391
|
|
|
27585
|
-
const preferences = gitWorkflow.preferences || gitWorkflowPreferences || {};
|
|
27586
28392
|
if (gitWorkflow.step === "add") {
|
|
27587
28393
|
if (preferences.stagingPolicy === "all") {
|
|
27588
28394
|
addGitWorkflowAction("Run git add .", () => runGitAdd(), "primary", false);
|
|
@@ -27964,10 +28770,9 @@ async function startGitWorkflow(tabId = activeTabId, { skipSetup = false } = {})
|
|
|
27964
28770
|
pr: null,
|
|
27965
28771
|
prRequestedAt: 0,
|
|
27966
28772
|
...resetGuidedGitReviewPatch({ retainDeclinedStagedContentHash: false }),
|
|
27967
|
-
//
|
|
27968
|
-
//
|
|
27969
|
-
|
|
27970
|
-
guidedReviewRequired: guidedGitReviewAvailable(tabId),
|
|
28773
|
+
// The saved option and current capability decide whether a new flow requires
|
|
28774
|
+
// review; once required, later setup or extension changes cannot bypass it.
|
|
28775
|
+
guidedReviewRequired: preferences.reviewProcessEnabled !== false && guidedGitReviewAvailable(tabId),
|
|
27971
28776
|
preferences,
|
|
27972
28777
|
verificationConfirmed: false,
|
|
27973
28778
|
}, { tabId });
|
|
@@ -28299,7 +29104,7 @@ async function runGitAdd(tabId = gitWorkflowActionTabId()) {
|
|
|
28299
29104
|
const result = await gitWorkflowRequest("/api/git-workflow/add", { runId, tabId });
|
|
28300
29105
|
if (!result) return;
|
|
28301
29106
|
const output = `${formatGitCommandResult(result)}\n\nStaged.`;
|
|
28302
|
-
if (guidedGitReviewAvailable(tabId) || workflow.guidedReviewRequired === true) {
|
|
29107
|
+
if ((workflow.preferences?.reviewProcessEnabled !== false && guidedGitReviewAvailable(tabId)) || workflow.guidedReviewRequired === true) {
|
|
28303
29108
|
// A required gate never falls through to the legacy message flow just
|
|
28304
29109
|
// because its extension was disabled or disappeared after staging.
|
|
28305
29110
|
await requestGuidedGitReview(tabId, { output });
|
|
@@ -28323,7 +29128,7 @@ async function acceptCurrentGitStaging(tabId = gitWorkflowActionTabId()) {
|
|
|
28323
29128
|
const staged = Number(response.data?.summary?.staged || 0);
|
|
28324
29129
|
if (staged <= 0) throw new Error("No staged files are available. Use Review/select changes to stage the intended files first.");
|
|
28325
29130
|
const output = `Using the current staged set (${staged} file${staged === 1 ? "" : "s"}).`;
|
|
28326
|
-
if (guidedGitReviewAvailable(tabId) || workflow.guidedReviewRequired === true) {
|
|
29131
|
+
if ((workflow.preferences?.reviewProcessEnabled !== false && guidedGitReviewAvailable(tabId)) || workflow.guidedReviewRequired === true) {
|
|
28327
29132
|
await requestGuidedGitReview(tabId, { output });
|
|
28328
29133
|
} else {
|
|
28329
29134
|
setGitWorkflow({
|
|
@@ -32295,43 +33100,9 @@ function updateLiveToolCard(bubble, message) {
|
|
|
32295
33100
|
return true;
|
|
32296
33101
|
}
|
|
32297
33102
|
|
|
32298
|
-
function cancelQueuedLiveToolRunRender(toolCallId = "") {
|
|
32299
|
-
if (toolCallId) liveToolRenderQueue.delete(String(toolCallId));
|
|
32300
|
-
else liveToolRenderQueue.clear();
|
|
32301
|
-
if (liveToolRenderQueue.size === 0) {
|
|
32302
|
-
clearTimeout(liveToolRenderTimer);
|
|
32303
|
-
liveToolRenderTimer = null;
|
|
32304
|
-
}
|
|
32305
|
-
}
|
|
32306
|
-
|
|
32307
|
-
function clearLiveToolRenderQueue() {
|
|
32308
|
-
cancelQueuedLiveToolRunRender();
|
|
32309
|
-
}
|
|
32310
|
-
|
|
32311
|
-
function flushLiveToolRunRenderQueue() {
|
|
32312
|
-
const entries = Array.from(liveToolRenderQueue.values());
|
|
32313
|
-
clearLiveToolRenderQueue();
|
|
32314
|
-
for (const entry of entries) renderLiveToolRun(entry.run, { scroll: entry.scroll });
|
|
32315
|
-
}
|
|
32316
|
-
|
|
32317
|
-
function scheduleLiveToolRunRender(run, { scroll = false } = {}) {
|
|
32318
|
-
if (!run?.toolCallId) return;
|
|
32319
|
-
const id = String(run.toolCallId);
|
|
32320
|
-
const existing = liveToolRenderQueue.get(id);
|
|
32321
|
-
liveToolRenderQueue.set(id, { run, scroll: !!(existing?.scroll || scroll) });
|
|
32322
|
-
if (liveToolRenderTimer) return;
|
|
32323
|
-
liveToolRenderTimer = setTimeout(() => {
|
|
32324
|
-
liveToolRenderTimer = null;
|
|
32325
|
-
const flush = () => flushLiveToolRunRenderQueue();
|
|
32326
|
-
if (typeof requestAnimationFrame === "function") requestAnimationFrame(flush);
|
|
32327
|
-
else flush();
|
|
32328
|
-
}, TOOL_LIVE_UPDATE_THROTTLE_MS);
|
|
32329
|
-
}
|
|
32330
|
-
|
|
32331
33103
|
function renderLiveToolRun(run, { scroll = true } = {}) {
|
|
32332
33104
|
if (!run?.toolCallId) return;
|
|
32333
33105
|
const id = String(run.toolCallId);
|
|
32334
|
-
cancelQueuedLiveToolRunRender(id);
|
|
32335
33106
|
const existing = liveToolCards.get(id);
|
|
32336
33107
|
const existingConnected = !!(existing?.isConnected && existing.parentElement === elements.chat);
|
|
32337
33108
|
const shouldFollow = scroll && (autoFollowChat || isChatNearBottom());
|
|
@@ -32381,10 +33152,10 @@ function handleToolExecutionStart(event) {
|
|
|
32381
33152
|
if (run) renderLiveToolRun(run);
|
|
32382
33153
|
}
|
|
32383
33154
|
|
|
32384
|
-
function
|
|
33155
|
+
function applyTranscriptToolExecutionUpdate(event) {
|
|
32385
33156
|
const result = { ...(event.partialResult || {}), isError: false };
|
|
32386
33157
|
const run = upsertLiveToolRun(event, { result, isPartial: true, isError: false });
|
|
32387
|
-
if (run)
|
|
33158
|
+
if (run) renderLiveToolRun(run, { scroll: false });
|
|
32388
33159
|
}
|
|
32389
33160
|
|
|
32390
33161
|
function handleToolExecutionEnd(event) {
|
|
@@ -32725,7 +33496,11 @@ function runIndicatorDetail() {
|
|
|
32725
33496
|
return "Waiting for output or action…";
|
|
32726
33497
|
}
|
|
32727
33498
|
|
|
33499
|
+
// Transcript-owned ticker: it may only repaint the run-indicator bubble's own
|
|
33500
|
+
// stable text nodes. Canonical state reconciliation belongs to the separate
|
|
33501
|
+
// lifecycle watchdog below, so transcript rendering never issues network work.
|
|
32728
33502
|
function startRunIndicatorTicker() {
|
|
33503
|
+
startLifecycleStateWatchdog();
|
|
32729
33504
|
if (runIndicatorTimer) return;
|
|
32730
33505
|
runIndicatorTimer = setInterval(() => {
|
|
32731
33506
|
if (!runIndicatorIsActive()) {
|
|
@@ -32733,17 +33508,39 @@ function startRunIndicatorTicker() {
|
|
|
32733
33508
|
return;
|
|
32734
33509
|
}
|
|
32735
33510
|
updateRunIndicatorBubble();
|
|
32736
|
-
maybeRefreshRunIndicatorState();
|
|
32737
33511
|
}, RUN_INDICATOR_TICK_MS);
|
|
32738
33512
|
}
|
|
32739
33513
|
|
|
32740
33514
|
function stopRunIndicatorTicker() {
|
|
32741
33515
|
clearInterval(runIndicatorTimer);
|
|
32742
33516
|
runIndicatorTimer = null;
|
|
33517
|
+
stopLifecycleStateWatchdog();
|
|
33518
|
+
}
|
|
33519
|
+
|
|
33520
|
+
// Lifecycle-owned watchdog. It runs while a run is active and performs the
|
|
33521
|
+
// bounded canonical state recheck that keeps Stop/idle honest when a terminal
|
|
33522
|
+
// lifecycle event is dropped. It is time-driven, never output/token-driven.
|
|
33523
|
+
function startLifecycleStateWatchdog() {
|
|
33524
|
+
if (lifecycleStateWatchdogTimer) return;
|
|
33525
|
+
lifecycleStateWatchdogTimer = setInterval(() => {
|
|
33526
|
+
if (!runIndicatorIsActive()) {
|
|
33527
|
+
stopLifecycleStateWatchdog();
|
|
33528
|
+
return;
|
|
33529
|
+
}
|
|
33530
|
+
maybeRefreshRunIndicatorState();
|
|
33531
|
+
}, RUN_INDICATOR_STATE_RECHECK_MS);
|
|
33532
|
+
}
|
|
33533
|
+
|
|
33534
|
+
function stopLifecycleStateWatchdog() {
|
|
33535
|
+
clearInterval(lifecycleStateWatchdogTimer);
|
|
33536
|
+
lifecycleStateWatchdogTimer = null;
|
|
32743
33537
|
}
|
|
32744
33538
|
|
|
32745
33539
|
function createRunIndicatorBubble() {
|
|
32746
33540
|
runIndicatorBubble = make("article", "message runIndicator run-indicator-message streaming");
|
|
33541
|
+
// Stable transcript-owned activity root: streaming activity updates rewrite
|
|
33542
|
+
// only this bubble's own text nodes, never composer or chrome surfaces.
|
|
33543
|
+
runIndicatorBubble.dataset.streamOwned = "run-indicator";
|
|
32747
33544
|
runIndicatorBubble.setAttribute("aria-live", "polite");
|
|
32748
33545
|
runIndicatorBubble.setAttribute("aria-label", "Agent is running:");
|
|
32749
33546
|
|
|
@@ -32820,10 +33617,31 @@ function setRunIndicatorActivity(activity, { active = true, scroll = true } = {}
|
|
|
32820
33617
|
const needsRender = scroll || !hadRunIndicatorBubble || wasLocallyActive !== runIndicatorLocallyActive || previousActivity !== runIndicatorActivity;
|
|
32821
33618
|
if (needsRender) scheduleRunIndicatorRender({ scroll });
|
|
32822
33619
|
else if (runIndicatorIsActive()) startRunIndicatorTicker();
|
|
32823
|
-
|
|
33620
|
+
// Activity wording is transcript-owned. Composer/Stop chrome is reconciled
|
|
33621
|
+
// only when the lifecycle enum itself changes, so wording updates can never
|
|
33622
|
+
// reparent Steer/Follow-up controls or rewrite the run-active body class.
|
|
33623
|
+
syncLifecycleComposerState();
|
|
32824
33624
|
if (active) scheduleRunIndicatorGraceCheck();
|
|
32825
33625
|
}
|
|
32826
33626
|
|
|
33627
|
+
function currentLifecycleComposerSignature() {
|
|
33628
|
+
return [
|
|
33629
|
+
activeTabGeneration,
|
|
33630
|
+
isRunActive() ? "run" : "idle",
|
|
33631
|
+
isAbortAvailable() ? "abort" : "no-abort",
|
|
33632
|
+
abortRequestInFlight ? "aborting" : "ready",
|
|
33633
|
+
busyPromptBehavior,
|
|
33634
|
+
].join("|");
|
|
33635
|
+
}
|
|
33636
|
+
|
|
33637
|
+
function syncLifecycleComposerState({ force = false } = {}) {
|
|
33638
|
+
const signature = currentLifecycleComposerSignature();
|
|
33639
|
+
if (!force && signature === lifecycleComposerSignature) return false;
|
|
33640
|
+
lifecycleComposerSignature = signature;
|
|
33641
|
+
scheduleComposerModeButtonsUpdate();
|
|
33642
|
+
return true;
|
|
33643
|
+
}
|
|
33644
|
+
|
|
32827
33645
|
function clearRunIndicatorActivity({ render = true, deferRemoval = false } = {}) {
|
|
32828
33646
|
clearRunIndicatorGraceCheck();
|
|
32829
33647
|
runIndicatorLastStateCheckAt = 0;
|
|
@@ -32833,6 +33651,8 @@ function clearRunIndicatorActivity({ render = true, deferRemoval = false } = {})
|
|
|
32833
33651
|
runIndicatorRemovalDeferred = deferRemoval && runIndicatorBubble?.parentElement === elements.chat;
|
|
32834
33652
|
if (runIndicatorRemovalDeferred) stopRunIndicatorTicker();
|
|
32835
33653
|
else if (render) renderRunIndicator();
|
|
33654
|
+
stopLifecycleStateWatchdog();
|
|
33655
|
+
lifecycleComposerSignature = currentLifecycleComposerSignature();
|
|
32836
33656
|
updateComposerModeButtons();
|
|
32837
33657
|
}
|
|
32838
33658
|
|
|
@@ -32858,6 +33678,7 @@ function syncRunIndicatorFromState(state = currentState) {
|
|
|
32858
33678
|
} else {
|
|
32859
33679
|
renderRunIndicator();
|
|
32860
33680
|
}
|
|
33681
|
+
lifecycleComposerSignature = currentLifecycleComposerSignature();
|
|
32861
33682
|
updateComposerModeButtons();
|
|
32862
33683
|
}
|
|
32863
33684
|
|
|
@@ -34196,6 +35017,38 @@ function ensureOptionalFeatureMigrationRenderTimer() {
|
|
|
34196
35017
|
}
|
|
34197
35018
|
}
|
|
34198
35019
|
|
|
35020
|
+
function clearOptionalFeatureReadyDismissTimer() {
|
|
35021
|
+
if (optionalFeatureMigrationReadyDismissTimer) clearTimeout(optionalFeatureMigrationReadyDismissTimer);
|
|
35022
|
+
optionalFeatureMigrationReadyDismissTimer = null;
|
|
35023
|
+
optionalFeatureMigrationPendingReadyDismissKey = "";
|
|
35024
|
+
}
|
|
35025
|
+
|
|
35026
|
+
function optionalFeatureReadyDismissKey(snapshot = optionalFeatureMigrationSnapshot) {
|
|
35027
|
+
return snapshot.phase === "ready" ? String(snapshot.revision || "pending") : "";
|
|
35028
|
+
}
|
|
35029
|
+
|
|
35030
|
+
function scheduleOptionalFeatureReadyDismiss(key) {
|
|
35031
|
+
if (!key) {
|
|
35032
|
+
clearOptionalFeatureReadyDismissTimer();
|
|
35033
|
+
if (optionalFeatureMigrationSnapshot.phase !== "ready") optionalFeatureMigrationDismissedReadyKey = "";
|
|
35034
|
+
return;
|
|
35035
|
+
}
|
|
35036
|
+
if (optionalFeatureMigrationDismissedReadyKey === key) return;
|
|
35037
|
+
if (optionalFeatureMigrationReadyDismissTimer && optionalFeatureMigrationPendingReadyDismissKey === key) return;
|
|
35038
|
+
clearOptionalFeatureReadyDismissTimer();
|
|
35039
|
+
optionalFeatureMigrationPendingReadyDismissKey = key;
|
|
35040
|
+
optionalFeatureMigrationReadyDismissTimer = setTimeout(() => {
|
|
35041
|
+
optionalFeatureMigrationReadyDismissTimer = null;
|
|
35042
|
+
optionalFeatureMigrationPendingReadyDismissKey = "";
|
|
35043
|
+
if (optionalFeatureReadyDismissKey() !== key || optionalFeatureRestartNotice) return;
|
|
35044
|
+
optionalFeatureMigrationDismissedReadyKey = key;
|
|
35045
|
+
const surface = elements.optionalFeatureMigrationSurface;
|
|
35046
|
+
if (!surface) return;
|
|
35047
|
+
surface.replaceChildren();
|
|
35048
|
+
surface.hidden = true;
|
|
35049
|
+
}, OPTIONAL_FEATURE_READY_AUTO_DISMISS_MS);
|
|
35050
|
+
}
|
|
35051
|
+
|
|
34199
35052
|
function optionalFeatureMigrationAction(label, handler, className = "") {
|
|
34200
35053
|
const button = make("button", className, label);
|
|
34201
35054
|
button.type = "button";
|
|
@@ -34248,6 +35101,14 @@ function renderOptionalFeatureMigrationSurface() {
|
|
|
34248
35101
|
const summary = snapshot.summary || {};
|
|
34249
35102
|
const conflicts = (snapshot.features || []).filter((feature) => feature.state === "conflict");
|
|
34250
35103
|
const progress = snapshot.progress;
|
|
35104
|
+
const readyDismissKey = optionalFeatureReadyDismissKey(snapshot);
|
|
35105
|
+
const readyCanAutoDismiss = Boolean(readyDismissKey && !optionalFeatureRestartNotice);
|
|
35106
|
+
if (readyCanAutoDismiss && optionalFeatureMigrationDismissedReadyKey === readyDismissKey) {
|
|
35107
|
+
surface.replaceChildren();
|
|
35108
|
+
surface.hidden = true;
|
|
35109
|
+
ensureOptionalFeatureMigrationRenderTimer();
|
|
35110
|
+
return;
|
|
35111
|
+
}
|
|
34251
35112
|
const card = make("div", `optional-feature-migration-card phase-${snapshot.phase}`);
|
|
34252
35113
|
const copy = make("div", "optional-feature-migration-copy");
|
|
34253
35114
|
const title = make("strong", "optional-feature-migration-title");
|
|
@@ -34334,6 +35195,7 @@ function renderOptionalFeatureMigrationSurface() {
|
|
|
34334
35195
|
surface.replaceChildren(card);
|
|
34335
35196
|
surface.hidden = false;
|
|
34336
35197
|
ensureOptionalFeatureMigrationRenderTimer();
|
|
35198
|
+
scheduleOptionalFeatureReadyDismiss(readyCanAutoDismiss ? readyDismissKey : "");
|
|
34337
35199
|
if (focusKey && focusKey !== optionalFeatureMigrationCompletionFocusKey) {
|
|
34338
35200
|
optionalFeatureMigrationCompletionFocusKey = focusKey;
|
|
34339
35201
|
queueMicrotask(() => card.isConnected && card.focus({ preventScroll: true }));
|
|
@@ -35450,19 +36312,108 @@ function sessionSummaryStateForTab(tabId = activeTabId) {
|
|
|
35450
36312
|
return normalized;
|
|
35451
36313
|
}
|
|
35452
36314
|
|
|
36315
|
+
function sessionSummaryControlStatus(tabId) {
|
|
36316
|
+
const state = sessionSummaryStateForTab(tabId);
|
|
36317
|
+
if (state?.status === "generating") return "Generating session summary…";
|
|
36318
|
+
if (state?.status === "failure") return `Session summary failed: ${state.message || "unknown error"}`;
|
|
36319
|
+
if (state?.summaryMarkdown) return "Open the latest session summary";
|
|
36320
|
+
return "Open or create a session summary";
|
|
36321
|
+
}
|
|
36322
|
+
|
|
36323
|
+
function createTerminalTabSplitButton(tab) {
|
|
36324
|
+
const button = make("button", "terminal-tab-split-button");
|
|
36325
|
+
button.type = "button";
|
|
36326
|
+
button.draggable = false;
|
|
36327
|
+
const isOpenSplit = splitTabId === tab.id && !embeddedSplitMode && !isSidePanelOverlayView();
|
|
36328
|
+
button.disabled = embeddedSplitMode || isSidePanelOverlayView();
|
|
36329
|
+
button.setAttribute("aria-pressed", isOpenSplit ? "true" : "false");
|
|
36330
|
+
button.dataset.splitState = isOpenSplit ? "unsplit" : "split";
|
|
36331
|
+
const label = isOpenSplit ? `Close split view for ${tab.title || "Pi terminal"}` : `Split ${tab.title || "Pi terminal"} to the right`;
|
|
36332
|
+
applyStyledTooltip(button, label, { ariaLabel: label, targetKey: `terminal-tab:${tab.id}:split` });
|
|
36333
|
+
const ns = "http://www.w3.org/2000/svg";
|
|
36334
|
+
const icon = document.createElementNS(ns, "svg");
|
|
36335
|
+
icon.setAttribute("class", "terminal-tab-action-icon terminal-tab-split-icon");
|
|
36336
|
+
icon.setAttribute("viewBox", "0 0 24 24");
|
|
36337
|
+
icon.setAttribute("aria-hidden", "true");
|
|
36338
|
+
icon.setAttribute("focusable", "false");
|
|
36339
|
+
const frame = document.createElementNS(ns, "rect");
|
|
36340
|
+
frame.setAttribute("x", "4");
|
|
36341
|
+
frame.setAttribute("y", "5");
|
|
36342
|
+
frame.setAttribute("width", "16");
|
|
36343
|
+
frame.setAttribute("height", "14");
|
|
36344
|
+
frame.setAttribute("rx", "2");
|
|
36345
|
+
frame.setAttribute("fill", "none");
|
|
36346
|
+
frame.setAttribute("stroke", "currentColor");
|
|
36347
|
+
frame.setAttribute("stroke-width", "2");
|
|
36348
|
+
const divider = document.createElementNS(ns, "path");
|
|
36349
|
+
divider.setAttribute("d", "M12 5v14M15 12h4m0 0-2-2m2 2-2 2");
|
|
36350
|
+
divider.setAttribute("fill", "none");
|
|
36351
|
+
divider.setAttribute("stroke", "currentColor");
|
|
36352
|
+
divider.setAttribute("stroke-width", "2");
|
|
36353
|
+
divider.setAttribute("stroke-linecap", "round");
|
|
36354
|
+
divider.setAttribute("stroke-linejoin", "round");
|
|
36355
|
+
icon.append(frame, divider);
|
|
36356
|
+
button.append(icon);
|
|
36357
|
+
button.addEventListener("click", (event) => {
|
|
36358
|
+
event.stopPropagation();
|
|
36359
|
+
void splitTerminalTab(tab.id, { triggerButton: button });
|
|
36360
|
+
});
|
|
36361
|
+
return button;
|
|
36362
|
+
}
|
|
36363
|
+
|
|
36364
|
+
function createTerminalTabActions(tab) {
|
|
36365
|
+
const actions = make("div", "terminal-tab-actions");
|
|
36366
|
+
actions.setAttribute("role", "group");
|
|
36367
|
+
actions.setAttribute("aria-label", `Actions for ${tab.title || "Pi terminal"}`);
|
|
36368
|
+
actions.append(createTerminalTabSplitButton(tab));
|
|
36369
|
+
const summary = createTerminalTabSessionSummaryButton(tab);
|
|
36370
|
+
if (summary) actions.append(summary);
|
|
36371
|
+
return actions;
|
|
36372
|
+
}
|
|
36373
|
+
|
|
36374
|
+
function createTerminalTabSessionSummaryButton(tab) {
|
|
36375
|
+
if (!tab?.id || !hasAvailableCommand("summary", { tabId: tab.id })) return null;
|
|
36376
|
+
const state = sessionSummaryStateForTab(tab.id);
|
|
36377
|
+
const status = sessionSummaryControlStatus(tab.id);
|
|
36378
|
+
const button = make("button", "terminal-tab-summary-button");
|
|
36379
|
+
button.type = "button";
|
|
36380
|
+
button.draggable = false;
|
|
36381
|
+
button.disabled = state?.status === "generating";
|
|
36382
|
+
button.setAttribute("aria-busy", state?.status === "generating" ? "true" : "false");
|
|
36383
|
+
button.setAttribute("aria-controls", "sessionSummaryOverlay");
|
|
36384
|
+
const label = `${status} for ${tab.title || "Pi terminal"}`;
|
|
36385
|
+
applyStyledTooltip(button, status, { ariaLabel: label, targetKey: `terminal-tab:${tab.id}:summary` });
|
|
36386
|
+
const ns = "http://www.w3.org/2000/svg";
|
|
36387
|
+
const icon = document.createElementNS(ns, "svg");
|
|
36388
|
+
icon.setAttribute("class", "composer-icon");
|
|
36389
|
+
icon.setAttribute("viewBox", "0 0 24 24");
|
|
36390
|
+
icon.setAttribute("aria-hidden", "true");
|
|
36391
|
+
icon.setAttribute("focusable", "false");
|
|
36392
|
+
const page = document.createElementNS(ns, "path");
|
|
36393
|
+
page.setAttribute("d", "M5 4h14v16H5z");
|
|
36394
|
+
page.setAttribute("fill", "none");
|
|
36395
|
+
page.setAttribute("stroke", "currentColor");
|
|
36396
|
+
page.setAttribute("stroke-width", "2");
|
|
36397
|
+
page.setAttribute("stroke-linejoin", "round");
|
|
36398
|
+
const lines = document.createElementNS(ns, "path");
|
|
36399
|
+
lines.setAttribute("d", "M8 8h8M8 12h8M8 16h5");
|
|
36400
|
+
lines.setAttribute("fill", "none");
|
|
36401
|
+
lines.setAttribute("stroke", "currentColor");
|
|
36402
|
+
lines.setAttribute("stroke-width", "2");
|
|
36403
|
+
lines.setAttribute("stroke-linecap", "round");
|
|
36404
|
+
icon.append(page, lines);
|
|
36405
|
+
button.append(icon);
|
|
36406
|
+
button.addEventListener("click", (event) => {
|
|
36407
|
+
event.stopPropagation();
|
|
36408
|
+
void openSessionSummaryForTab(tab.id, { focusReturnKey: `terminal-tab:${tab.id}:summary` }).catch((error) => addEvent(error.message || String(error), "error"));
|
|
36409
|
+
});
|
|
36410
|
+
return button;
|
|
36411
|
+
}
|
|
36412
|
+
|
|
35453
36413
|
function renderSessionSummaryControls() {
|
|
35454
|
-
const available = !!activeTabId && hasAvailableCommand("summary", { tabId: activeTabId });
|
|
35455
36414
|
const setupAvailable = !!activeTabId && hasAvailableCommand("summary-setup", { tabId: activeTabId });
|
|
35456
|
-
const state = sessionSummaryStateForTab(activeTabId);
|
|
35457
|
-
const status = state?.status === "generating" ? "Generating session summary…" : state?.status === "failure" ? `Session summary failed: ${state.message || "unknown error"}` : state?.summaryMarkdown ? "Open the latest session summary" : "Open or create a session summary";
|
|
35458
|
-
for (const button of [elements.summaryHeaderButton, elements.summaryActionButton]) {
|
|
35459
|
-
if (!button) continue;
|
|
35460
|
-
button.hidden = !available;
|
|
35461
|
-
button.disabled = !available || state?.status === "generating";
|
|
35462
|
-
button.setAttribute("aria-busy", state?.status === "generating" ? "true" : "false");
|
|
35463
|
-
applyStyledTooltip(button, status, { ariaLabel: status, align: "end" });
|
|
35464
|
-
}
|
|
35465
36415
|
if (elements.optionsSummarySetupButton) elements.optionsSummarySetupButton.hidden = !setupAvailable;
|
|
36416
|
+
scheduleTabsRender();
|
|
35466
36417
|
}
|
|
35467
36418
|
|
|
35468
36419
|
function closeSessionSummaryOverlay({ restoreFocus = true } = {}) {
|
|
@@ -35470,9 +36421,19 @@ function closeSessionSummaryOverlay({ restoreFocus = true } = {}) {
|
|
|
35470
36421
|
if (!overlay || overlay.hidden) return;
|
|
35471
36422
|
overlay.hidden = true;
|
|
35472
36423
|
const focusReturn = sessionSummaryOverlayFocusReturn;
|
|
36424
|
+
const focusReturnKey = sessionSummaryOverlayFocusReturnKey;
|
|
36425
|
+
const keyedFocusReturn = focusReturnKey
|
|
36426
|
+
? [...elements.tabBar.querySelectorAll("button")].find((node) => terminalTabControlKey(node) === focusReturnKey)
|
|
36427
|
+
: null;
|
|
36428
|
+
const connectedFocusReturn = keyedFocusReturn || (focusReturn?.isConnected ? focusReturn : null);
|
|
35473
36429
|
sessionSummaryOverlayTabId = null;
|
|
35474
36430
|
sessionSummaryOverlayFocusReturn = null;
|
|
35475
|
-
|
|
36431
|
+
sessionSummaryOverlayFocusReturnKey = "";
|
|
36432
|
+
if (restoreFocus && connectedFocusReturn) {
|
|
36433
|
+
const groupKey = connectedFocusReturn.closest?.("[data-group-key]")?.dataset?.groupKey;
|
|
36434
|
+
if (groupKey) setOpenTerminalTabGroup(groupKey);
|
|
36435
|
+
queueMicrotask(() => connectedFocusReturn.focus({ preventScroll: true }));
|
|
36436
|
+
}
|
|
35476
36437
|
}
|
|
35477
36438
|
|
|
35478
36439
|
function renderSessionSummaryOverlay() {
|
|
@@ -35500,9 +36461,10 @@ function renderSessionSummaryOverlay() {
|
|
|
35500
36461
|
elements.sessionSummaryOverlayRefreshButton.textContent = generating ? "Generating…" : "Refresh";
|
|
35501
36462
|
}
|
|
35502
36463
|
|
|
35503
|
-
function openSessionSummaryOverlay(tabId, { loading = false } = {}) {
|
|
36464
|
+
function openSessionSummaryOverlay(tabId, { loading = false, focusReturnKey = "" } = {}) {
|
|
35504
36465
|
if (!tabId || !elements.sessionSummaryOverlay) return;
|
|
35505
36466
|
sessionSummaryOverlayFocusReturn = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
36467
|
+
sessionSummaryOverlayFocusReturnKey = focusReturnKey || terminalTabControlKey(sessionSummaryOverlayFocusReturn);
|
|
35506
36468
|
sessionSummaryOverlayTabId = tabId;
|
|
35507
36469
|
if (loading) {
|
|
35508
36470
|
const previous = sessionSummaryStateForTab(tabId);
|
|
@@ -35524,7 +36486,7 @@ function updateSessionSummaryForTab(tabId, value, { resetProjection = false } =
|
|
|
35524
36486
|
const normalized = normalizeSessionSummaryClientState(value, sessionSummaryByTab.get(tabId), { resetProjection });
|
|
35525
36487
|
if (!normalized) return null;
|
|
35526
36488
|
sessionSummaryByTab.set(tabId, normalized);
|
|
35527
|
-
|
|
36489
|
+
renderSessionSummaryControls();
|
|
35528
36490
|
if (sessionSummaryOverlayTabId === tabId) renderSessionSummaryOverlay();
|
|
35529
36491
|
return normalized;
|
|
35530
36492
|
}
|
|
@@ -35559,7 +36521,7 @@ async function requestSessionSummaryGeneration(tabId, { refresh = false } = {})
|
|
|
35559
36521
|
}
|
|
35560
36522
|
}
|
|
35561
36523
|
|
|
35562
|
-
async function openSessionSummaryForTab(tabId = activeTabId, { refresh = false } = {}) {
|
|
36524
|
+
async function openSessionSummaryForTab(tabId = activeTabId, { refresh = false, focusReturnKey = "" } = {}) {
|
|
35563
36525
|
if (!tabId || !hasAvailableCommand("summary", { tabId })) return;
|
|
35564
36526
|
let state = sessionSummaryStateForTab(tabId);
|
|
35565
36527
|
if (!state?.configured) {
|
|
@@ -35573,11 +36535,11 @@ async function openSessionSummaryForTab(tabId = activeTabId, { refresh = false }
|
|
|
35573
36535
|
updatedAt: new Date().toISOString(),
|
|
35574
36536
|
});
|
|
35575
36537
|
if (!response.data?.preferences?.configured) {
|
|
35576
|
-
await openNativeSessionSummarySetupDialog({ initialData: response.data });
|
|
36538
|
+
await openNativeSessionSummarySetupDialog({ initialData: response.data, tabId, focusReturnKey });
|
|
35577
36539
|
return;
|
|
35578
36540
|
}
|
|
35579
36541
|
}
|
|
35580
|
-
openSessionSummaryOverlay(tabId, { loading: refresh || !state?.summaryMarkdown });
|
|
36542
|
+
openSessionSummaryOverlay(tabId, { loading: refresh || !state?.summaryMarkdown, focusReturnKey });
|
|
35581
36543
|
if (refresh || !state?.summaryMarkdown) await requestSessionSummaryGeneration(tabId, { refresh }).catch(() => {});
|
|
35582
36544
|
}
|
|
35583
36545
|
|
|
@@ -36376,8 +37338,8 @@ function gitWorkflowSetupModelKey(model) {
|
|
|
36376
37338
|
return model?.provider && model?.id ? `${model.provider}/${model.id}` : "";
|
|
36377
37339
|
}
|
|
36378
37340
|
|
|
36379
|
-
async function openNativeSessionSummarySetupDialog({ initialData = null, onSaved } = {}) {
|
|
36380
|
-
nativeCommandTabId =
|
|
37341
|
+
async function openNativeSessionSummarySetupDialog({ initialData = null, onSaved, tabId = activeTabId, focusReturnKey = "" } = {}) {
|
|
37342
|
+
nativeCommandTabId = tabId;
|
|
36381
37343
|
openNativeCommandDialog({
|
|
36382
37344
|
title: "/summary-setup",
|
|
36383
37345
|
message: "Configure persistent background titles and Markdown summaries. Saving confirms the disclosure below, then immediately generates and opens the first summary.",
|
|
@@ -36474,10 +37436,11 @@ async function openNativeSessionSummarySetupDialog({ initialData = null, onSaved
|
|
|
36474
37436
|
const summaryPrompt = controls.summaryPrompt.textarea.value.trim();
|
|
36475
37437
|
if (!titlePrompt || !summaryPrompt) throw new Error("Both editable prompts are required.");
|
|
36476
37438
|
if (titlePrompt.length > SESSION_SUMMARY_PROMPT_MAX_CHARS || summaryPrompt.length > SESSION_SUMMARY_PROMPT_MAX_CHARS) throw new Error("Each editable prompt must not exceed 8 KiB.");
|
|
37439
|
+
const targetTabId = nativeCommandTabId || tabId || activeTabId;
|
|
36477
37440
|
const reviewed = await appConfirm({
|
|
36478
37441
|
title: "Save session summary setup?",
|
|
36479
37442
|
summary: `${disclosure.scope || "Selected active-branch text and tool names will be sent to the configured model."}\n\n${disclosure.cost || "Generation may incur provider usage."}`,
|
|
36480
|
-
affected: "Global session-summary preferences and the
|
|
37443
|
+
affected: "Global session-summary preferences and the selected tab's first generated summary",
|
|
36481
37444
|
undoable: false,
|
|
36482
37445
|
confirmLabel: "Save and generate",
|
|
36483
37446
|
danger: false,
|
|
@@ -36485,6 +37448,7 @@ async function openNativeSessionSummarySetupDialog({ initialData = null, onSaved
|
|
|
36485
37448
|
if (!reviewed) return;
|
|
36486
37449
|
const response = await nativeCommandApi("/api/session-summary/preferences", {
|
|
36487
37450
|
method: "PUT",
|
|
37451
|
+
tabId: targetTabId,
|
|
36488
37452
|
body: {
|
|
36489
37453
|
confirmed: true,
|
|
36490
37454
|
preferences: {
|
|
@@ -36497,7 +37461,6 @@ async function openNativeSessionSummarySetupDialog({ initialData = null, onSaved
|
|
|
36497
37461
|
},
|
|
36498
37462
|
},
|
|
36499
37463
|
});
|
|
36500
|
-
const targetTabId = nativeCommandTabId || activeTabId;
|
|
36501
37464
|
updateSessionSummaryForTab(targetTabId, response.data?.summary || {
|
|
36502
37465
|
version: SESSION_SUMMARY_PROTOCOL_VERSION,
|
|
36503
37466
|
status: "idle",
|
|
@@ -36508,7 +37471,7 @@ async function openNativeSessionSummarySetupDialog({ initialData = null, onSaved
|
|
|
36508
37471
|
});
|
|
36509
37472
|
nativeSettingsDirty = false;
|
|
36510
37473
|
closeNativeCommandDialog({ force: true });
|
|
36511
|
-
openSessionSummaryOverlay(targetTabId, { loading: true });
|
|
37474
|
+
openSessionSummaryOverlay(targetTabId, { loading: true, focusReturnKey });
|
|
36512
37475
|
await requestSessionSummaryGeneration(targetTabId, { refresh: true }).catch(() => {});
|
|
36513
37476
|
if (typeof onSaved === "function") await onSaved(response.data?.preferences);
|
|
36514
37477
|
} catch (error) {
|
|
@@ -36578,6 +37541,10 @@ async function openNativeGitWorkflowSetupDialog({ onSaved } = {}) {
|
|
|
36578
37541
|
{ value: "preserve", label: "Use current staged set" },
|
|
36579
37542
|
{ value: "all", label: "Stage all with git add ." },
|
|
36580
37543
|
], "Review/select is the safe default and opens Git Changes for per-file staging.", { label: "safety", tone: "safety" }),
|
|
37544
|
+
reviewProcess: nativeSettingSelect("Manual review process", preferences.reviewProcessEnabled !== false ? "enabled" : "disabled", [
|
|
37545
|
+
{ value: "enabled", label: "Enabled when aur-review is available" },
|
|
37546
|
+
{ value: "disabled", label: "Disabled — continue to message generation" },
|
|
37547
|
+
], "When enabled, staged changes require explicit approval before message, worktree, or commit actions.", { label: "safety", tone: "safety" }),
|
|
36581
37548
|
delivery: nativeSettingSelect("Delivery path", preferences.deliveryMode || "ask", [
|
|
36582
37549
|
{ value: "ask", label: "Ask each workflow" },
|
|
36583
37550
|
{ value: "current", label: "Prefer current branch" },
|
|
@@ -36606,7 +37573,7 @@ async function openNativeGitWorkflowSetupDialog({ onSaved } = {}) {
|
|
|
36606
37573
|
nativeSettingsNote("Persistence", `Saved globally in ${data.path || "the Pi Web UI settings file"}. Credentials are never stored here.`),
|
|
36607
37574
|
nativeSettingsSection("Generation profile", "Required model and effort for generated Git text.", [controls.model, controls.thinking], { open: true }),
|
|
36608
37575
|
nativeSettingsSection("Commit style", "Conventional Commit output preferences.", [controls.language, controls.defaultVariant, controls.scope], { open: true }),
|
|
36609
|
-
nativeSettingsSection("Workflow safety", "Staging, delivery, and verification defaults; push and PR confirmation remain mandatory.", [controls.staging, controls.delivery, controls.verification], { open: true }),
|
|
37576
|
+
nativeSettingsSection("Workflow safety", "Staging, review, delivery, and verification defaults; push and PR confirmation remain mandatory.", [controls.staging, controls.reviewProcess, controls.delivery, controls.verification], { open: true }),
|
|
36610
37577
|
);
|
|
36611
37578
|
elements.nativeCommandBody.replaceChildren(body);
|
|
36612
37579
|
elements.nativeCommandActions.replaceChildren();
|
|
@@ -36634,6 +37601,7 @@ async function openNativeGitWorkflowSetupDialog({ onSaved } = {}) {
|
|
|
36634
37601
|
scope: controls.scope.select.value,
|
|
36635
37602
|
},
|
|
36636
37603
|
stagingPolicy: controls.staging.select.value,
|
|
37604
|
+
reviewProcessEnabled: controls.reviewProcess.select.value === "enabled",
|
|
36637
37605
|
deliveryMode: controls.delivery.select.value,
|
|
36638
37606
|
verificationPolicy: controls.verification.select.value,
|
|
36639
37607
|
},
|
|
@@ -37637,6 +38605,9 @@ function insertNumpadDecimal(event) {
|
|
|
37637
38605
|
return true;
|
|
37638
38606
|
}
|
|
37639
38607
|
|
|
38608
|
+
// Transcript-only. Message rendering may reconcile transcript state and the
|
|
38609
|
+
// transcript DOM, but never footer/feedback/widget chrome: those surfaces are
|
|
38610
|
+
// owned by the coalesced semantic reconciler.
|
|
37640
38611
|
function renderMessages(messages) {
|
|
37641
38612
|
latestMessages = messages || [];
|
|
37642
38613
|
reconcileOptimisticUserPrompts(latestMessages);
|
|
@@ -37645,8 +38616,6 @@ function renderMessages(messages) {
|
|
|
37645
38616
|
syncPromptHistoryFromMessages(latestMessages);
|
|
37646
38617
|
trackSkillsFromMessages(latestMessages, activeTabId);
|
|
37647
38618
|
renderAllMessages();
|
|
37648
|
-
renderFooter();
|
|
37649
|
-
renderFeedbackTray();
|
|
37650
38619
|
}
|
|
37651
38620
|
|
|
37652
38621
|
function cancelStreamBubbleHide() {
|
|
@@ -37791,10 +38760,6 @@ function handleCompactMessageUpdate(event) {
|
|
|
37791
38760
|
if (!reduced.changed) return true;
|
|
37792
38761
|
compactLiveState = reduced.state;
|
|
37793
38762
|
clearCompactToolShells();
|
|
37794
|
-
if (reduced.kind.startsWith("thinking")) setRunIndicatorActivity("Thinking…", { scroll: false });
|
|
37795
|
-
else if (reduced.kind.startsWith("toolcall")) setRunIndicatorActivity("Building tool call…", { scroll: false });
|
|
37796
|
-
else setRunIndicatorActivity("Writing response…", { scroll: false });
|
|
37797
|
-
compactLiveScheduler.request();
|
|
37798
38763
|
return true;
|
|
37799
38764
|
}
|
|
37800
38765
|
|
|
@@ -37854,15 +38819,7 @@ function applyOutputModeControl(event, tabContext = activeTabContext()) {
|
|
|
37854
38819
|
return true;
|
|
37855
38820
|
}
|
|
37856
38821
|
|
|
37857
|
-
function cancelStreamingAssistantTextRender() {
|
|
37858
|
-
clearTimeout(streamTextRenderTimer);
|
|
37859
|
-
streamTextRenderTimer = null;
|
|
37860
|
-
if (streamTextRenderFrame !== null && typeof cancelAnimationFrame === "function") cancelAnimationFrame(streamTextRenderFrame);
|
|
37861
|
-
streamTextRenderFrame = null;
|
|
37862
|
-
}
|
|
37863
|
-
|
|
37864
38822
|
function removeStreamBubble() {
|
|
37865
|
-
cancelStreamingAssistantTextRender();
|
|
37866
38823
|
cancelStreamBubbleHide();
|
|
37867
38824
|
removeLiveTranscriptBubble(streamBubble, "assistant");
|
|
37868
38825
|
streamBubble = null;
|
|
@@ -38009,18 +38966,6 @@ function renderStreamingAssistantText() {
|
|
|
38009
38966
|
}
|
|
38010
38967
|
}
|
|
38011
38968
|
|
|
38012
|
-
function scheduleStreamingAssistantTextRender({ immediate = false } = {}) {
|
|
38013
|
-
if (streamTextRenderTimer || streamTextRenderFrame !== null) return;
|
|
38014
|
-
const flush = () => {
|
|
38015
|
-
streamTextRenderTimer = null;
|
|
38016
|
-
streamTextRenderFrame = null;
|
|
38017
|
-
renderStreamingAssistantText();
|
|
38018
|
-
scheduleChatFollowScroll();
|
|
38019
|
-
};
|
|
38020
|
-
if (immediate && typeof requestAnimationFrame === "function") streamTextRenderFrame = requestAnimationFrame(flush);
|
|
38021
|
-
else streamTextRenderTimer = setTimeout(flush, immediate ? 0 : STREAM_OUTPUT_TOOLCALL_GUARD_MS);
|
|
38022
|
-
}
|
|
38023
|
-
|
|
38024
38969
|
function suppressStreamingAssistantTextBeforeToolCall() {
|
|
38025
38970
|
setStreamRawText("");
|
|
38026
38971
|
removeStreamBubble();
|
|
@@ -38117,7 +39062,6 @@ function showStreamingThinking(initialText = "") {
|
|
|
38117
39062
|
|
|
38118
39063
|
function resetStreamBubble({ preserveCompact = false } = {}) {
|
|
38119
39064
|
resetCompactLiveOutput({ remove: !preserveCompact });
|
|
38120
|
-
cancelStreamingAssistantTextRender();
|
|
38121
39065
|
cancelStreamBubbleHide();
|
|
38122
39066
|
streamBubble = null;
|
|
38123
39067
|
streamText = null;
|
|
@@ -38356,52 +39300,35 @@ function handleMessageUpdate(event) {
|
|
|
38356
39300
|
if (compactOutputActive() && handleCompactMessageUpdate(event)) return;
|
|
38357
39301
|
const update = event.assistantMessageEvent || {};
|
|
38358
39302
|
if (update.type === "thinking_start") {
|
|
38359
|
-
setRunIndicatorActivity("Thinking…", { scroll: false });
|
|
38360
39303
|
syncStreamingThinkingFromUpdate(event, update);
|
|
38361
|
-
scheduleChatFollowScroll();
|
|
38362
39304
|
} else if (update.type === "thinking_delta") {
|
|
38363
39305
|
const delta = thinkingDeltaText(update);
|
|
38364
|
-
setRunIndicatorActivity("Thinking…", { scroll: false });
|
|
38365
39306
|
const synced = syncStreamingThinkingFromUpdate(event, update);
|
|
38366
39307
|
if (thinkingOutputVisible && delta && (!synced || !streamThinking?.textContent)) {
|
|
38367
39308
|
showStreamingThinking("");
|
|
38368
39309
|
if (streamThinking) renderThinkingMarkdown(streamThinking, `${streamThinking._rawThinkingText || ""}${delta}`);
|
|
38369
39310
|
}
|
|
38370
|
-
scheduleChatFollowScroll();
|
|
38371
39311
|
} else if (update.type === "thinking_end") {
|
|
38372
39312
|
if (syncStreamingThinkingFromUpdate(event, update)) streamThinkingBubble?.classList.add("complete");
|
|
38373
|
-
setRunIndicatorActivity("Finished thinking; waiting for the next output or action…", { scroll: false });
|
|
38374
39313
|
} else if (update.type === "text_delta" || update.type === "text_end") {
|
|
38375
39314
|
syncStreamRawTextFromUpdate(event, update);
|
|
38376
|
-
|
|
38377
|
-
setRunIndicatorActivity("Writing response…", { scroll: false });
|
|
38378
|
-
scheduleStreamingAssistantTextRender({ immediate: !!(streamToolCallSeen || streamBubble) });
|
|
38379
|
-
// Streaming output must stay transcript-local. Full footer/status
|
|
38380
|
-
// reconciliation happens on message/state refreshes, not per token.
|
|
38381
|
-
scheduleChatFollowScroll();
|
|
39315
|
+
renderStreamingAssistantText();
|
|
38382
39316
|
} else if (update.type === "toolcall_start") {
|
|
38383
39317
|
streamToolCallSeen = true;
|
|
38384
39318
|
suppressStreamingAssistantTextBeforeToolCall();
|
|
38385
|
-
|
|
38386
|
-
setRunIndicatorActivity(`Building tool call: ${name}…`, { scroll: false });
|
|
38387
|
-
addEvent(`tool call started in assistant message`, "info");
|
|
39319
|
+
updateStreamingToolCallFromEvent(event, { reset: true });
|
|
38388
39320
|
} else if (update.type === "toolcall_delta") {
|
|
38389
39321
|
streamToolCallSeen = true;
|
|
38390
39322
|
suppressStreamingAssistantTextBeforeToolCall();
|
|
38391
|
-
|
|
38392
|
-
setRunIndicatorActivity(`Building tool call: ${name}…`, { scroll: false });
|
|
38393
|
-
scheduleChatFollowScroll();
|
|
39323
|
+
updateStreamingToolCallFromEvent(event, { appendDelta: true });
|
|
38394
39324
|
} else if (update.type === "toolcall_end") {
|
|
38395
39325
|
streamToolCallSeen = true;
|
|
38396
39326
|
suppressStreamingAssistantTextBeforeToolCall();
|
|
38397
|
-
|
|
38398
|
-
setRunIndicatorActivity(`Tool call ready: ${name}; waiting to run…`, { scroll: false });
|
|
39327
|
+
updateStreamingToolCallFromEvent(event, { complete: true });
|
|
38399
39328
|
} else if (update.type === "error") {
|
|
38400
39329
|
streamProviderErrorText = assistantStreamErrorMessage(event, update);
|
|
38401
|
-
setRunIndicatorActivity("Assistant stream reported an error…");
|
|
38402
39330
|
appendMessage({ role: "error", title: "assistant error", timestamp: Date.now(), content: streamProviderErrorText, level: "error" }, { streaming: true });
|
|
38403
39331
|
renderRunIndicator({ scroll: false });
|
|
38404
|
-
scheduleChatFollowScroll();
|
|
38405
39332
|
}
|
|
38406
39333
|
}
|
|
38407
39334
|
|
|
@@ -38697,7 +39624,13 @@ async function refreshMessages(tabContext = activeTabContext(), { authoritative
|
|
|
38697
39624
|
else if (preserveNormalStream) restoreStreamRenderAfterChatRebuild();
|
|
38698
39625
|
restoreChatTextSelection(selectionSnapshot);
|
|
38699
39626
|
markTabOutputSeen();
|
|
38700
|
-
|
|
39627
|
+
// Authoritative content just landed: derive the todo-progress record once
|
|
39628
|
+
// here instead of from raw token cadence, and let the coalesced semantic
|
|
39629
|
+
// reconciler own the footer/widget chrome that message data can change.
|
|
39630
|
+
// syncLiveTodoProgressWidgetFromText owns the frame-coalesced widget render
|
|
39631
|
+
// and only fires when the parsed checklist value actually changed.
|
|
39632
|
+
reconcileTodoProgressFromMessages(latestMessages, tabContext.tabId);
|
|
39633
|
+
scheduleSemanticReconcile({ footer: true }, tabContext);
|
|
38701
39634
|
}
|
|
38702
39635
|
|
|
38703
39636
|
async function refreshModels(tabContext = activeTabContext()) {
|
|
@@ -39482,6 +40415,7 @@ function renderCommands() {
|
|
|
39482
40415
|
async function refreshCommands(tabContext = activeTabContext()) {
|
|
39483
40416
|
if (!tabContext.tabId) return;
|
|
39484
40417
|
const response = await api("/api/commands", { tabId: tabContext.tabId });
|
|
40418
|
+
if (!tabs.some((tab) => tab.id === tabContext.tabId)) return;
|
|
39485
40419
|
const catalog = {
|
|
39486
40420
|
raw: normalizeCommands(response.data?.commands || [], { dedupe: false }),
|
|
39487
40421
|
available: normalizeCommands(response.data?.commands || []),
|
|
@@ -39490,6 +40424,7 @@ async function refreshCommands(tabContext = activeTabContext()) {
|
|
|
39490
40424
|
// while this request was in flight. Guided Git must never borrow another
|
|
39491
40425
|
// tab's extension availability or duplicate-command alias.
|
|
39492
40426
|
commandCatalogsByTab.set(tabContext.tabId, catalog);
|
|
40427
|
+
scheduleTabsRender();
|
|
39493
40428
|
if (!isCurrentTabContext(tabContext)) return;
|
|
39494
40429
|
rawAvailableCommands = catalog.raw;
|
|
39495
40430
|
availableCommands = catalog.available;
|
|
@@ -40920,7 +41855,39 @@ function handleInactiveTabEvent(event) {
|
|
|
40920
41855
|
}
|
|
40921
41856
|
}
|
|
40922
41857
|
|
|
41858
|
+
const TRANSCRIPT_STREAM_BARRIER_EVENT_TYPES = new Set([
|
|
41859
|
+
"agent_start",
|
|
41860
|
+
"message_start",
|
|
41861
|
+
"message_end",
|
|
41862
|
+
"tool_execution_start",
|
|
41863
|
+
"tool_execution_end",
|
|
41864
|
+
"agent_end",
|
|
41865
|
+
"agent_settled",
|
|
41866
|
+
"auto_retry_start",
|
|
41867
|
+
"auto_retry_end",
|
|
41868
|
+
"compaction_start",
|
|
41869
|
+
"compaction_end",
|
|
41870
|
+
"webui_output_mode",
|
|
41871
|
+
"pi_process_exit",
|
|
41872
|
+
"pi_process_error",
|
|
41873
|
+
]);
|
|
41874
|
+
|
|
41875
|
+
function dispatchTranscriptStreamEvent(event) {
|
|
41876
|
+
return streamOutputController.dispatch(event, {
|
|
41877
|
+
owner: transcriptStreamOwner(event?.tabId || activeTabId),
|
|
41878
|
+
});
|
|
41879
|
+
}
|
|
41880
|
+
|
|
41881
|
+
function flushTranscriptStreamBarrier(event) {
|
|
41882
|
+
if (!TRANSCRIPT_STREAM_BARRIER_EVENT_TYPES.has(event?.type)) return;
|
|
41883
|
+
streamOutputController.barrier(event.type);
|
|
41884
|
+
reconcileUnknownTranscriptEvidenceAtBarrier(event);
|
|
41885
|
+
if (event.type === "pi_process_exit" || event.type === "pi_process_error") streamOutputController.cancel();
|
|
41886
|
+
}
|
|
41887
|
+
|
|
40923
41888
|
function handleEvent(event) {
|
|
41889
|
+
if (dispatchTranscriptStreamEvent(event)) return;
|
|
41890
|
+
flushTranscriptStreamBarrier(event);
|
|
40924
41891
|
if (event?.type === "webui_session_summary") {
|
|
40925
41892
|
handleSessionSummaryEvent(event);
|
|
40926
41893
|
return;
|
|
@@ -40943,6 +41910,10 @@ function handleEvent(event) {
|
|
|
40943
41910
|
}
|
|
40944
41911
|
if (eventHasTabActivityPayload(event)) ingestEventTabActivity(event);
|
|
40945
41912
|
if (event?.type === "auto_retry_start" || event?.type === "auto_retry_end") trackAutoRetryStateFromEvent(event);
|
|
41913
|
+
// Advance the fallback tool-boundary epoch before inactive-tab routing.
|
|
41914
|
+
// Inactive tool boundaries are still tracked, so their agent_start must own
|
|
41915
|
+
// the same run identity semantics as the foreground tab.
|
|
41916
|
+
if (event?.type === "agent_start") beginToolBoundaryRun(event);
|
|
40946
41917
|
if (eventMayAffectSkillUsage(event)) trackSkillsFromEvent(event);
|
|
40947
41918
|
if (!eventTargetsActiveTab(event)) {
|
|
40948
41919
|
handleInactiveTabEvent(event);
|
|
@@ -41126,9 +42097,8 @@ function handleEvent(event) {
|
|
|
41126
42097
|
if (voiceConversationActiveFor(event.tabId || activeTabId)) voiceConversation.setAssistantActivity({ streaming: true });
|
|
41127
42098
|
setRunIndicatorActivity("Agent run started; waiting for first output or action…");
|
|
41128
42099
|
addEvent("agent started");
|
|
41129
|
-
|
|
41130
|
-
|
|
41131
|
-
renderFeedbackTray();
|
|
42100
|
+
syncLifecycleComposerState({ force: true });
|
|
42101
|
+
scheduleSemanticReconcile({ state: true, footer: true, feedback: true }, tabContext);
|
|
41132
42102
|
break;
|
|
41133
42103
|
case "agent_end":
|
|
41134
42104
|
if (compactOutputActive()) finishCompactLiveOutput(tabContext);
|
|
@@ -41142,9 +42112,7 @@ function handleEvent(event) {
|
|
|
41142
42112
|
}
|
|
41143
42113
|
addEvent("agent run ended; waiting for settlement");
|
|
41144
42114
|
if (runIndicatorIsActive()) setRunIndicatorActivity("Agent run ended; checking for retry or continuation…", { scroll: false });
|
|
41145
|
-
|
|
41146
|
-
scheduleRefreshState();
|
|
41147
|
-
scheduleRefreshFooter();
|
|
42115
|
+
scheduleSemanticReconcile({ messages: true, state: true, footerData: true }, tabContext);
|
|
41148
42116
|
break;
|
|
41149
42117
|
case "message_start":
|
|
41150
42118
|
if (event.message?.role === "assistant") {
|
|
@@ -41153,9 +42121,6 @@ function handleEvent(event) {
|
|
|
41153
42121
|
setRunIndicatorActivity("Starting assistant message…", { scroll: false });
|
|
41154
42122
|
}
|
|
41155
42123
|
break;
|
|
41156
|
-
case "message_update":
|
|
41157
|
-
handleMessageUpdate(event);
|
|
41158
|
-
break;
|
|
41159
42124
|
case "message_end": {
|
|
41160
42125
|
if (compactOutputActive()) finishCompactLiveOutput(tabContext);
|
|
41161
42126
|
streamMessageActive = false;
|
|
@@ -41166,9 +42131,9 @@ function handleEvent(event) {
|
|
|
41166
42131
|
}
|
|
41167
42132
|
streamProviderErrorText = "";
|
|
41168
42133
|
if (runIndicatorIsActive()) setRunIndicatorActivity("Assistant message finished; waiting for the next step…", { scroll: false });
|
|
41169
|
-
|
|
41170
|
-
|
|
41171
|
-
|
|
42134
|
+
// Authoritative message reconciliation derives the todo-progress record;
|
|
42135
|
+
// raw assistant tokens never rebuild widgets.
|
|
42136
|
+
scheduleSemanticReconcile({ messages: true, state: true, footerData: true }, tabContext);
|
|
41172
42137
|
break;
|
|
41173
42138
|
}
|
|
41174
42139
|
case "tool_execution_start":
|
|
@@ -41183,11 +42148,7 @@ function handleEvent(event) {
|
|
|
41183
42148
|
handleToolExecutionStart(event);
|
|
41184
42149
|
}
|
|
41185
42150
|
setRunIndicatorActivity(`Running tool: ${runIndicatorToolName(event.toolName)}…`);
|
|
41186
|
-
addEvent(`tool ${event.toolName} started`, "info", { toolCallId: event.toolCallId });
|
|
41187
|
-
break;
|
|
41188
|
-
case "tool_execution_update":
|
|
41189
|
-
if (!compactOutputActive()) handleToolExecutionUpdate(event);
|
|
41190
|
-
setRunIndicatorActivity(`Running tool: ${runIndicatorToolName(event.toolName)}…`, { scroll: false });
|
|
42151
|
+
if (claimToolBoundaryRecord(event, "log:start")) addEvent(`tool ${event.toolName} started`, "info", { toolCallId: event.toolCallId });
|
|
41191
42152
|
break;
|
|
41192
42153
|
case "tool_execution_end": {
|
|
41193
42154
|
if (voiceConversationActiveFor(event.tabId || activeTabId)) voiceConversation.setAssistantActivity({ toolRunning: false });
|
|
@@ -41201,10 +42162,10 @@ function handleEvent(event) {
|
|
|
41201
42162
|
handleToolExecutionEnd(event);
|
|
41202
42163
|
}
|
|
41203
42164
|
setRunIndicatorActivity(`Tool ${runIndicatorToolName(event.toolName)} ${event.isError ? "failed" : "finished"}; waiting for the agent's next step…`);
|
|
41204
|
-
addEvent(`tool ${event.toolName} ${event.isError ? "failed" : "finished"}`, event.isError ? "error" : "info", { toolCallId: event.toolCallId });
|
|
42165
|
+
if (claimToolBoundaryRecord(event, "log:end")) addEvent(`tool ${event.toolName} ${event.isError ? "failed" : "finished"}`, event.isError ? "error" : "info", { toolCallId: event.toolCallId });
|
|
41205
42166
|
// Compact tool shells deliberately defer rich body construction to the
|
|
41206
42167
|
// final transcript reconciliation; normal mode retains its live card.
|
|
41207
|
-
|
|
42168
|
+
scheduleSemanticReconcile({ footerData: true }, tabContext);
|
|
41208
42169
|
break;
|
|
41209
42170
|
}
|
|
41210
42171
|
case "compaction_start":
|
|
@@ -41224,9 +42185,7 @@ function handleEvent(event) {
|
|
|
41224
42185
|
if (!currentState?.isStreaming) clearRunIndicatorActivity();
|
|
41225
42186
|
markTabOutputSeen();
|
|
41226
42187
|
renderStatus();
|
|
41227
|
-
|
|
41228
|
-
scheduleRefreshMessages();
|
|
41229
|
-
scheduleRefreshFooter();
|
|
42188
|
+
scheduleSemanticReconcile({ state: true, messages: true, footerData: true }, tabContext);
|
|
41230
42189
|
break;
|
|
41231
42190
|
case "agent_settled":
|
|
41232
42191
|
promptRoutingTabs.delete(event.tabId || activeTabId);
|
|
@@ -41243,24 +42202,17 @@ function handleEvent(event) {
|
|
|
41243
42202
|
clearRunIndicatorActivity({ deferRemoval: !autoFollowChat || !isChatNearBottom() });
|
|
41244
42203
|
markTabOutputSeen();
|
|
41245
42204
|
requestGitFooterWebuiPayload(tabContext, { force: true });
|
|
41246
|
-
|
|
41247
|
-
|
|
41248
|
-
|
|
41249
|
-
|
|
41250
|
-
|
|
41251
|
-
|
|
41252
|
-
|
|
41253
|
-
|
|
41254
|
-
|
|
41255
|
-
|
|
41256
|
-
|
|
41257
|
-
loadGitWorkflowMessage({ requireFresh: true, generationId: workflow.messageGenerationId, runId: workflow.runId, tabId: workflowTabId });
|
|
41258
|
-
} else if (workflow?.active && workflow.step === "branchNaming") {
|
|
41259
|
-
loadGitWorkflowBranchName({ requireFresh: true, retries: 3, runId: workflow.runId, tabId: workflowTabId });
|
|
41260
|
-
} else if (workflow?.active && workflow.step === "prGenerating") {
|
|
41261
|
-
loadGitWorkflowPr({ requireFresh: true, retries: 3, runId: workflow.runId, tabId: workflowTabId });
|
|
41262
|
-
}
|
|
41263
|
-
}
|
|
42205
|
+
// Settlement is the one boundary allowed to reconcile the full changed
|
|
42206
|
+
// set; it runs once here through the coalesced semantic scheduler.
|
|
42207
|
+
syncLifecycleComposerState({ force: true });
|
|
42208
|
+
scheduleSemanticReconcile({
|
|
42209
|
+
state: true,
|
|
42210
|
+
messages: true,
|
|
42211
|
+
footerData: true,
|
|
42212
|
+
feedback: true,
|
|
42213
|
+
usage: true,
|
|
42214
|
+
workflow: true,
|
|
42215
|
+
}, tabContext);
|
|
41264
42216
|
break;
|
|
41265
42217
|
case "auto_retry_start": {
|
|
41266
42218
|
const seconds = Math.max(0, Math.ceil(Number(event.delayMs || 0) / 1000));
|
|
@@ -41321,6 +42273,7 @@ function handleEvent(event) {
|
|
|
41321
42273
|
function connectEvents(tabContext = activeTabContext(), { requestedMode = "auto", fallbackAttempted = false } = {}) {
|
|
41322
42274
|
eventSource?.close();
|
|
41323
42275
|
eventSource = null;
|
|
42276
|
+
streamOutputController.cancel();
|
|
41324
42277
|
resetCompactLiveOutput();
|
|
41325
42278
|
activeOutputMode = "normal";
|
|
41326
42279
|
outputModeAcknowledged = false;
|
|
@@ -41350,6 +42303,8 @@ function connectEvents(tabContext = activeTabContext(), { requestedMode = "auto"
|
|
|
41350
42303
|
};
|
|
41351
42304
|
source.onerror = () => {
|
|
41352
42305
|
if (eventSource !== source || !isCurrentTabContext(tabContext)) return;
|
|
42306
|
+
streamOutputController.flush();
|
|
42307
|
+
streamOutputController.cancel();
|
|
41353
42308
|
if (compactOutputActive()) compactLiveScheduler.flushNow();
|
|
41354
42309
|
addEvent("event stream disconnected; browser will retry", "warn");
|
|
41355
42310
|
fetch("/api/health", { cache: "no-store" }).catch((error) => setBackendOffline(true, error));
|
|
@@ -41526,16 +42481,7 @@ elements.newTabMenu?.addEventListener("focusout", () => {
|
|
|
41526
42481
|
elements.newTabCurrentDirectoryButton?.addEventListener("click", () => createTerminalTab(currentDirectoryForNewTab(), { triggerButton: elements.newTabCurrentDirectoryButton }));
|
|
41527
42482
|
elements.newTabChooseDirectoryButton?.addEventListener("click", () => createTerminalTabFromChosenDirectory({ triggerButton: elements.newTabChooseDirectoryButton }));
|
|
41528
42483
|
elements.newTabWorktreeButton?.addEventListener("click", () => openBranchWorktreePicker());
|
|
41529
|
-
elements.splitTabButton?.addEventListener("click", () => splitActiveTerminalTab());
|
|
41530
42484
|
elements.workspaceSaveButton?.addEventListener("click", () => saveWebuiWorkspace());
|
|
41531
|
-
const openActiveSessionSummary = () => {
|
|
41532
|
-
void openSessionSummaryForTab().catch((error) => addEvent(error.message || String(error), "error"));
|
|
41533
|
-
};
|
|
41534
|
-
elements.summaryHeaderButton?.addEventListener("click", openActiveSessionSummary);
|
|
41535
|
-
elements.summaryActionButton?.addEventListener("click", () => {
|
|
41536
|
-
setComposerActionsOpen(false);
|
|
41537
|
-
openActiveSessionSummary();
|
|
41538
|
-
});
|
|
41539
42485
|
elements.terminalSplitCloseButton?.addEventListener("click", () => closeTerminalSplitView());
|
|
41540
42486
|
elements.closeAllTabsButton.addEventListener("click", () => closeAllTerminalTabs());
|
|
41541
42487
|
elements.commandPaletteButton?.addEventListener("click", () => openCommandPalette());
|
|
@@ -42013,6 +42959,8 @@ function resetAbortLongPressAffordance() {
|
|
|
42013
42959
|
async function abortActiveRun({ source = "button" } = {}) {
|
|
42014
42960
|
if (abortRequestInFlight || !isAbortAvailable()) return;
|
|
42015
42961
|
const tabContext = activeTabContext();
|
|
42962
|
+
streamOutputController.barrier("user-abort");
|
|
42963
|
+
reconcileUnknownTranscriptEvidenceAtBarrier({ type: "user_abort", tabId: tabContext.tabId });
|
|
42016
42964
|
abortRequestInFlight = true;
|
|
42017
42965
|
resetAbortLongPressAffordance();
|
|
42018
42966
|
updateComposerModeButtons();
|
|
@@ -42209,6 +43157,33 @@ elements.themeSchemeToggle?.querySelectorAll("[data-scheme-mode]").forEach((butt
|
|
|
42209
43157
|
setThemeSchemeMode(button.dataset.schemeMode, { announce: true }).catch((error) => addEvent(error.message || String(error), "error"));
|
|
42210
43158
|
});
|
|
42211
43159
|
});
|
|
43160
|
+
elements.themeCustomizeButton?.addEventListener("click", () => openThemeCustomizer().catch((error) => addEvent(error.message || String(error), "error")));
|
|
43161
|
+
elements.themeCustomizerName?.addEventListener("input", updateThemeCustomizerFromVisual);
|
|
43162
|
+
elements.themeCustomizerScope?.addEventListener("change", () => {
|
|
43163
|
+
invalidateThemeCustomizerOverwrite();
|
|
43164
|
+
updateThemeCustomizerActions();
|
|
43165
|
+
});
|
|
43166
|
+
elements.themeCustomizerThinkingMax?.addEventListener("input", updateThemeCustomizerFromVisual);
|
|
43167
|
+
elements.themeCustomizerVars?.addEventListener("input", updateThemeCustomizerFromVisual);
|
|
43168
|
+
elements.themeCustomizerJson?.addEventListener("input", updateThemeCustomizerFromJson);
|
|
43169
|
+
elements.themeCustomizerCancelButton?.addEventListener("click", () => closeThemeCustomizer({ restore: true }));
|
|
43170
|
+
elements.themeCustomizerResetButton?.addEventListener("click", resetThemeCustomizerDraft);
|
|
43171
|
+
elements.themeCustomizerSaveButton?.addEventListener("click", () => saveThemeCustomizer().catch((error) => setThemeCustomizerStatus(error.message || String(error), "error")));
|
|
43172
|
+
elements.themeCustomizerOverwriteButton?.addEventListener("click", () => saveThemeCustomizer({ overwrite: true }).catch((error) => setThemeCustomizerStatus(error.message || String(error), "error")));
|
|
43173
|
+
elements.themeCustomizerDialog?.addEventListener("cancel", (event) => {
|
|
43174
|
+
event.preventDefault();
|
|
43175
|
+
if (themeCustomizerState?.saving) {
|
|
43176
|
+
setThemeCustomizerStatus("Wait for the theme save to finish before closing.", "warn");
|
|
43177
|
+
return;
|
|
43178
|
+
}
|
|
43179
|
+
closeThemeCustomizer({ restore: true });
|
|
43180
|
+
});
|
|
43181
|
+
elements.themeCustomizerDialog?.addEventListener("close", () => {
|
|
43182
|
+
const state = themeCustomizerState;
|
|
43183
|
+
if (!state || state.closing) return;
|
|
43184
|
+
restoreThemeCustomizerOpeningState(state.generation);
|
|
43185
|
+
themeCustomizerState = null;
|
|
43186
|
+
});
|
|
42212
43187
|
if (elements.backgroundChooseButton && elements.backgroundInput) {
|
|
42213
43188
|
elements.backgroundChooseButton.addEventListener("click", () => elements.backgroundInput.click());
|
|
42214
43189
|
elements.backgroundInput.addEventListener("change", () => {
|