@firstpick/pi-package-webui 0.9.4 → 0.9.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 +7 -2
- package/bin/pi-webui.mjs +90 -5
- package/lib/optional-feature-catalog.mjs +1 -1
- package/lib/session-actions.mjs +20 -2
- package/lib/ui-layout-settings.mjs +37 -6
- package/package.json +1 -1
- package/public/app.js +2311 -257
- package/public/index.html +82 -55
- package/public/service-worker.js +4 -1
- package/public/stream-derived-output.mjs +799 -0
- package/public/stream-markdown-tail.mjs +204 -0
- package/public/stream-output-controller.mjs +222 -51
- package/public/stream-render-scheduler.mjs +85 -0
- package/public/styles.css +276 -20
- package/public/transcript-renderer.mjs +73 -24
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/composer-action-grid-reorder.spec.mjs +114 -31
- package/tests/browser/control-deck-side-panels.spec.mjs +42 -0
- package/tests/browser/control-visibility.spec.mjs +396 -0
- package/tests/browser/mobile-foundation.spec.mjs +28 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +9 -9
- package/tests/browser/stream-output-isolation.spec.mjs +308 -3
- package/tests/browser/user-noticeable-fixes.spec.mjs +204 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/composer-action-grid-reorder-static.test.mjs +8 -7
- package/tests/control-deck-side-panels-static.test.mjs +3 -1
- package/tests/control-visibility-static.test.mjs +294 -0
- package/tests/controls-layout-static.test.mjs +3 -3
- package/tests/cwd-footer-reliability-static.test.mjs +1 -1
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/file-viewer-image-static.test.mjs +3 -3
- package/tests/fixtures/fake-pi.mjs +57 -10
- package/tests/fixtures/streaming-workloads.mjs +167 -0
- package/tests/footer-provider-usage-visual-static.test.mjs +15 -0
- package/tests/foreground-transcript-catch-up-static.test.mjs +7 -1
- package/tests/git-workflow-preferences.test.mjs +2 -2
- package/tests/http-endpoints-harness.test.mjs +4 -4
- package/tests/interaction-state-stability-static.test.mjs +3 -1
- package/tests/intercom-conversation-viewer-static.test.mjs +4 -4
- package/tests/intercom-conversations-http.test.mjs +16 -0
- package/tests/main-output-loading-static.test.mjs +3 -3
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +3 -3
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +77 -66
- package/tests/open-issue-wizard-static.test.mjs +2 -2
- package/tests/persistent-ui-layout-static.test.mjs +7 -7
- package/tests/prompt-input-vertical-scroll-static.test.mjs +26 -0
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/runtime-error-visibility.test.mjs +3 -3
- package/tests/session-auth-harness.test.mjs +26 -1
- package/tests/session-sampling-ui-static.test.mjs +3 -3
- package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
- package/tests/stream-derived-output.test.mjs +121 -0
- package/tests/stream-markdown-tail.test.mjs +218 -0
- package/tests/stream-output-controller.test.mjs +119 -4
- package/tests/stream-output-isolation-static.test.mjs +34 -6
- package/tests/stream-output-workloads.test.mjs +276 -0
- package/tests/stream-render-scheduler.test.mjs +115 -0
- package/tests/streaming-ui-coupling.test.mjs +1 -1
- package/tests/subagent-observability-static.test.mjs +2 -2
- package/tests/syntax-highlighting-static.test.mjs +3 -3
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/thinking-format-parser.test.mjs +15 -0
- package/tests/todo-filter-static.test.mjs +148 -0
- package/tests/transcript-markdown-tail.test.mjs +137 -0
- package/tests/ui-layout-settings.test.mjs +54 -7
- package/tests/webui-settings-locking.test.mjs +3 -3
package/public/app.js
CHANGED
|
@@ -9,6 +9,9 @@ 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 { createStreamDerivedOutputState } from "./stream-derived-output.mjs";
|
|
13
|
+
import { advanceStreamingMarkdownTail } from "./stream-markdown-tail.mjs";
|
|
14
|
+
import { createLatestWinsRenderScheduler } from "./stream-render-scheduler.mjs";
|
|
12
15
|
import { classifyTranscriptStreamEvent, createStreamOutputController, reconcileTranscriptThinkingSnapshot } from "./stream-output-controller.mjs";
|
|
13
16
|
import { installMiddleButtonDragScroll } from "./middle-button-drag-scroll.mjs";
|
|
14
17
|
import { tokenizeCode } from "./syntax-highlight.mjs";
|
|
@@ -293,6 +296,8 @@ const elements = {
|
|
|
293
296
|
agentDoneNotificationsStatus: $("#agentDoneNotificationsStatus"),
|
|
294
297
|
optionalFeaturesBox: $("#optionalFeaturesBox"),
|
|
295
298
|
optionalFeatureMigrationSurface: $("#optionalFeatureMigrationSurface"),
|
|
299
|
+
noticeToastStack: $("#noticeToastStack"),
|
|
300
|
+
eventsUnreadBadge: $("#eventsUnreadBadge"),
|
|
296
301
|
optionalFeatureMigrationDialog: $("#optionalFeatureMigrationDialog"),
|
|
297
302
|
optionalFeatureMigrationDialogTitle: $("#optionalFeatureMigrationDialogTitle"),
|
|
298
303
|
optionalFeatureMigrationDialogMessage: $("#optionalFeatureMigrationDialogMessage"),
|
|
@@ -314,6 +319,7 @@ const elements = {
|
|
|
314
319
|
fileTreeRoot: $("#fileTreeRoot"),
|
|
315
320
|
fileTreeStatus: $("#fileTreeStatus"),
|
|
316
321
|
fileTreeRefreshButton: $("#fileTreeRefreshButton"),
|
|
322
|
+
fileTreeNewFileButton: $("#fileTreeNewFileButton"),
|
|
317
323
|
fileTreeSearchInput: $("#fileTreeSearchInput"),
|
|
318
324
|
fileTreeSearchClearButton: $("#fileTreeSearchClearButton"),
|
|
319
325
|
gitPanelGroups: $("#gitPanelGroups"),
|
|
@@ -350,6 +356,7 @@ const elements = {
|
|
|
350
356
|
fileSelectionSendButton: $("#fileSelectionSendButton"),
|
|
351
357
|
fileContextMenu: $("#fileContextMenu"),
|
|
352
358
|
sidePanelContextMenu: $("#sidePanelContextMenu"),
|
|
359
|
+
visibilityContextMenu: $("#visibilityContextMenu"),
|
|
353
360
|
gitFooterContextMenu: $("#gitFooterContextMenu"),
|
|
354
361
|
sidePanelResizeHandle: $("#sidePanelResizeHandle"),
|
|
355
362
|
sidePanelResizeHandleLeft: $("#sidePanelLeftResizeHandle"),
|
|
@@ -458,6 +465,13 @@ const elements = {
|
|
|
458
465
|
undoToastButton: $("#undoToastButton"),
|
|
459
466
|
undoToastDismissButton: $("#undoToastDismissButton"),
|
|
460
467
|
confirmationDialog: $("#confirmationDialog"),
|
|
468
|
+
textPromptDialog: $("#textPromptDialog"),
|
|
469
|
+
textPromptTitle: $("#textPromptTitle"),
|
|
470
|
+
textPromptSummary: $("#textPromptSummary"),
|
|
471
|
+
textPromptInput: $("#textPromptInput"),
|
|
472
|
+
textPromptError: $("#textPromptError"),
|
|
473
|
+
textPromptCancelButton: $("#textPromptCancelButton"),
|
|
474
|
+
textPromptConfirmButton: $("#textPromptConfirmButton"),
|
|
461
475
|
confirmationTitle: $("#confirmationTitle"),
|
|
462
476
|
confirmationSummary: $("#confirmationSummary"),
|
|
463
477
|
confirmationAffected: $("#confirmationAffected"),
|
|
@@ -636,9 +650,18 @@ const promptRoutingTabs = new Set();
|
|
|
636
650
|
let tabSeenCompletionSerials = new Map();
|
|
637
651
|
let streamBubble = null;
|
|
638
652
|
let streamText = null;
|
|
653
|
+
// Controls-panel Model / Thinking selections the user has made but not applied yet. While set,
|
|
654
|
+
// status refreshes must not snap the selects back to the live value.
|
|
655
|
+
let controlsPendingModelValue = "";
|
|
656
|
+
let controlsPendingThinkingValue = "";
|
|
657
|
+
const PATH_SUGGEST_DEBOUNCE_MS = 120;
|
|
658
|
+
const NOTICE_TOAST_LIMIT = 3;
|
|
659
|
+
const NOTICE_TOAST_TIMEOUT_MS = { info: 5000, success: 5000, warn: 6000, error: 10000 };
|
|
660
|
+
const noticeToasts = [];
|
|
661
|
+
let eventsUnreadCount = 0;
|
|
639
662
|
let streamRawText = "";
|
|
640
663
|
let streamThinkingRawText = "";
|
|
641
|
-
let
|
|
664
|
+
let streamDerivedOutputState = null;
|
|
642
665
|
let streamBubbleVisibleSince = 0;
|
|
643
666
|
let streamBubbleHideTimer = null;
|
|
644
667
|
let streamToolCallSeen = false;
|
|
@@ -668,7 +691,7 @@ const STREAM_ISOLATION_DEBUG_LIMIT = 4096;
|
|
|
668
691
|
const STREAM_ISOLATION_DEBUG_ENABLED = globalThis.__PI_STREAM_ISOLATION_DEBUG__ === true
|
|
669
692
|
|| new URLSearchParams(window.location.search).get("streamIsolationDebug") === "1";
|
|
670
693
|
const streamIsolationDebugLedger = STREAM_ISOLATION_DEBUG_ENABLED ? {
|
|
671
|
-
version:
|
|
694
|
+
version: 2,
|
|
672
695
|
counters: {
|
|
673
696
|
receivedEvents: 0,
|
|
674
697
|
appliedEvents: 0,
|
|
@@ -680,7 +703,32 @@ const streamIsolationDebugLedger = STREAM_ISOLATION_DEBUG_ENABLED ? {
|
|
|
680
703
|
staleEvents: 0,
|
|
681
704
|
highWaterPendingCount: 0,
|
|
682
705
|
highWaterPendingBytes: 0,
|
|
706
|
+
// Version 2 streaming-performance baseline counters (webui-output-streaming plan, Phase 0).
|
|
707
|
+
batchLatencyMaxMs: 0,
|
|
708
|
+
batchDrainMaxMs: 0,
|
|
709
|
+
batchPaintMaxMs: 0,
|
|
710
|
+
transcriptNodeMax: 0,
|
|
711
|
+
currentMessageNodeMax: 0,
|
|
712
|
+
deriveCalls: 0,
|
|
713
|
+
deriveMaxBytes: 0,
|
|
714
|
+
deriveMaxMs: 0,
|
|
715
|
+
tokenizeCalls: 0,
|
|
716
|
+
tokenizeMaxBytes: 0,
|
|
717
|
+
tokenizeMaxMs: 0,
|
|
718
|
+
markdownCommits: 0,
|
|
719
|
+
markdownCommitMaxMs: 0,
|
|
720
|
+
tailMaxBytes: 0,
|
|
721
|
+
longTasks: 0,
|
|
722
|
+
longAnimationFrames: 0,
|
|
723
|
+
focusLossNearStreamBatch: 0,
|
|
724
|
+
detachedScrollMoves: 0,
|
|
725
|
+
renderSchedulerFlushes: 0,
|
|
726
|
+
renderSchedulerDefers: 0,
|
|
727
|
+
pressureDeferred: 0,
|
|
728
|
+
pressureSynchronousFallbacks: 0,
|
|
683
729
|
},
|
|
730
|
+
lastBatchAppliedAt: 0,
|
|
731
|
+
lastChatScrollTop: undefined,
|
|
684
732
|
receivedIndexes: [],
|
|
685
733
|
appliedIndexes: [],
|
|
686
734
|
records: [],
|
|
@@ -714,12 +762,22 @@ function recordStreamIsolationDiagnostic(record) {
|
|
|
714
762
|
if (record.kind === "unknown-message-update") counters.unknownEvents += Number(record.sourceCount) || 1;
|
|
715
763
|
} else if (record.type === "batch") {
|
|
716
764
|
counters.batches += 1;
|
|
765
|
+
counters.batchLatencyMaxMs = Math.max(counters.batchLatencyMaxMs, Number(record.maxAgeMs) || 0);
|
|
766
|
+
counters.batchDrainMaxMs = Math.max(counters.batchDrainMaxMs, Number(record.drainMs) || 0);
|
|
767
|
+
ledger.lastBatchAppliedAt = performance.now();
|
|
768
|
+
scheduleStreamPaintDiagnostic(record);
|
|
717
769
|
} else if (record.type === "barrier") {
|
|
718
770
|
counters.barriers += 1;
|
|
719
771
|
} else if (record.type === "overflow") {
|
|
720
772
|
counters.overflows += 1;
|
|
721
773
|
} else if (record.type === "stale") {
|
|
722
774
|
counters.staleEvents += 1;
|
|
775
|
+
} else if (record.type === "render-scheduler") {
|
|
776
|
+
if (record.action === "flush") counters.renderSchedulerFlushes += 1;
|
|
777
|
+
else if (record.action === "defer") counters.renderSchedulerDefers += 1;
|
|
778
|
+
} else if (record.type === "pressure") {
|
|
779
|
+
if (record.action === "deferred") counters.pressureDeferred += 1;
|
|
780
|
+
else if (record.action === "synchronous-fallback") counters.pressureSynchronousFallbacks += 1;
|
|
723
781
|
}
|
|
724
782
|
if (record.type === "queued") {
|
|
725
783
|
counters.highWaterPendingCount = Math.max(counters.highWaterPendingCount, Number(record.pendingCount) || 0);
|
|
@@ -731,12 +789,168 @@ function recordStreamIsolationDiagnostic(record) {
|
|
|
731
789
|
});
|
|
732
790
|
}
|
|
733
791
|
|
|
792
|
+
/**
|
|
793
|
+
* Streaming-performance profile records for the opt-in debug ledger. Every
|
|
794
|
+
* caller guards on `streamIsolationDebugLedger` before doing measurement work,
|
|
795
|
+
* so the disabled hot path pays only one falsy check per instrumented site.
|
|
796
|
+
*/
|
|
797
|
+
function streamDiagnosticBytes(value) {
|
|
798
|
+
// Match the controller's conservative UTF-16 queue accounting.
|
|
799
|
+
return String(value || "").length * 2;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
function recordStreamProfileDiagnostic(record) {
|
|
803
|
+
const ledger = streamIsolationDebugLedger;
|
|
804
|
+
if (!ledger || !record) return;
|
|
805
|
+
const counters = ledger.counters;
|
|
806
|
+
if (record.type === "derive") {
|
|
807
|
+
counters.deriveCalls += 1;
|
|
808
|
+
counters.deriveMaxBytes = Math.max(counters.deriveMaxBytes, Number(record.bytes) || 0);
|
|
809
|
+
counters.deriveMaxMs = Math.max(counters.deriveMaxMs, Number(record.ms) || 0);
|
|
810
|
+
} else if (record.type === "tokenize") {
|
|
811
|
+
counters.tokenizeCalls += 1;
|
|
812
|
+
counters.tokenizeMaxBytes = Math.max(counters.tokenizeMaxBytes, Number(record.bytes) || 0);
|
|
813
|
+
counters.tokenizeMaxMs = Math.max(counters.tokenizeMaxMs, Number(record.ms) || 0);
|
|
814
|
+
} else if (record.type === "markdown-commit") {
|
|
815
|
+
counters.markdownCommits += 1;
|
|
816
|
+
counters.markdownCommitMaxMs = Math.max(counters.markdownCommitMaxMs, Number(record.ms) || 0);
|
|
817
|
+
counters.tailMaxBytes = Math.max(counters.tailMaxBytes, Number(record.tailBytes) || 0);
|
|
818
|
+
} else if (record.type === "paint-opportunity") {
|
|
819
|
+
counters.batchPaintMaxMs = Math.max(counters.batchPaintMaxMs, Number(record.ms) || 0);
|
|
820
|
+
counters.transcriptNodeMax = Math.max(counters.transcriptNodeMax, Number(record.transcriptNodes) || 0);
|
|
821
|
+
counters.currentMessageNodeMax = Math.max(counters.currentMessageNodeMax, Number(record.currentMessageNodes) || 0);
|
|
822
|
+
} else if (record.type === "longtask") {
|
|
823
|
+
counters.longTasks += 1;
|
|
824
|
+
} else if (record.type === "long-animation-frame") {
|
|
825
|
+
counters.longAnimationFrames += 1;
|
|
826
|
+
} else if (record.type === "focus-loss") {
|
|
827
|
+
counters.focusLossNearStreamBatch += 1;
|
|
828
|
+
} else if (record.type === "detached-scroll") {
|
|
829
|
+
counters.detachedScrollMoves += 1;
|
|
830
|
+
}
|
|
831
|
+
appendBoundedStreamDiagnostic(ledger.records, record);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
function scheduleStreamPaintDiagnostic(batchRecord) {
|
|
835
|
+
if (!streamIsolationDebugLedger || typeof requestAnimationFrame !== "function") return;
|
|
836
|
+
const scheduledAt = performance.now();
|
|
837
|
+
requestAnimationFrame(() => {
|
|
838
|
+
const activeMessage = streamBubble?.isConnected
|
|
839
|
+
? streamBubble
|
|
840
|
+
: streamThinkingBubble?.isConnected
|
|
841
|
+
? streamThinkingBubble
|
|
842
|
+
: compactTextBubble?.isConnected
|
|
843
|
+
? compactTextBubble
|
|
844
|
+
: compactThinkingBubble?.isConnected
|
|
845
|
+
? compactThinkingBubble
|
|
846
|
+
: null;
|
|
847
|
+
recordStreamProfileDiagnostic({
|
|
848
|
+
type: "paint-opportunity",
|
|
849
|
+
ms: (Number(batchRecord.maxAgeMs) || 0) + Math.max(0, performance.now() - scheduledAt),
|
|
850
|
+
transcriptNodes: elements.chat.querySelectorAll("*").length,
|
|
851
|
+
currentMessageNodes: activeMessage?.querySelectorAll?.("*").length || 0,
|
|
852
|
+
});
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* Detached-mode movement tracking: while the user owns the scroll position,
|
|
858
|
+
* any chat scroll change right after a stream batch that is not explained by
|
|
859
|
+
* user intent or a recent programmatic follow write is recorded as a
|
|
860
|
+
* regression candidate. Runs only when the debug ledger is enabled.
|
|
861
|
+
*/
|
|
862
|
+
function noteDetachedChatScrollMovement() {
|
|
863
|
+
const ledger = streamIsolationDebugLedger;
|
|
864
|
+
if (!ledger) return;
|
|
865
|
+
const previousTop = ledger.lastChatScrollTop;
|
|
866
|
+
const currentTop = elements.chat.scrollTop;
|
|
867
|
+
ledger.lastChatScrollTop = currentTop;
|
|
868
|
+
if (autoFollowChat || previousTop === undefined) return;
|
|
869
|
+
if (isChatUserScrollIntentActive()) return;
|
|
870
|
+
if (performance.now() - lastChatProgrammaticScrollAt <= CHAT_PROGRAMMATIC_SCROLL_GRACE_MS) return;
|
|
871
|
+
const lastBatch = ledger.lastBatchAppliedAt || 0;
|
|
872
|
+
if (!lastBatch || performance.now() - lastBatch > 250) return;
|
|
873
|
+
const deltaTop = currentTop - previousTop;
|
|
874
|
+
if (deltaTop !== 0) recordStreamProfileDiagnostic({ type: "detached-scroll", deltaTop });
|
|
875
|
+
}
|
|
876
|
+
|
|
734
877
|
if (streamIsolationDebugLedger) {
|
|
735
878
|
Object.defineProperty(globalThis, "__piStreamIsolationDebug", {
|
|
736
879
|
configurable: true,
|
|
737
880
|
enumerable: false,
|
|
738
881
|
value: streamIsolationDebugLedger,
|
|
739
882
|
});
|
|
883
|
+
try {
|
|
884
|
+
const longTaskObserver = new PerformanceObserver((list) => {
|
|
885
|
+
for (const entry of list.getEntries()) recordStreamProfileDiagnostic({ type: "longtask", ms: entry.duration });
|
|
886
|
+
});
|
|
887
|
+
longTaskObserver.observe({ type: "longtask", buffered: false });
|
|
888
|
+
} catch {
|
|
889
|
+
// Long-task timing is unsupported in this browser; counters stay at zero.
|
|
890
|
+
}
|
|
891
|
+
try {
|
|
892
|
+
const longFrameObserver = new PerformanceObserver((list) => {
|
|
893
|
+
for (const entry of list.getEntries()) recordStreamProfileDiagnostic({ type: "long-animation-frame", ms: entry.duration });
|
|
894
|
+
});
|
|
895
|
+
longFrameObserver.observe({ type: "long-animation-frame", buffered: false });
|
|
896
|
+
} catch {
|
|
897
|
+
// Long-animation-frame timing is unsupported in this browser.
|
|
898
|
+
}
|
|
899
|
+
document.addEventListener("focusout", (event) => {
|
|
900
|
+
if (event.target !== elements.promptInput) return;
|
|
901
|
+
const lastBatch = streamIsolationDebugLedger.lastBatchAppliedAt || 0;
|
|
902
|
+
if (!lastBatch) return;
|
|
903
|
+
const msSinceBatch = performance.now() - lastBatch;
|
|
904
|
+
if (msSinceBatch <= 250) recordStreamProfileDiagnostic({ type: "focus-loss", msSinceBatch });
|
|
905
|
+
}, true);
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
let normalStreamFollowPending = false;
|
|
909
|
+
const normalStreamSchedulerDiagnostic = streamIsolationDebugLedger ? recordStreamIsolationDiagnostic : undefined;
|
|
910
|
+
const assistantStreamRenderScheduler = createLatestWinsRenderScheduler({
|
|
911
|
+
render: (options) => {
|
|
912
|
+
renderStreamingAssistantText(options);
|
|
913
|
+
completeNormalStreamScheduledRender();
|
|
914
|
+
},
|
|
915
|
+
onDiagnostic: normalStreamSchedulerDiagnostic,
|
|
916
|
+
});
|
|
917
|
+
const thinkingStreamRenderScheduler = createLatestWinsRenderScheduler({
|
|
918
|
+
render: (options = {}) => {
|
|
919
|
+
if (streamThinkingRawText) setStreamingThinkingText(streamThinkingRawText, options);
|
|
920
|
+
if (options.complete) streamThinkingBubble?.classList.add("complete");
|
|
921
|
+
completeNormalStreamScheduledRender();
|
|
922
|
+
},
|
|
923
|
+
onDiagnostic: normalStreamSchedulerDiagnostic,
|
|
924
|
+
});
|
|
925
|
+
|
|
926
|
+
function normalStreamRenderPending() {
|
|
927
|
+
return assistantStreamRenderScheduler.pending() || thinkingStreamRenderScheduler.pending();
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
function completeNormalStreamScheduledRender() {
|
|
931
|
+
if (!normalStreamFollowPending || normalStreamRenderPending()) return;
|
|
932
|
+
normalStreamFollowPending = false;
|
|
933
|
+
scheduleChatFollowScroll();
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
function requestNormalStreamFollowAfterRender() {
|
|
937
|
+
if (normalStreamRenderPending()) {
|
|
938
|
+
normalStreamFollowPending = true;
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
scheduleChatFollowScroll();
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
function flushNormalStreamRenders(reason = "semantic") {
|
|
945
|
+
assistantStreamRenderScheduler.flushNow(reason);
|
|
946
|
+
thinkingStreamRenderScheduler.flushNow(reason);
|
|
947
|
+
completeNormalStreamScheduledRender();
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
function cancelNormalStreamRenders() {
|
|
951
|
+
assistantStreamRenderScheduler.cancel();
|
|
952
|
+
thinkingStreamRenderScheduler.cancel();
|
|
953
|
+
normalStreamFollowPending = false;
|
|
740
954
|
}
|
|
741
955
|
|
|
742
956
|
const streamOutputController = createStreamOutputController({
|
|
@@ -758,7 +972,7 @@ const streamOutputController = createStreamOutputController({
|
|
|
758
972
|
applyStreamError: (event) => handleMessageUpdate(event),
|
|
759
973
|
applyFollowScroll: () => {
|
|
760
974
|
if (compactOutputActive()) flushCompactLiveOutput();
|
|
761
|
-
|
|
975
|
+
else requestNormalStreamFollowAfterRender();
|
|
762
976
|
},
|
|
763
977
|
onUnknownStreamEvent: preserveUnknownTranscriptEvidence,
|
|
764
978
|
onDiagnostic: streamIsolationDebugLedger ? recordStreamIsolationDiagnostic : undefined,
|
|
@@ -767,6 +981,7 @@ let assistantErrorSurfacedThisRun = false;
|
|
|
767
981
|
let runIndicatorBubble = null;
|
|
768
982
|
let runIndicatorText = null;
|
|
769
983
|
let runIndicatorMeta = null;
|
|
984
|
+
let runIndicatorElapsed = null;
|
|
770
985
|
let runIndicatorTimer = null;
|
|
771
986
|
let runIndicatorRenderFrame = null;
|
|
772
987
|
let runIndicatorRenderScroll = false;
|
|
@@ -1317,7 +1532,9 @@ const UPDATE_STATUS_INITIAL_DELAY_MS = 1800;
|
|
|
1317
1532
|
const RUN_INDICATOR_TICK_MS = 1000;
|
|
1318
1533
|
const RUN_INDICATOR_START_GRACE_MS = 2500;
|
|
1319
1534
|
const RUN_INDICATOR_STATE_RECHECK_MS = 5000;
|
|
1320
|
-
const ABORT_LONG_PRESS_MS =
|
|
1535
|
+
const ABORT_LONG_PRESS_MS = 1200;
|
|
1536
|
+
const ABORT_TAP_HINT_MS = 1800;
|
|
1537
|
+
let abortTapHintTimer = null;
|
|
1321
1538
|
const ABORT_LONG_PRESS_TICK_MS = 100;
|
|
1322
1539
|
const ABORT_LONG_PRESS_RELEASE_GRACE_MS = 350;
|
|
1323
1540
|
const EMPTY_PROMPT_ESCAPE_AFTER_ABORT_GRACE_MS = 1000;
|
|
@@ -1490,6 +1707,55 @@ function persistMobileContinuityState() {
|
|
|
1490
1707
|
function scheduleMobileContinuityPersist() {
|
|
1491
1708
|
clearTimeout(mobileContinuityPersistTimer);
|
|
1492
1709
|
mobileContinuityPersistTimer = setTimeout(persistMobileContinuityState, MOBILE_CONTINUITY_PERSIST_DEBOUNCE_MS);
|
|
1710
|
+
scheduleDesktopDraftPersist();
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
// Desktop draft continuity: composer text per tab survives reloads and browser restarts (the
|
|
1714
|
+
// mobile v2 shell has its own richer continuity store; this covers everything else).
|
|
1715
|
+
const DESKTOP_DRAFT_STORAGE_KEY = "pi-webui-composer-drafts-v1";
|
|
1716
|
+
const DESKTOP_DRAFT_PERSIST_DEBOUNCE_MS = 500;
|
|
1717
|
+
const DESKTOP_DRAFT_MAX_TABS = 24;
|
|
1718
|
+
let desktopDraftPersistTimer = null;
|
|
1719
|
+
|
|
1720
|
+
function persistDesktopDrafts() {
|
|
1721
|
+
clearTimeout(desktopDraftPersistTimer);
|
|
1722
|
+
desktopDraftPersistTimer = null;
|
|
1723
|
+
if (isMobileShellV2Active()) return;
|
|
1724
|
+
if (activeTabId && elements.promptInput) tabDrafts.set(activeTabId, elements.promptInput.value || "");
|
|
1725
|
+
const liveIds = new Set(tabs.map((tab) => tab.id));
|
|
1726
|
+
const drafts = {};
|
|
1727
|
+
let count = 0;
|
|
1728
|
+
for (const [tabId, draft] of tabDrafts) {
|
|
1729
|
+
if (!liveIds.has(tabId) || !draft || count >= DESKTOP_DRAFT_MAX_TABS) continue;
|
|
1730
|
+
drafts[tabId] = String(draft).slice(0, 200_000);
|
|
1731
|
+
count += 1;
|
|
1732
|
+
}
|
|
1733
|
+
try {
|
|
1734
|
+
if (count === 0) localStorage.removeItem(DESKTOP_DRAFT_STORAGE_KEY);
|
|
1735
|
+
else localStorage.setItem(DESKTOP_DRAFT_STORAGE_KEY, JSON.stringify({ v: 1, drafts, savedAt: Date.now() }));
|
|
1736
|
+
} catch {
|
|
1737
|
+
// Storage may be unavailable (private mode / quota); drafts then live for this page only.
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
function scheduleDesktopDraftPersist() {
|
|
1742
|
+
clearTimeout(desktopDraftPersistTimer);
|
|
1743
|
+
desktopDraftPersistTimer = setTimeout(persistDesktopDrafts, DESKTOP_DRAFT_PERSIST_DEBOUNCE_MS);
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
function restoreDesktopDrafts() {
|
|
1747
|
+
if (isMobileShellV2Active()) return;
|
|
1748
|
+
let stored = null;
|
|
1749
|
+
try {
|
|
1750
|
+
stored = JSON.parse(localStorage.getItem(DESKTOP_DRAFT_STORAGE_KEY) || "null");
|
|
1751
|
+
} catch {
|
|
1752
|
+
stored = null;
|
|
1753
|
+
}
|
|
1754
|
+
if (!stored || stored.v !== 1 || !stored.drafts || typeof stored.drafts !== "object") return;
|
|
1755
|
+
const liveIds = new Set(tabs.map((tab) => tab.id));
|
|
1756
|
+
for (const [tabId, draft] of Object.entries(stored.drafts)) {
|
|
1757
|
+
if (liveIds.has(tabId) && !tabDrafts.get(tabId) && typeof draft === "string" && draft) tabDrafts.set(tabId, draft);
|
|
1758
|
+
}
|
|
1493
1759
|
}
|
|
1494
1760
|
|
|
1495
1761
|
function restoreMobileContinuityState() {
|
|
@@ -4043,7 +4309,6 @@ function moveSidePanelSectionRelative(fromId, targetRecord, insertBefore, target
|
|
|
4043
4309
|
|
|
4044
4310
|
function completeControlDeckSectionSideMove(record, side) {
|
|
4045
4311
|
if (!record) return;
|
|
4046
|
-
if (!record.section.classList.contains("collapsed")) setOnlySidePanelSectionExpanded(record);
|
|
4047
4312
|
const sideRecords = sidePanelSectionRecords()
|
|
4048
4313
|
.filter(({ id, section }) => !section.hidden && controlDeckSectionSide(id) === side)
|
|
4049
4314
|
.sort((a, b) => controlDeckLayout.sectionLayout.order.indexOf(a.id) - controlDeckLayout.sectionLayout.order.indexOf(b.id));
|
|
@@ -4235,6 +4500,8 @@ function setSidePanelSectionCollapsed(record, collapsed, { persist = true } = {}
|
|
|
4235
4500
|
record.content.hidden = collapsed;
|
|
4236
4501
|
record.button.setAttribute("aria-expanded", collapsed ? "false" : "true");
|
|
4237
4502
|
updateSidePanelSectionEditAffordance(record);
|
|
4503
|
+
if (!collapsed && record.id === "events") clearUnreadEvents();
|
|
4504
|
+
if (!collapsed && record.id === "subagents") queueMicrotask(() => revealSubagentLaunchSlotConfigIfDeferred());
|
|
4238
4505
|
if (!collapsed && record.id === "git" && !record.section.hidden) {
|
|
4239
4506
|
queueMicrotask(() => {
|
|
4240
4507
|
renderGitPanel();
|
|
@@ -4257,18 +4524,13 @@ function setOnlySidePanelSectionExpanded(targetRecord, { persist = true } = {})
|
|
|
4257
4524
|
if (persist) persistSidePanelSectionState();
|
|
4258
4525
|
}
|
|
4259
4526
|
|
|
4527
|
+
// Sections open and close independently (any number may be expanded at once); the persisted
|
|
4528
|
+
// collapsed set is honored as-is. With no stored state every section starts collapsed.
|
|
4260
4529
|
function restoreSidePanelSectionState() {
|
|
4261
4530
|
const records = sidePanelSectionRecords();
|
|
4262
4531
|
const collapsedIds = readStoredSidePanelSectionCollapsedIds();
|
|
4263
|
-
const expandedBySide = new Map();
|
|
4264
|
-
if (collapsedIds) {
|
|
4265
|
-
for (const record of records) {
|
|
4266
|
-
const side = controlDeckSectionSide(record.id);
|
|
4267
|
-
if (!collapsedIds.has(record.id) && !expandedBySide.has(side)) expandedBySide.set(side, record.id);
|
|
4268
|
-
}
|
|
4269
|
-
}
|
|
4270
4532
|
for (const record of records) {
|
|
4271
|
-
setSidePanelSectionCollapsed(record,
|
|
4533
|
+
setSidePanelSectionCollapsed(record, collapsedIds ? collapsedIds.has(record.id) : true, { persist: false });
|
|
4272
4534
|
}
|
|
4273
4535
|
}
|
|
4274
4536
|
|
|
@@ -4331,11 +4593,7 @@ function bindSidePanelSectionToggles() {
|
|
|
4331
4593
|
event.preventDefault();
|
|
4332
4594
|
return;
|
|
4333
4595
|
}
|
|
4334
|
-
|
|
4335
|
-
setOnlySidePanelSectionExpanded(record);
|
|
4336
|
-
} else {
|
|
4337
|
-
setSidePanelSectionCollapsed(record, true);
|
|
4338
|
-
}
|
|
4596
|
+
setSidePanelSectionCollapsed(record, !record.section.classList.contains("collapsed"));
|
|
4339
4597
|
});
|
|
4340
4598
|
record.button.addEventListener("keydown", (event) => {
|
|
4341
4599
|
if (!isSidePanelSectionReorderingEnabled() || !event.altKey || !["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(event.key)) return;
|
|
@@ -4482,13 +4740,48 @@ function persistComposerActionSlotLayout() {
|
|
|
4482
4740
|
markDurableUiLayoutDirty("composerActions");
|
|
4483
4741
|
}
|
|
4484
4742
|
|
|
4485
|
-
function
|
|
4486
|
-
const
|
|
4487
|
-
const
|
|
4488
|
-
|
|
4489
|
-
const
|
|
4490
|
-
|
|
4491
|
-
|
|
4743
|
+
function projectComposerActionSlots(entries, sourceColumns, targetColumns) {
|
|
4744
|
+
const projected = new Map();
|
|
4745
|
+
const chunks = [];
|
|
4746
|
+
let chunk = [];
|
|
4747
|
+
const flushChunk = () => {
|
|
4748
|
+
if (chunk.length) chunks.push(chunk);
|
|
4749
|
+
chunk = [];
|
|
4750
|
+
};
|
|
4751
|
+
|
|
4752
|
+
for (const entry of entries) {
|
|
4753
|
+
const sourceRow = Math.floor(entry.storedSlot / sourceColumns);
|
|
4754
|
+
const sourceColumn = entry.storedSlot % sourceColumns;
|
|
4755
|
+
const sourceEnd = sourceColumn + entry.record.span;
|
|
4756
|
+
const first = chunk[0];
|
|
4757
|
+
const previous = chunk.at(-1);
|
|
4758
|
+
const continuesChunk = !!first
|
|
4759
|
+
&& first.sourceRow === sourceRow
|
|
4760
|
+
&& sourceColumn <= previous.sourceEnd + 1
|
|
4761
|
+
&& sourceEnd - first.sourceColumn <= targetColumns;
|
|
4762
|
+
if (chunk.length && !continuesChunk) flushChunk();
|
|
4763
|
+
chunk.push({ ...entry, sourceRow, sourceColumn, sourceEnd });
|
|
4764
|
+
}
|
|
4765
|
+
flushChunk();
|
|
4766
|
+
|
|
4767
|
+
let lastTargetRow = -1;
|
|
4768
|
+
let lastTargetEnd = 0;
|
|
4769
|
+
for (const entriesInChunk of chunks) {
|
|
4770
|
+
const sourceRow = entriesInChunk[0].sourceRow;
|
|
4771
|
+
const sourceStart = entriesInChunk[0].sourceColumn;
|
|
4772
|
+
const sourceEnd = Math.max(...entriesInChunk.map((entry) => entry.sourceEnd));
|
|
4773
|
+
const chunkWidth = sourceEnd - sourceStart;
|
|
4774
|
+
const targetStart = Math.max(0, Math.min(sourceStart, targetColumns - chunkWidth));
|
|
4775
|
+
let targetRow = Math.max(sourceRow, lastTargetRow);
|
|
4776
|
+
if (targetRow === lastTargetRow && targetStart < lastTargetEnd) targetRow += 1;
|
|
4777
|
+
for (const entry of entriesInChunk) {
|
|
4778
|
+
const targetColumn = targetStart + (entry.sourceColumn - sourceStart);
|
|
4779
|
+
projected.set(entry.id, targetRow * targetColumns + targetColumn);
|
|
4780
|
+
}
|
|
4781
|
+
lastTargetRow = targetRow;
|
|
4782
|
+
lastTargetEnd = targetStart + chunkWidth;
|
|
4783
|
+
}
|
|
4784
|
+
return projected;
|
|
4492
4785
|
}
|
|
4493
4786
|
|
|
4494
4787
|
function nearestAvailableComposerActionSlot(record, preferredSlot, layout, columns) {
|
|
@@ -4519,16 +4812,23 @@ function restoreComposerActionSlotLayout() {
|
|
|
4519
4812
|
return;
|
|
4520
4813
|
}
|
|
4521
4814
|
const records = new Map(composerActionRecords().map((record) => [record.id, record]));
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4815
|
+
const storedEntries = [...stored.positions]
|
|
4816
|
+
.sort((a, b) => a[1] - b[1])
|
|
4817
|
+
.map(([id, storedSlot]) => ({ id, storedSlot, record: records.get(id) }))
|
|
4818
|
+
.filter(({ record }) => record && !record.root.hidden && record.root.getClientRects().length);
|
|
4819
|
+
const projectedSlots = stored.columns === columns
|
|
4820
|
+
? new Map(storedEntries.map(({ id, storedSlot }) => [id, storedSlot]))
|
|
4821
|
+
: projectComposerActionSlots(storedEntries, stored.columns, columns);
|
|
4822
|
+
for (const { id, record } of storedEntries) {
|
|
4823
|
+
const slot = nearestAvailableComposerActionSlot(record, projectedSlots.get(id), composerActionSlotLayout, columns);
|
|
4529
4824
|
if (slot !== null) composerActionSlotLayout.set(id, slot);
|
|
4530
4825
|
}
|
|
4531
4826
|
applyComposerActionSlotLayout();
|
|
4827
|
+
// Project visible actions into a dense grid without overwriting the user's
|
|
4828
|
+
// saved layout. Restoring all hidden actions restores their original slots.
|
|
4829
|
+
if (composerActionRecords().some(({ root }) => root.classList.contains("webui-user-hidden"))) {
|
|
4830
|
+
repackComposerActionSlotLayout({ persist: false });
|
|
4831
|
+
}
|
|
4532
4832
|
}
|
|
4533
4833
|
|
|
4534
4834
|
function scheduleComposerActionSlotLayoutRestore() {
|
|
@@ -4561,7 +4861,7 @@ function captureComposerActionSlotLayout() {
|
|
|
4561
4861
|
applyComposerActionSlotLayout();
|
|
4562
4862
|
}
|
|
4563
4863
|
|
|
4564
|
-
function repackComposerActionSlotLayout() {
|
|
4864
|
+
function repackComposerActionSlotLayout({ persist = true } = {}) {
|
|
4565
4865
|
if (composerActionLayoutColumns < 1) return;
|
|
4566
4866
|
const nextLayout = new Map();
|
|
4567
4867
|
let slot = 0;
|
|
@@ -4573,7 +4873,7 @@ function repackComposerActionSlotLayout() {
|
|
|
4573
4873
|
}
|
|
4574
4874
|
composerActionSlotLayout = nextLayout;
|
|
4575
4875
|
applyComposerActionSlotLayout();
|
|
4576
|
-
persistComposerActionSlotLayout();
|
|
4876
|
+
if (persist) persistComposerActionSlotLayout();
|
|
4577
4877
|
}
|
|
4578
4878
|
|
|
4579
4879
|
function syncComposerActionOrderFromSlots() {
|
|
@@ -4813,7 +5113,10 @@ function initializeComposerActionOrdering() {
|
|
|
4813
5113
|
}
|
|
4814
5114
|
window.addEventListener("resize", scheduleComposerActionSlotLayoutRestore);
|
|
4815
5115
|
for (const record of composerActionRecords()) {
|
|
4816
|
-
|
|
5116
|
+
// Send also anchors the keyboard-only visibility recovery menu.
|
|
5117
|
+
record.focusTarget.setAttribute("aria-keyshortcuts", record.id === "send"
|
|
5118
|
+
? "Alt+ArrowLeft Alt+ArrowRight Alt+ArrowUp Alt+ArrowDown ContextMenu Shift+F10"
|
|
5119
|
+
: "Alt+ArrowLeft Alt+ArrowRight Alt+ArrowUp Alt+ArrowDown");
|
|
4817
5120
|
record.focusTarget.addEventListener("keydown", (event) => {
|
|
4818
5121
|
if (isMobileView() || !event.altKey || !["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(event.key)) return;
|
|
4819
5122
|
event.preventDefault();
|
|
@@ -5355,7 +5658,7 @@ async function hydrateLoadedWorkspaceActiveTab(requestedTabId) {
|
|
|
5355
5658
|
|
|
5356
5659
|
async function saveWebuiWorkspace({ triggerButton = elements.workspaceSaveButton } = {}) {
|
|
5357
5660
|
if (!tabs.length) return;
|
|
5358
|
-
const promptedName =
|
|
5661
|
+
const promptedName = await appPromptText({ title: "Save workspace", summary: "Captures all open tabs, sessions, groups, and the active tab.", defaultValue: workspaceDefaultName(), confirmLabel: "Save workspace" });
|
|
5359
5662
|
if (promptedName === null) return;
|
|
5360
5663
|
const body = {
|
|
5361
5664
|
name: promptedName.trim() || workspaceDefaultName(),
|
|
@@ -6851,7 +7154,11 @@ function setSkillEditorStatus(message = "", level = "muted") {
|
|
|
6851
7154
|
status.hidden = !message;
|
|
6852
7155
|
}
|
|
6853
7156
|
|
|
6854
|
-
function closeSkillEditor() {
|
|
7157
|
+
async function closeSkillEditor({ force = false } = {}) {
|
|
7158
|
+
if (!force && activeSkillEditor?.dirty && elements.skillEditorDialog?.open) {
|
|
7159
|
+
if (!(await confirmDiscardEdits({ what: "unsaved skill edits", target: activeSkillEditor.path || activeSkillEditor.name || "SKILL.md" }))) return;
|
|
7160
|
+
activeSkillEditor.dirty = false;
|
|
7161
|
+
}
|
|
6855
7162
|
if (elements.skillEditorDialog?.open) elements.skillEditorDialog.close();
|
|
6856
7163
|
else activeSkillEditor = null;
|
|
6857
7164
|
}
|
|
@@ -7116,7 +7423,7 @@ function resizePromptInput() {
|
|
|
7116
7423
|
const maxHeight = Number.parseFloat(getComputedStyle(input).maxHeight);
|
|
7117
7424
|
const nextHeight = Number.isFinite(maxHeight) ? Math.min(input.scrollHeight, maxHeight) : input.scrollHeight;
|
|
7118
7425
|
input.style.height = `${Math.ceil(nextHeight)}px`;
|
|
7119
|
-
input.style.overflowY =
|
|
7426
|
+
input.style.overflowY = "auto";
|
|
7120
7427
|
}
|
|
7121
7428
|
|
|
7122
7429
|
function updateComposerModeButtons() {
|
|
@@ -7155,10 +7462,29 @@ function updateComposerModeButtons() {
|
|
|
7155
7462
|
if (elements.abortButton.getAttribute("aria-label") !== abortTitle) elements.abortButton.setAttribute("aria-label", abortTitle);
|
|
7156
7463
|
}
|
|
7157
7464
|
renderBusyPromptBehaviorTag();
|
|
7465
|
+
renderSendButtonMode(runActive);
|
|
7158
7466
|
document.body.classList.toggle("pi-run-active", runActive || abortAvailable);
|
|
7159
7467
|
scheduleComposerActionSlotLayoutRestore();
|
|
7160
7468
|
}
|
|
7161
7469
|
|
|
7470
|
+
// While Pi is running, Send does not start a new turn: it queues a follow-up or steers the active
|
|
7471
|
+
// run (per the busy-behavior tag). Say so on the button instead of silently acting differently.
|
|
7472
|
+
function renderSendButtonMode(runActive = isRunActive()) {
|
|
7473
|
+
const button = elements.sendButton;
|
|
7474
|
+
if (!button) return;
|
|
7475
|
+
const behavior = normalizeBusyPromptBehavior(busyPromptBehavior);
|
|
7476
|
+
const label = !runActive ? "Send" : behavior === "steer" ? "Steer" : "Queue";
|
|
7477
|
+
const title = !runActive
|
|
7478
|
+
? "Send prompt — Shift+F10 opens visibility options"
|
|
7479
|
+
: behavior === "steer"
|
|
7480
|
+
? "Pi is running: Enter steers the active run with this text. Change the behavior via the tag above the prompt."
|
|
7481
|
+
: "Pi is running: Enter queues this text as a follow-up. Change the behavior via the tag above the prompt.";
|
|
7482
|
+
if (button.textContent !== label) button.textContent = label;
|
|
7483
|
+
if (button.title !== title) button.title = title;
|
|
7484
|
+
button.setAttribute("aria-label", runActive ? `${label} (Send while Pi is running)` : "Send");
|
|
7485
|
+
button.classList.toggle("send-busy-mode", runActive);
|
|
7486
|
+
}
|
|
7487
|
+
|
|
7162
7488
|
function scheduleComposerModeButtonsUpdate() {
|
|
7163
7489
|
if (composerModeButtonsFrame !== null) return;
|
|
7164
7490
|
const flush = () => {
|
|
@@ -7412,6 +7738,72 @@ function appConfirm({ title = "Confirm action", summary = "Continue?", affected
|
|
|
7412
7738
|
});
|
|
7413
7739
|
}
|
|
7414
7740
|
|
|
7741
|
+
// Ask before an action would throw away unsaved edits. Resolves true when it is fine to proceed.
|
|
7742
|
+
function confirmDiscardEdits({ what = "unsaved edits", target = "" } = {}) {
|
|
7743
|
+
return appConfirm({
|
|
7744
|
+
title: `Discard ${what}?`,
|
|
7745
|
+
summary: target ? `${target} has changes that have not been saved.` : "There are changes that have not been saved.",
|
|
7746
|
+
affected: target || "The current editor contents",
|
|
7747
|
+
undoable: false,
|
|
7748
|
+
confirmLabel: "Discard changes",
|
|
7749
|
+
});
|
|
7750
|
+
}
|
|
7751
|
+
|
|
7752
|
+
// Application text prompt (replaces blocking window.prompt): resolves with the entered string,
|
|
7753
|
+
// or null when cancelled. `validate` may return an error message to keep the dialog open.
|
|
7754
|
+
let activeTextPromptResolve = null;
|
|
7755
|
+
|
|
7756
|
+
function appPromptText({ title = "Enter a value", summary = "", defaultValue = "", placeholder = "", confirmLabel = "OK", validate = null, selectRange = null } = {}) {
|
|
7757
|
+
const dialog = elements.textPromptDialog;
|
|
7758
|
+
if (!dialog?.showModal) {
|
|
7759
|
+
const value = window.prompt([title, summary].filter(Boolean).join("\n\n"), defaultValue);
|
|
7760
|
+
return Promise.resolve(value === null ? null : String(value));
|
|
7761
|
+
}
|
|
7762
|
+
if (activeTextPromptResolve) finishTextPrompt(null);
|
|
7763
|
+
elements.textPromptTitle.textContent = title;
|
|
7764
|
+
elements.textPromptSummary.textContent = summary;
|
|
7765
|
+
elements.textPromptSummary.hidden = !summary;
|
|
7766
|
+
elements.textPromptInput.value = defaultValue;
|
|
7767
|
+
elements.textPromptInput.placeholder = placeholder;
|
|
7768
|
+
elements.textPromptError.hidden = true;
|
|
7769
|
+
elements.textPromptError.textContent = "";
|
|
7770
|
+
elements.textPromptConfirmButton.textContent = confirmLabel;
|
|
7771
|
+
dialog.dataset.validate = validate ? "1" : "";
|
|
7772
|
+
textPromptValidator = typeof validate === "function" ? validate : null;
|
|
7773
|
+
return new Promise((resolve) => {
|
|
7774
|
+
activeTextPromptResolve = resolve;
|
|
7775
|
+
dialog.showModal();
|
|
7776
|
+
queueMicrotask(() => {
|
|
7777
|
+
const input = elements.textPromptInput;
|
|
7778
|
+
input.focus();
|
|
7779
|
+
if (Array.isArray(selectRange)) input.setSelectionRange(selectRange[0], selectRange[1]);
|
|
7780
|
+
else input.select();
|
|
7781
|
+
});
|
|
7782
|
+
});
|
|
7783
|
+
}
|
|
7784
|
+
|
|
7785
|
+
let textPromptValidator = null;
|
|
7786
|
+
|
|
7787
|
+
function finishTextPrompt(value) {
|
|
7788
|
+
const resolve = activeTextPromptResolve;
|
|
7789
|
+
activeTextPromptResolve = null;
|
|
7790
|
+
textPromptValidator = null;
|
|
7791
|
+
if (elements.textPromptDialog?.open) elements.textPromptDialog.close();
|
|
7792
|
+
resolve?.(value);
|
|
7793
|
+
}
|
|
7794
|
+
|
|
7795
|
+
function submitTextPrompt() {
|
|
7796
|
+
const value = String(elements.textPromptInput?.value ?? "");
|
|
7797
|
+
const problem = textPromptValidator ? textPromptValidator(value) : "";
|
|
7798
|
+
if (problem) {
|
|
7799
|
+
elements.textPromptError.textContent = String(problem);
|
|
7800
|
+
elements.textPromptError.hidden = false;
|
|
7801
|
+
elements.textPromptInput?.focus();
|
|
7802
|
+
return;
|
|
7803
|
+
}
|
|
7804
|
+
finishTextPrompt(value);
|
|
7805
|
+
}
|
|
7806
|
+
|
|
7415
7807
|
function appConfirmText(message, options = {}) {
|
|
7416
7808
|
const text = String(message || "Continue?").trim();
|
|
7417
7809
|
const [firstLine, ...rest] = text.split("\n");
|
|
@@ -8241,10 +8633,28 @@ function scopedApiPath(path, tabId = activeTabId) {
|
|
|
8241
8633
|
return `${url.pathname}${url.search}${url.hash}`;
|
|
8242
8634
|
}
|
|
8243
8635
|
|
|
8636
|
+
// Identical GET requests that overlap in time (boot fans out several refresh paths that ask for
|
|
8637
|
+
// the same catalogs) share one in-flight fetch. Callers still get their own resolved value.
|
|
8638
|
+
const inFlightGetRequests = new Map();
|
|
8639
|
+
|
|
8244
8640
|
async function api(path, { method = "GET", body, tabId = activeTabId, scoped = true, signal } = {}) {
|
|
8641
|
+
const url = scoped ? scopedApiPath(path, tabId) : path;
|
|
8642
|
+
if (method === "GET" && !signal) {
|
|
8643
|
+
const pending = inFlightGetRequests.get(url);
|
|
8644
|
+
if (pending) return pending;
|
|
8645
|
+
const request = apiUncached(url, { method, body, signal }).finally(() => {
|
|
8646
|
+
if (inFlightGetRequests.get(url) === request) inFlightGetRequests.delete(url);
|
|
8647
|
+
});
|
|
8648
|
+
inFlightGetRequests.set(url, request);
|
|
8649
|
+
return request;
|
|
8650
|
+
}
|
|
8651
|
+
return apiUncached(url, { method, body, signal });
|
|
8652
|
+
}
|
|
8653
|
+
|
|
8654
|
+
async function apiUncached(url, { method = "GET", body, signal } = {}) {
|
|
8245
8655
|
let response;
|
|
8246
8656
|
try {
|
|
8247
|
-
response = await fetch(
|
|
8657
|
+
response = await fetch(url, {
|
|
8248
8658
|
method,
|
|
8249
8659
|
headers: body === undefined ? undefined : { "content-type": "application/json" },
|
|
8250
8660
|
body: body === undefined ? undefined : JSON.stringify(body),
|
|
@@ -8988,7 +9398,22 @@ function renderAttachmentTray() {
|
|
|
8988
9398
|
const pill = make("span", "attachment-pill");
|
|
8989
9399
|
pill.title = attachment.requiresReselect ? `${attachment.name}\nReselect required; only metadata was restored.` : `${attachment.name}\n${attachment.mimeType}\n${formatBytes(attachment.size)}`;
|
|
8990
9400
|
pill.classList.toggle("requires-reselect", attachment.requiresReselect === true);
|
|
8991
|
-
|
|
9401
|
+
let icon = make("span", "attachment-pill-icon", attachmentIcon(attachment.kind));
|
|
9402
|
+
if (attachment.kind === "image" && attachment.previewUrl) {
|
|
9403
|
+
// Show the actual picture so a pasted screenshot can be checked at a glance.
|
|
9404
|
+
const thumb = make("img", "attachment-pill-thumb");
|
|
9405
|
+
thumb.src = attachment.previewUrl;
|
|
9406
|
+
thumb.alt = "";
|
|
9407
|
+
thumb.decoding = "async";
|
|
9408
|
+
thumb.loading = "lazy";
|
|
9409
|
+
const thumbButton = make("button", "attachment-pill-thumb-button");
|
|
9410
|
+
thumbButton.type = "button";
|
|
9411
|
+
thumbButton.title = `Preview ${attachment.name}`;
|
|
9412
|
+
thumbButton.setAttribute("aria-label", `Preview ${attachment.name}`);
|
|
9413
|
+
thumbButton.append(thumb);
|
|
9414
|
+
thumbButton.addEventListener("click", () => openImageLightbox(attachment.previewUrl, attachment.name));
|
|
9415
|
+
icon = thumbButton;
|
|
9416
|
+
}
|
|
8992
9417
|
const name = make("span", "attachment-pill-name", attachment.name);
|
|
8993
9418
|
const meta = make("span", "attachment-pill-meta", attachment.requiresReselect ? `${attachment.kind} · ${formatBytes(attachment.size)} · Reselect required` : `${attachment.kind} · ${formatBytes(attachment.size)}`);
|
|
8994
9419
|
const edit = !attachment.requiresReselect && isEditableTextAttachment(attachment) ? make("button", "attachment-edit-button", "Edit") : null;
|
|
@@ -9021,7 +9446,7 @@ function removeAttachment(id, tabId = activeTabId) {
|
|
|
9021
9446
|
if (index === -1) return;
|
|
9022
9447
|
const [removed] = attachments.splice(index, 1);
|
|
9023
9448
|
if (removed?.previewUrl) URL.revokeObjectURL(removed.previewUrl);
|
|
9024
|
-
if (activeTextAttachmentEditor?.tabId === tabId && activeTextAttachmentEditor?.attachmentId === id) closeTextAttachmentEditor();
|
|
9449
|
+
if (activeTextAttachmentEditor?.tabId === tabId && activeTextAttachmentEditor?.attachmentId === id) closeTextAttachmentEditor({ force: true });
|
|
9025
9450
|
if (attachments.length === 0) tabAttachments.delete(tabId);
|
|
9026
9451
|
if (tabId === activeTabId) renderAttachmentTray();
|
|
9027
9452
|
persistMobileContinuityState();
|
|
@@ -9032,7 +9457,7 @@ function clearAttachments(tabId = activeTabId) {
|
|
|
9032
9457
|
for (const attachment of attachments) {
|
|
9033
9458
|
if (attachment.previewUrl) URL.revokeObjectURL(attachment.previewUrl);
|
|
9034
9459
|
}
|
|
9035
|
-
if (activeTextAttachmentEditor?.tabId === tabId) closeTextAttachmentEditor();
|
|
9460
|
+
if (activeTextAttachmentEditor?.tabId === tabId) closeTextAttachmentEditor({ force: true });
|
|
9036
9461
|
if (tabId) tabAttachments.delete(tabId);
|
|
9037
9462
|
if (tabId === activeTabId) renderAttachmentTray();
|
|
9038
9463
|
persistMobileContinuityState();
|
|
@@ -9095,20 +9520,15 @@ function attachLongTextAsFile(text, source = "input text") {
|
|
|
9095
9520
|
return result.added > 0;
|
|
9096
9521
|
}
|
|
9097
9522
|
|
|
9098
|
-
function moveLongPromptInputToAttachment() {
|
|
9099
|
-
const text = elements.promptInput.value || "";
|
|
9100
|
-
if (!attachLongTextAsFile(text, "input text")) return false;
|
|
9101
|
-
elements.promptInput.value = "";
|
|
9102
|
-
resizePromptInput();
|
|
9103
|
-
hideCommandSuggestions();
|
|
9104
|
-
return true;
|
|
9105
|
-
}
|
|
9106
|
-
|
|
9107
9523
|
function attachmentById(tabId, id) {
|
|
9108
9524
|
return attachmentsForTab(tabId).find((attachment) => attachment.id === id) || null;
|
|
9109
9525
|
}
|
|
9110
9526
|
|
|
9111
|
-
function closeTextAttachmentEditor() {
|
|
9527
|
+
async function closeTextAttachmentEditor({ force = false } = {}) {
|
|
9528
|
+
if (!force && activeTextAttachmentEditor?.dirty && elements.attachmentTextDialog?.open) {
|
|
9529
|
+
if (!(await confirmDiscardEdits({ what: "unsaved attachment edits", target: "The attachment text" }))) return;
|
|
9530
|
+
activeTextAttachmentEditor.dirty = false;
|
|
9531
|
+
}
|
|
9112
9532
|
if (elements.attachmentTextDialog?.open) elements.attachmentTextDialog.close();
|
|
9113
9533
|
else activeTextAttachmentEditor = null;
|
|
9114
9534
|
}
|
|
@@ -9206,7 +9626,7 @@ function saveTextAttachmentEdit() {
|
|
|
9206
9626
|
attachment.previewUrl = undefined;
|
|
9207
9627
|
if (tabId === activeTabId) renderAttachmentTray();
|
|
9208
9628
|
addEvent(`updated text attachment ${attachment.name} (${formatBytes(attachment.size)})`, "info");
|
|
9209
|
-
closeTextAttachmentEditor();
|
|
9629
|
+
closeTextAttachmentEditor({ force: true });
|
|
9210
9630
|
}
|
|
9211
9631
|
|
|
9212
9632
|
function clipboardFiles(dataTransfer) {
|
|
@@ -12777,6 +13197,37 @@ async function moveFileTreeEntryToDestination(entry = {}, destinationPath = "",
|
|
|
12777
13197
|
}
|
|
12778
13198
|
}
|
|
12779
13199
|
|
|
13200
|
+
// "New file… / New folder…" for the Files panel. `entry` is the folder (or a file, whose parent
|
|
13201
|
+
// folder is used) the action was invoked on; the workspace root when invoked from the toolbar.
|
|
13202
|
+
async function createFileTreeEntry(entry = null, kind = "file") {
|
|
13203
|
+
const entryPath = normalizeFileTreePath(entry?.path || "");
|
|
13204
|
+
const parentPath = !entryPath ? "" : entry?.type === "directory" ? entryPath : entryPath.split("/").slice(0, -1).join("/");
|
|
13205
|
+
const label = kind === "directory" ? "folder" : "file";
|
|
13206
|
+
const name = await appPromptText({
|
|
13207
|
+
title: `New ${label}`,
|
|
13208
|
+
summary: `Created inside ${parentPath || "the workspace root"}. Use "/" to create it deeper (existing folders only).`,
|
|
13209
|
+
placeholder: kind === "directory" ? "folder-name" : "notes.md",
|
|
13210
|
+
confirmLabel: "Create",
|
|
13211
|
+
validate: (value) => {
|
|
13212
|
+
const text = String(value || "").trim();
|
|
13213
|
+
if (!text) return "A name is required.";
|
|
13214
|
+
if (text === "." || text === ".." || text.includes("\0")) return "That name is not allowed.";
|
|
13215
|
+
if (text.startsWith("/") || text.startsWith("..")) return "Use a path relative to this folder.";
|
|
13216
|
+
return "";
|
|
13217
|
+
},
|
|
13218
|
+
});
|
|
13219
|
+
if (name === null) return;
|
|
13220
|
+
const relative = normalizeFileTreePath([parentPath, String(name).trim()].filter(Boolean).join("/"));
|
|
13221
|
+
const tabContext = activeTabContext();
|
|
13222
|
+
const response = await api("/api/files/create", { method: "POST", body: { path: relative, type: kind }, tabId: tabContext.tabId });
|
|
13223
|
+
if (!isCurrentTabContext(tabContext)) return;
|
|
13224
|
+
const created = response.data || {};
|
|
13225
|
+
addEvent(`Created ${label} ${created.path || relative}.`, "success");
|
|
13226
|
+
if (parentPath) fileTreeState.expanded.add(parentPath);
|
|
13227
|
+
await refreshFileTreeLive(tabContext).catch(() => {});
|
|
13228
|
+
if (kind === "file") await openFileInViewer(created.path || relative);
|
|
13229
|
+
}
|
|
13230
|
+
|
|
12780
13231
|
async function moveFileTreeEntry(entry = fileContextMenuState?.entry) {
|
|
12781
13232
|
if (!entry) return;
|
|
12782
13233
|
const sourcePath = normalizeFileTreePath(entry.path || "");
|
|
@@ -12785,12 +13236,18 @@ async function moveFileTreeEntry(entry = fileContextMenuState?.entry) {
|
|
|
12785
13236
|
return;
|
|
12786
13237
|
}
|
|
12787
13238
|
const typeLabel = fileOperationTypeLabel(entry);
|
|
12788
|
-
const
|
|
12789
|
-
|
|
12790
|
-
|
|
12791
|
-
|
|
12792
|
-
`
|
|
12793
|
-
|
|
13239
|
+
const baseName = sourcePath.split("/").pop() || sourcePath;
|
|
13240
|
+
const nameStart = sourcePath.length - baseName.length;
|
|
13241
|
+
const dotIndex = baseName.lastIndexOf(".");
|
|
13242
|
+
const destinationInput = await appPromptText({
|
|
13243
|
+
title: `Move or rename ${typeLabel}`,
|
|
13244
|
+
summary: `${sourcePath} — enter a new name or a destination path inside the workspace. An existing folder receives the ${typeLabel} as a child.`,
|
|
13245
|
+
defaultValue: sourcePath,
|
|
13246
|
+
confirmLabel: "Move",
|
|
13247
|
+
// Pre-select the file name (without extension) so a plain rename is one keystroke away.
|
|
13248
|
+
selectRange: [nameStart, entry.type === "directory" || dotIndex <= 0 ? sourcePath.length : nameStart + dotIndex],
|
|
13249
|
+
validate: (value) => (String(value || "").trim() ? "" : "Destination path is required."),
|
|
13250
|
+
});
|
|
12794
13251
|
if (destinationInput === null) return;
|
|
12795
13252
|
const destinationPath = String(destinationInput || "").trim();
|
|
12796
13253
|
if (!destinationPath) {
|
|
@@ -12805,11 +13262,11 @@ async function moveFileTreeEntry(entry = fileContextMenuState?.entry) {
|
|
|
12805
13262
|
// per-user layout lives in the WebUI settings file behind
|
|
12806
13263
|
// GET/PUT /api/interface-preferences. Local writes always apply first; server
|
|
12807
13264
|
// reconciliation is non-blocking, coalesced, and revision guarded.
|
|
12808
|
-
const UI_LAYOUT_SCHEMA_VERSION =
|
|
13265
|
+
const UI_LAYOUT_SCHEMA_VERSION = 3;
|
|
12809
13266
|
const UI_LAYOUT_ENDPOINT = "/api/interface-preferences";
|
|
12810
13267
|
const UI_LAYOUT_SAVE_DEBOUNCE_MS = 250;
|
|
12811
13268
|
const UI_LAYOUT_MAX_CONFLICT_RETRIES = 1;
|
|
12812
|
-
const UI_LAYOUT_FIELDS = ["sidePanel", "composerActions", "footerScopedModelOrder", "terminalTabs", "fileViewerWidth"];
|
|
13269
|
+
const UI_LAYOUT_FIELDS = ["sidePanel", "composerActions", "controlVisibility", "footerScopedModelOrder", "terminalTabs", "fileViewerWidth"];
|
|
12813
13270
|
const UI_LAYOUT_SIDE_PANEL_FIELDS = ["placement", "sectionLayout", "collapsedSectionIds", "hiddenSectionIds", "collapsedPanels", "panelWidths"];
|
|
12814
13271
|
const REMOVED_SIDE_PANEL_SECTION_HEIGHT_STORAGE_KEY = "pi-webui-side-panel-section-heights-v1";
|
|
12815
13272
|
const UI_LAYOUT_COMPOSER_FIELDS = ["order", "grid"];
|
|
@@ -13016,6 +13473,271 @@ function collectDurableTerminalTabsLayout() {
|
|
|
13016
13473
|
};
|
|
13017
13474
|
}
|
|
13018
13475
|
|
|
13476
|
+
// --- Control visibility registry -------------------------------------------
|
|
13477
|
+
// Stable preference keys are independent of DOM ids. Each entry maps to a
|
|
13478
|
+
// static selector so user hiding composes with runtime capability gating via
|
|
13479
|
+
// the dedicated .webui-user-hidden class (never touches the hidden attribute).
|
|
13480
|
+
// Send is intentionally unregistered: it can never be hidden by preference.
|
|
13481
|
+
const CONTROL_VISIBILITY_HIDDEN_IDS_STORAGE_KEY = "pi-webui-control-visibility-hidden-ids-v1";
|
|
13482
|
+
const CONTROL_VISIBILITY_GROUP_LABELS = [
|
|
13483
|
+
["workspace", "Workspace toolbar"],
|
|
13484
|
+
["control-deck", "Control Deck"],
|
|
13485
|
+
["composer", "Composer actions"],
|
|
13486
|
+
["inputframe", "Input-frame controls"],
|
|
13487
|
+
["tags", "Input-frame tags"],
|
|
13488
|
+
];
|
|
13489
|
+
const CONTROL_VISIBILITY_CATALOG = [
|
|
13490
|
+
{ id: "workspace.save", group: "workspace", label: "Save workspace", selector: "#workspaceSaveButton" },
|
|
13491
|
+
{ id: "workspace.command-palette", group: "workspace", label: "Command palette", selector: "#commandPaletteButton" },
|
|
13492
|
+
{ id: "workspace.overview", group: "workspace", label: "Show workspace overview", selector: "#workspaceDashboardToggleButton" },
|
|
13493
|
+
{ id: "workspace.close-all-tabs", group: "workspace", label: "Close all tabs", selector: "#closeAllTabsButton" },
|
|
13494
|
+
{ id: "control-deck.sponsor", group: "control-deck", label: "Sponsor", selector: ".sponsor-link" },
|
|
13495
|
+
{ id: "control-deck.open-issue", group: "control-deck", label: "Open Issue", selector: "#openIssueButton" },
|
|
13496
|
+
{ id: "composer.new", group: "composer", label: "New", selector: '[data-composer-action-id="new"]' },
|
|
13497
|
+
{ id: "composer.compact", group: "composer", label: "Compact", selector: '[data-composer-action-id="compact"]' },
|
|
13498
|
+
{ id: "composer.guided-git", group: "composer", label: "Guided Git workflow", selector: '[data-composer-action-id="git"]' },
|
|
13499
|
+
{ id: "composer.publish", group: "composer", label: "AUR/npm release dropdown", selector: '[data-composer-action-id="publish"]' },
|
|
13500
|
+
{ id: "composer.tools-skills", group: "composer", label: "Tools/skills setup dropdown", selector: '[data-composer-action-id="native-command"]' },
|
|
13501
|
+
{ id: "composer.common-options", group: "composer", label: "Common options", selector: '[data-composer-action-id="options"]' },
|
|
13502
|
+
{ id: "composer.app-runner", group: "composer", label: "App runner", selector: '[data-composer-action-id="app-runner"]' },
|
|
13503
|
+
{ id: "composer.steer", group: "composer", label: "Steer", selector: '[data-composer-action-id="steer"]' },
|
|
13504
|
+
{ id: "composer.follow-up", group: "composer", label: "Follow-up", selector: '[data-composer-action-id="follow-up"]' },
|
|
13505
|
+
{ id: "composer.btw", group: "composer", label: "/btw side question", selector: '[data-composer-action-id="btw"]' },
|
|
13506
|
+
{ id: "input.workflow", group: "inputframe", label: "Workflow controls", selector: "#workflowModeControls" },
|
|
13507
|
+
{ id: "input.attach-files", group: "inputframe", label: "Attach files", selector: "#attachButton" },
|
|
13508
|
+
{ id: "tag.prompt-behavior", group: "tags", label: "Follow-up/Steer busy-prompt behavior tag", selector: "#busyPromptBehaviorTag" },
|
|
13509
|
+
{ id: "tag.skills", group: "tags", label: "Session skill tags", selector: "#sessionSkillTags" },
|
|
13510
|
+
{ id: "tag.agent-conversations", group: "tags", label: "Intercom agent-conversation tags", selector: "#intercomConversationTags" },
|
|
13511
|
+
{ id: "tag.feature-category", group: "tags", label: "Feature-category tag", selector: "#featureCategoryTag" },
|
|
13512
|
+
{ id: "tag.voice-mode", group: "tags", label: "Natural-conversation/voice tag", selector: "#conversationModeChip" },
|
|
13513
|
+
{ id: "tag.workflow-mode", group: "tags", label: "Workflow-mode tag", selector: "#workflowModeChip" },
|
|
13514
|
+
];
|
|
13515
|
+
const CONTROL_VISIBILITY_REGISTRY = new Map(CONTROL_VISIBILITY_CATALOG.map((entry) => [entry.id, entry]));
|
|
13516
|
+
|
|
13517
|
+
function readStoredControlVisibilityHiddenIds() {
|
|
13518
|
+
const raw = readDurableLayoutCache(CONTROL_VISIBILITY_HIDDEN_IDS_STORAGE_KEY);
|
|
13519
|
+
if (raw === null) return null;
|
|
13520
|
+
try {
|
|
13521
|
+
return durableLayoutIdList(JSON.parse(raw));
|
|
13522
|
+
} catch {
|
|
13523
|
+
return null;
|
|
13524
|
+
}
|
|
13525
|
+
}
|
|
13526
|
+
|
|
13527
|
+
function userControlHiddenIds() {
|
|
13528
|
+
const dirtyHiddenIds = durableLayoutDirtyFields.get("controlVisibility")?.value?.hiddenIds;
|
|
13529
|
+
if (dirtyHiddenIds === null || Array.isArray(dirtyHiddenIds)) return dirtyHiddenIds || [];
|
|
13530
|
+
return readStoredControlVisibilityHiddenIds() || [];
|
|
13531
|
+
}
|
|
13532
|
+
|
|
13533
|
+
// Only the preference class is managed here. A runtime `hidden` attribute
|
|
13534
|
+
// owned by capability/state gating always remains authoritative.
|
|
13535
|
+
function applyControlVisibility(hiddenIdsOverride) {
|
|
13536
|
+
// An explicit override lets this tab keep showing its own pending mutation
|
|
13537
|
+
// while another same-origin tab's cache value is still unacknowledged.
|
|
13538
|
+
const hiddenSet = new Set(hiddenIdsOverride === undefined ? userControlHiddenIds() : hiddenIdsOverride || []);
|
|
13539
|
+
let composerChanged = false;
|
|
13540
|
+
for (const entry of CONTROL_VISIBILITY_CATALOG) {
|
|
13541
|
+
const shouldHide = hiddenSet.has(entry.id);
|
|
13542
|
+
for (const element of document.querySelectorAll(entry.selector)) {
|
|
13543
|
+
const wasHidden = element.classList.contains("webui-user-hidden");
|
|
13544
|
+
element.classList.toggle("webui-user-hidden", shouldHide);
|
|
13545
|
+
// Reflow on a real state change in either direction: un-hiding must
|
|
13546
|
+
// restore saved slots, and unchanged reapplies (storage events, snapshot
|
|
13547
|
+
// adoption) must not schedule spurious repacks.
|
|
13548
|
+
if (wasHidden !== shouldHide && entry.group === "composer") composerChanged = true;
|
|
13549
|
+
}
|
|
13550
|
+
}
|
|
13551
|
+
// Hiding composer actions leaves grid holes; repack/restore the saved layout.
|
|
13552
|
+
if (composerChanged) scheduleComposerActionSlotLayoutRestore();
|
|
13553
|
+
}
|
|
13554
|
+
|
|
13555
|
+
function persistControlVisibilityHiddenIds(hiddenIds) {
|
|
13556
|
+
writeDurableLayoutCache(CONTROL_VISIBILITY_HIDDEN_IDS_STORAGE_KEY, JSON.stringify(hiddenIds ?? null));
|
|
13557
|
+
markDurableUiLayoutDirty("controlVisibility");
|
|
13558
|
+
applyControlVisibility(hiddenIds);
|
|
13559
|
+
}
|
|
13560
|
+
|
|
13561
|
+
function setControlVisibilityHidden(id, hidden) {
|
|
13562
|
+
if (!CONTROL_VISIBILITY_REGISTRY.has(id)) return;
|
|
13563
|
+
const current = userControlHiddenIds();
|
|
13564
|
+
const next = hidden ? [...new Set([...current, id])] : current.filter((entry) => entry !== id);
|
|
13565
|
+
persistControlVisibilityHiddenIds(next);
|
|
13566
|
+
}
|
|
13567
|
+
|
|
13568
|
+
function showAllControls() {
|
|
13569
|
+
persistControlVisibilityHiddenIds([]);
|
|
13570
|
+
}
|
|
13571
|
+
|
|
13572
|
+
function resetControlVisibilityDefaults() {
|
|
13573
|
+
persistControlVisibilityHiddenIds(null);
|
|
13574
|
+
}
|
|
13575
|
+
|
|
13576
|
+
let visibilityContextMenuState = null;
|
|
13577
|
+
|
|
13578
|
+
function closeVisibilityContextMenu({ returnFocus = true } = {}) {
|
|
13579
|
+
const trigger = visibilityContextMenuState?.trigger;
|
|
13580
|
+
visibilityContextMenuState = null;
|
|
13581
|
+
if (elements.visibilityContextMenu) elements.visibilityContextMenu.hidden = true;
|
|
13582
|
+
if (!returnFocus) return;
|
|
13583
|
+
const triggerSurvives = trigger
|
|
13584
|
+
&& trigger.isConnected
|
|
13585
|
+
&& !trigger.hidden
|
|
13586
|
+
&& !trigger.classList?.contains("webui-user-hidden")
|
|
13587
|
+
&& typeof trigger.focus === "function";
|
|
13588
|
+
if (triggerSurvives) trigger.focus({ preventScroll: true });
|
|
13589
|
+
else elements.promptInput?.focus({ preventScroll: true });
|
|
13590
|
+
}
|
|
13591
|
+
|
|
13592
|
+
function positionControlVisibilityMenu(clientX, clientY) {
|
|
13593
|
+
const menu = elements.visibilityContextMenu;
|
|
13594
|
+
menu.hidden = false;
|
|
13595
|
+
const rect = menu.getBoundingClientRect();
|
|
13596
|
+
const left = Math.min(clientX, Math.max(8, window.innerWidth - rect.width - 8));
|
|
13597
|
+
const top = Math.min(clientY, Math.max(8, window.innerHeight - rect.height - 8));
|
|
13598
|
+
menu.style.left = `${Math.max(8, left)}px`;
|
|
13599
|
+
menu.style.top = `${Math.max(8, top)}px`;
|
|
13600
|
+
}
|
|
13601
|
+
|
|
13602
|
+
function controlVisibilityMenuLabel(text) {
|
|
13603
|
+
const label = make("div", "control-visibility-menu-label", text);
|
|
13604
|
+
label.setAttribute("role", "presentation");
|
|
13605
|
+
label.setAttribute("aria-hidden", "true");
|
|
13606
|
+
return label;
|
|
13607
|
+
}
|
|
13608
|
+
|
|
13609
|
+
function controlVisibilityMenuAction(action, text) {
|
|
13610
|
+
const button = make("button", "control-visibility-menu-item control-visibility-menu-action", text);
|
|
13611
|
+
button.type = "button";
|
|
13612
|
+
button.setAttribute("role", "menuitem");
|
|
13613
|
+
button.dataset.visibilityMenuAction = action;
|
|
13614
|
+
return button;
|
|
13615
|
+
}
|
|
13616
|
+
|
|
13617
|
+
function prepareControlVisibilityMenu(trigger, entryId = null) {
|
|
13618
|
+
if (!elements.visibilityContextMenu) return null;
|
|
13619
|
+
closeFileContextMenu({ returnFocus: false });
|
|
13620
|
+
closeGitPanelContextMenu({ returnFocus: false });
|
|
13621
|
+
closeSidePanelContextMenu({ returnFocus: false });
|
|
13622
|
+
closeGitFooterContextMenu({ returnFocus: false });
|
|
13623
|
+
closeVisibilityContextMenu({ returnFocus: false });
|
|
13624
|
+
// Region hosts are plain non-focusable containers; storing one as the
|
|
13625
|
+
// trigger would let Escape focus fall through to <body>. Fall back to the
|
|
13626
|
+
// prompt unless the trigger can actually receive keyboard focus.
|
|
13627
|
+
const focusableTrigger = trigger
|
|
13628
|
+
&& typeof trigger.focus === "function"
|
|
13629
|
+
&& trigger.matches("button, a, input, select, textarea, [tabindex]")
|
|
13630
|
+
? trigger
|
|
13631
|
+
: elements.promptInput;
|
|
13632
|
+
visibilityContextMenuState = {
|
|
13633
|
+
trigger: focusableTrigger,
|
|
13634
|
+
entryId,
|
|
13635
|
+
openedAt: performance.now(),
|
|
13636
|
+
};
|
|
13637
|
+
return elements.visibilityContextMenu;
|
|
13638
|
+
}
|
|
13639
|
+
|
|
13640
|
+
// Right-clicking a visible registered control offers Hide <label> plus the
|
|
13641
|
+
// recovery actions; empty marked regions open the grouped full catalog.
|
|
13642
|
+
function showControlVisibilityDirectMenu(entry, directElement, { clientX, clientY }) {
|
|
13643
|
+
const menu = prepareControlVisibilityMenu(directElement, entry.id);
|
|
13644
|
+
if (!menu) return;
|
|
13645
|
+
const items = [
|
|
13646
|
+
controlVisibilityMenuLabel("Hide or restore controls"),
|
|
13647
|
+
controlVisibilityMenuAction("hide", `Hide ${entry.label}`),
|
|
13648
|
+
controlVisibilityMenuAction("show-all", "Show all"),
|
|
13649
|
+
controlVisibilityMenuAction("reset-defaults", "Reset defaults"),
|
|
13650
|
+
];
|
|
13651
|
+
menu.replaceChildren(...items);
|
|
13652
|
+
positionControlVisibilityMenu(clientX, clientY);
|
|
13653
|
+
menu.querySelector('[role="menuitem"]')?.focus({ preventScroll: true });
|
|
13654
|
+
}
|
|
13655
|
+
|
|
13656
|
+
function showControlVisibilityRegionMenu(trigger, { clientX, clientY }) {
|
|
13657
|
+
const menu = prepareControlVisibilityMenu(trigger, null);
|
|
13658
|
+
if (!menu) return;
|
|
13659
|
+
const hiddenSet = new Set(userControlHiddenIds());
|
|
13660
|
+
const children = [controlVisibilityMenuLabel("Choose visible controls")];
|
|
13661
|
+
for (const [groupId, groupLabel] of CONTROL_VISIBILITY_GROUP_LABELS) {
|
|
13662
|
+
children.push(controlVisibilityMenuLabel(groupLabel));
|
|
13663
|
+
for (const entry of CONTROL_VISIBILITY_CATALOG.filter((item) => item.group === groupId)) {
|
|
13664
|
+
const button = make("button", "control-visibility-menu-item side-panel-context-menu-item", entry.label);
|
|
13665
|
+
button.type = "button";
|
|
13666
|
+
button.setAttribute("role", "menuitemcheckbox");
|
|
13667
|
+
button.setAttribute("aria-checked", hiddenSet.has(entry.id) ? "false" : "true");
|
|
13668
|
+
button.dataset.visibilityMenuToggle = entry.id;
|
|
13669
|
+
children.push(button);
|
|
13670
|
+
}
|
|
13671
|
+
}
|
|
13672
|
+
children.push(controlVisibilityMenuAction("show-all", "Show all"));
|
|
13673
|
+
children.push(controlVisibilityMenuAction("reset-defaults", "Reset defaults"));
|
|
13674
|
+
menu.replaceChildren(...children);
|
|
13675
|
+
positionControlVisibilityMenu(clientX, clientY);
|
|
13676
|
+
menu.querySelector('[role="menuitemcheckbox"]')?.focus({ preventScroll: true });
|
|
13677
|
+
}
|
|
13678
|
+
|
|
13679
|
+
// Registered visibility targets always win; unrelated editable/input/link
|
|
13680
|
+
// contexts and existing specialized menus keep their native behavior.
|
|
13681
|
+
function handleControlVisibilityContextMenu(event) {
|
|
13682
|
+
const target = event.target;
|
|
13683
|
+
if (!(target instanceof Element)) return;
|
|
13684
|
+
if (target.closest?.(".file-context-menu, dialog, .composer-publish-menu-panel")) return;
|
|
13685
|
+
const direct = target.closest?.("[data-visibility-key]");
|
|
13686
|
+
const entry = direct ? CONTROL_VISIBILITY_REGISTRY.get(direct.dataset.visibilityKey) : null;
|
|
13687
|
+
if (entry) {
|
|
13688
|
+
event.preventDefault();
|
|
13689
|
+
event.stopPropagation();
|
|
13690
|
+
showControlVisibilityDirectMenu(entry, direct, { clientX: event.clientX, clientY: event.clientY });
|
|
13691
|
+
return;
|
|
13692
|
+
}
|
|
13693
|
+
if (target.closest?.("button, input, textarea, select, [contenteditable='true'], a")) return;
|
|
13694
|
+
const region = target.closest?.("[data-visibility-region]");
|
|
13695
|
+
if (!region) return;
|
|
13696
|
+
event.preventDefault();
|
|
13697
|
+
event.stopPropagation();
|
|
13698
|
+
showControlVisibilityRegionMenu(region, { clientX: event.clientX, clientY: event.clientY });
|
|
13699
|
+
}
|
|
13700
|
+
|
|
13701
|
+
function handleControlVisibilityKeydown(event) {
|
|
13702
|
+
if (event.key !== "ContextMenu" && !(event.shiftKey && event.key === "F10")) return;
|
|
13703
|
+
const target = event.target instanceof Element ? event.target : document.activeElement;
|
|
13704
|
+
if (!(target instanceof Element)) return;
|
|
13705
|
+
if (target.closest?.(".file-context-menu, dialog, .composer-publish-menu-panel")) return;
|
|
13706
|
+
const direct = target.closest?.("[data-visibility-key]");
|
|
13707
|
+
const entry = direct ? CONTROL_VISIBILITY_REGISTRY.get(direct.dataset.visibilityKey) : null;
|
|
13708
|
+
// Send is permanently visible and never toggleable, so from the keyboard it
|
|
13709
|
+
// doubles as the always-reachable anchor for the grouped recovery menu when
|
|
13710
|
+
// every optional control is hidden. Pointer right-click on Send stays native.
|
|
13711
|
+
const sendAnchor = entry ? null : target.closest?.("#sendButton");
|
|
13712
|
+
const anchor = direct || sendAnchor || target.closest?.("[data-visibility-region]");
|
|
13713
|
+
if (!anchor) return;
|
|
13714
|
+
if (!entry && !sendAnchor && target.closest?.("button, input, textarea, select, [contenteditable='true'], a")) return;
|
|
13715
|
+
const rect = anchor.getBoundingClientRect();
|
|
13716
|
+
const position = { clientX: rect.left + Math.min(rect.width, 24), clientY: rect.bottom };
|
|
13717
|
+
event.preventDefault();
|
|
13718
|
+
event.stopPropagation();
|
|
13719
|
+
if (entry) showControlVisibilityDirectMenu(entry, direct, position);
|
|
13720
|
+
else showControlVisibilityRegionMenu(anchor, position);
|
|
13721
|
+
}
|
|
13722
|
+
|
|
13723
|
+
function initializeControlVisibility() {
|
|
13724
|
+
applyControlVisibility();
|
|
13725
|
+
document.addEventListener("contextmenu", handleControlVisibilityContextMenu, { capture: true });
|
|
13726
|
+
document.addEventListener("keydown", handleControlVisibilityKeydown, { capture: true });
|
|
13727
|
+
document.addEventListener("pointerdown", (event) => {
|
|
13728
|
+
if (!elements.visibilityContextMenu || elements.visibilityContextMenu.hidden) return;
|
|
13729
|
+
if (!event.target?.closest?.(".control-visibility-context-menu")) closeVisibilityContextMenu({ returnFocus: false });
|
|
13730
|
+
}, { passive: true });
|
|
13731
|
+
window.addEventListener("resize", () => closeVisibilityContextMenu({ returnFocus: false }), { passive: true });
|
|
13732
|
+
document.addEventListener("scroll", () => {
|
|
13733
|
+
// Pointer-driven context-menu invocation can finish an automatic
|
|
13734
|
+
// scroll-into-view after the menu opens. Ignore that trailing event while
|
|
13735
|
+
// still dismissing the menu for subsequent user scrolling.
|
|
13736
|
+
if (!visibilityContextMenuState || performance.now() - visibilityContextMenuState.openedAt < 100) return;
|
|
13737
|
+
closeVisibilityContextMenu({ returnFocus: false });
|
|
13738
|
+
}, { capture: true, passive: true });
|
|
13739
|
+
}
|
|
13740
|
+
|
|
13019
13741
|
function collectDurableFileViewerWidth() {
|
|
13020
13742
|
const width = readStoredFileViewerWidth();
|
|
13021
13743
|
if (!Number.isFinite(width)) return null;
|
|
@@ -13029,6 +13751,8 @@ function collectDurableUiLayoutField(field) {
|
|
|
13029
13751
|
return collectDurableSidePanelLayout();
|
|
13030
13752
|
case "composerActions":
|
|
13031
13753
|
return collectDurableComposerActionsLayout();
|
|
13754
|
+
case "controlVisibility":
|
|
13755
|
+
return { hiddenIds: readStoredControlVisibilityHiddenIds() };
|
|
13032
13756
|
case "footerScopedModelOrder":
|
|
13033
13757
|
return durableLayoutStoredIdList(FOOTER_SCOPED_MODEL_ORDER_STORAGE_KEY);
|
|
13034
13758
|
case "terminalTabs":
|
|
@@ -13267,6 +13991,12 @@ function applyDurableComposerActionsLayout(value) {
|
|
|
13267
13991
|
}
|
|
13268
13992
|
}
|
|
13269
13993
|
|
|
13994
|
+
function applyDurableControlVisibility(value) {
|
|
13995
|
+
if (!value || typeof value !== "object") return;
|
|
13996
|
+
writeDurableLayoutCache(CONTROL_VISIBILITY_HIDDEN_IDS_STORAGE_KEY, JSON.stringify(value.hiddenIds ?? null));
|
|
13997
|
+
applyControlVisibility();
|
|
13998
|
+
}
|
|
13999
|
+
|
|
13270
14000
|
function applyDurableFooterScopedModelOrder(value) {
|
|
13271
14001
|
if (!Array.isArray(value)) return;
|
|
13272
14002
|
writeDurableLayoutCache(FOOTER_SCOPED_MODEL_ORDER_STORAGE_KEY, JSON.stringify(value));
|
|
@@ -13304,6 +14034,7 @@ function applyDurableFileViewerWidth(value) {
|
|
|
13304
14034
|
function applyDurableUiLayoutField(field, value) {
|
|
13305
14035
|
if (field === "sidePanel") applyDurableSidePanelLayout(value);
|
|
13306
14036
|
else if (field === "composerActions") applyDurableComposerActionsLayout(value);
|
|
14037
|
+
else if (field === "controlVisibility") applyDurableControlVisibility(value);
|
|
13307
14038
|
else if (field === "footerScopedModelOrder") applyDurableFooterScopedModelOrder(value);
|
|
13308
14039
|
else if (field === "terminalTabs") applyDurableTerminalTabsLayout(value);
|
|
13309
14040
|
else if (field === "fileViewerWidth") applyDurableFileViewerWidth(value);
|
|
@@ -13313,6 +14044,7 @@ function durableUiLayoutInteractionActive(field = null) {
|
|
|
13313
14044
|
const activeByField = {
|
|
13314
14045
|
sidePanel: Boolean(sidePanelSectionPointerDrag?.active || sidePanelResizeState),
|
|
13315
14046
|
composerActions: Boolean(composerActionPointerDrag?.active),
|
|
14047
|
+
controlVisibility: false,
|
|
13316
14048
|
footerScopedModelOrder: Boolean(footerScopedModelPointerDrag?.active),
|
|
13317
14049
|
terminalTabs: Boolean(terminalTabDragId || terminalTabsResizeState),
|
|
13318
14050
|
fileViewerWidth: Boolean(fileViewerResizeState),
|
|
@@ -13495,6 +14227,12 @@ async function flushDurableUiLayoutSave() {
|
|
|
13495
14227
|
else current.value = collectDurableUiLayoutField(field);
|
|
13496
14228
|
} else if (current.generation === entry.generation && current.mutationId === entry.mutationId) {
|
|
13497
14229
|
durableLayoutDirtyFields.delete(field);
|
|
14230
|
+
if (field === "controlVisibility") {
|
|
14231
|
+
// Another tab may have overwritten the same-origin cache while this
|
|
14232
|
+
// mutation was pending; the acknowledged value is authoritative now.
|
|
14233
|
+
writeDurableLayoutCache(CONTROL_VISIBILITY_HIDDEN_IDS_STORAGE_KEY, JSON.stringify(entry.value?.hiddenIds ?? null));
|
|
14234
|
+
applyControlVisibility();
|
|
14235
|
+
}
|
|
13498
14236
|
}
|
|
13499
14237
|
}
|
|
13500
14238
|
clearAcknowledgedDurableUiLayoutPendingMutations(snapshot);
|
|
@@ -14524,6 +15262,9 @@ async function applyGitFileChangesSnapshot(request, tabContext, viewerPath, requ
|
|
|
14524
15262
|
async function openFileInViewer(path = "", { gitCategory = "", gitPath = "" } = {}) {
|
|
14525
15263
|
const normalized = normalizeFileTreePath(path);
|
|
14526
15264
|
if (!normalized) return;
|
|
15265
|
+
if (activeFileViewer?.dirty && activeFileViewer.path !== normalized) {
|
|
15266
|
+
if (!(await confirmDiscardEdits({ what: "unsaved file edits", target: activeFileViewer.path }))) return;
|
|
15267
|
+
}
|
|
14527
15268
|
const openRequestSerial = ++fileViewerOpenRequestSerial;
|
|
14528
15269
|
const tabContext = activeTabContext();
|
|
14529
15270
|
fileTreeState.selectedPath = normalized;
|
|
@@ -15020,6 +15761,7 @@ function updateDocumentTitle() {
|
|
|
15020
15761
|
function saveActiveDraft() {
|
|
15021
15762
|
if (activeTabId) tabDrafts.set(activeTabId, elements.promptInput.value || "");
|
|
15022
15763
|
persistMobileContinuityState();
|
|
15764
|
+
persistDesktopDrafts();
|
|
15023
15765
|
}
|
|
15024
15766
|
|
|
15025
15767
|
function restoreActiveDraft() {
|
|
@@ -15180,6 +15922,8 @@ function resetActiveTabUi() {
|
|
|
15180
15922
|
clearRefreshTimers();
|
|
15181
15923
|
eventSource?.close();
|
|
15182
15924
|
eventSource = null;
|
|
15925
|
+
setControlsPendingModel("");
|
|
15926
|
+
setControlsPendingThinking("");
|
|
15183
15927
|
currentState = cachedStateForTabSwitch(activeTabId);
|
|
15184
15928
|
latestStats = activeTabId ? tabStatsCache.get(activeTabId) || null : null;
|
|
15185
15929
|
latestStatsOverlayPayload = null;
|
|
@@ -15619,6 +16363,30 @@ function showGitPanelContextMenu(event, context) {
|
|
|
15619
16363
|
menu.querySelector('[role="menuitem"]:not([disabled])')?.focus({ preventScroll: true });
|
|
15620
16364
|
}
|
|
15621
16365
|
|
|
16366
|
+
// Touch- and keyboard-discoverable entry to the same actions as the right-click menu.
|
|
16367
|
+
function gitPanelOverflowButton(context, label) {
|
|
16368
|
+
const button = make("button", "git-side-panel-overflow-button file-tree-overflow-button", "⋯");
|
|
16369
|
+
button.type = "button";
|
|
16370
|
+
button.setAttribute("aria-label", `Git actions for ${label}`);
|
|
16371
|
+
button.setAttribute("aria-haspopup", "menu");
|
|
16372
|
+
button.title = "Git actions";
|
|
16373
|
+
button.addEventListener("click", (event) => {
|
|
16374
|
+
event.stopPropagation();
|
|
16375
|
+
const rect = button.getBoundingClientRect();
|
|
16376
|
+
showGitPanelContextMenu({
|
|
16377
|
+
preventDefault: () => event.preventDefault(),
|
|
16378
|
+
stopPropagation: () => event.stopPropagation(),
|
|
16379
|
+
clientX: rect.right,
|
|
16380
|
+
clientY: rect.bottom,
|
|
16381
|
+
currentTarget: button,
|
|
16382
|
+
}, context);
|
|
16383
|
+
});
|
|
16384
|
+
button.addEventListener("keydown", (event) => {
|
|
16385
|
+
if (event.key === "Enter" || event.key === " ") event.stopPropagation();
|
|
16386
|
+
});
|
|
16387
|
+
return button;
|
|
16388
|
+
}
|
|
16389
|
+
|
|
15622
16390
|
function bindGitPanelContextMenu(trigger, context) {
|
|
15623
16391
|
trigger.setAttribute("aria-haspopup", "menu");
|
|
15624
16392
|
trigger.addEventListener("contextmenu", (event) => showGitPanelContextMenu(event, context));
|
|
@@ -15726,7 +16494,7 @@ function renderGitPanelFile(entry, card, category) {
|
|
|
15726
16494
|
const row = make("div", `git-side-panel-file ${category}`);
|
|
15727
16495
|
row.dataset.gitPanelContinuityKey = `file:${card.root}:${category}:${entry.path}`;
|
|
15728
16496
|
const fullPath = entry.oldPath ? `${entry.oldPath} → ${entry.path}` : entry.path;
|
|
15729
|
-
row.title = `${fullPath} · Open in WebUI ·
|
|
16497
|
+
row.title = `${fullPath} · Open in WebUI · ⋯ or right-click for Git actions`;
|
|
15730
16498
|
row.tabIndex = 0;
|
|
15731
16499
|
row.setAttribute("role", "button");
|
|
15732
16500
|
row.setAttribute("aria-label", `Open ${entry.name || entry.path} in WebUI, ${gitPanelStatsText(entry, category) || "no line statistics"}`);
|
|
@@ -15743,8 +16511,9 @@ function renderGitPanelFile(entry, card, category) {
|
|
|
15743
16511
|
const statsText = gitPanelStatsText(entry, category);
|
|
15744
16512
|
const stats = make("span", "git-side-panel-file-stats", statsText);
|
|
15745
16513
|
stats.hidden = !statsText;
|
|
15746
|
-
|
|
15747
|
-
row
|
|
16514
|
+
const context = { card, category, kind: "file", path: entry.path };
|
|
16515
|
+
bindGitPanelContextMenu(row, context);
|
|
16516
|
+
row.append(status, name, stats, gitPanelOverflowButton(context, entry.name || entry.path));
|
|
15748
16517
|
return row;
|
|
15749
16518
|
}
|
|
15750
16519
|
|
|
@@ -15913,7 +16682,7 @@ function renderGitPanelRepositoryCard(card) {
|
|
|
15913
16682
|
button.type = "button";
|
|
15914
16683
|
button.dataset.gitPanelContinuityKey = `repository:${card.root}`;
|
|
15915
16684
|
button.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
15916
|
-
button.title = `${expanded ? "Collapse" : "Expand"} ${card.root} ·
|
|
16685
|
+
button.title = `${expanded ? "Collapse" : "Expand"} ${card.root} · ⋯ or right-click for repository actions`;
|
|
15917
16686
|
const count = gitPanelChangeCount(snapshot?.data);
|
|
15918
16687
|
button.append(
|
|
15919
16688
|
make("span", "git-side-panel-repository-chevron", "›"),
|
|
@@ -15923,8 +16692,11 @@ function renderGitPanelRepositoryCard(card) {
|
|
|
15923
16692
|
const copy = button.querySelector(".git-side-panel-repository-copy");
|
|
15924
16693
|
copy.append(make("strong", undefined, gitPanelRootLabel(card.root)), make("span", undefined, card.root));
|
|
15925
16694
|
button.addEventListener("click", () => toggleGitPanelRepository(card));
|
|
15926
|
-
|
|
15927
|
-
|
|
16695
|
+
const repositoryContext = { card, kind: "repository", path: card.root };
|
|
16696
|
+
bindGitPanelContextMenu(button, repositoryContext);
|
|
16697
|
+
const header = make("div", "git-side-panel-repository-header");
|
|
16698
|
+
header.append(button, gitPanelOverflowButton(repositoryContext, gitPanelRootLabel(card.root)));
|
|
16699
|
+
section.append(header);
|
|
15928
16700
|
if (expanded) section.append(renderGitPanelRepositoryContent(card, snapshot));
|
|
15929
16701
|
return section;
|
|
15930
16702
|
}
|
|
@@ -15987,7 +16759,7 @@ function renderGitPanel() {
|
|
|
15987
16759
|
? "No terminal tabs are open."
|
|
15988
16760
|
: discovering
|
|
15989
16761
|
? "Discovering repositories…"
|
|
15990
|
-
: `${repositoryCount} Git ${repositoryCount === 1 ? "repository" : "repositories"} ·
|
|
16762
|
+
: `${repositoryCount} Git ${repositoryCount === 1 ? "repository" : "repositories"} · ⋯ or right-click for actions`;
|
|
15991
16763
|
}
|
|
15992
16764
|
ensureGitPanelRepositoriesDiscovered();
|
|
15993
16765
|
ensureGitPanelVisibleRepositoriesFresh(cards);
|
|
@@ -16654,10 +17426,11 @@ async function switchTab(tabId) {
|
|
|
16654
17426
|
focusPromptInput({ defer: true });
|
|
16655
17427
|
connectEvents(tabContext);
|
|
16656
17428
|
await refreshAll(tabContext);
|
|
17429
|
+
noteRecentFullRefresh();
|
|
16657
17430
|
if (isCurrentTabContext(tabContext)) markTabOutputSeen();
|
|
16658
17431
|
await refreshThemeCatalog(tabContext).catch((error) => addEvent(`Custom theme catalog refresh failed: ${error.message || String(error)}`, "warn"));
|
|
16659
17432
|
if (!subagentLaunchSlotDraftIsDirty()) {
|
|
16660
|
-
|
|
17433
|
+
loadSubagentLaunchSlotConfigWhenVisible({ tabId }).catch(() => {});
|
|
16661
17434
|
} else {
|
|
16662
17435
|
renderSubagentLaunchSlots();
|
|
16663
17436
|
}
|
|
@@ -16862,11 +17635,21 @@ async function confirmCloseTerminalTabs(targetTabs, label) {
|
|
|
16862
17635
|
});
|
|
16863
17636
|
}
|
|
16864
17637
|
|
|
17638
|
+
async function reopenClosedTerminalTab(tabId) {
|
|
17639
|
+
const response = await api("/api/tabs/reopen", { method: "POST", body: { id: tabId }, scoped: false });
|
|
17640
|
+
await refreshTabs();
|
|
17641
|
+
const reopened = response.data?.tab?.id;
|
|
17642
|
+
if (reopened) await switchTab(reopened);
|
|
17643
|
+
}
|
|
17644
|
+
|
|
16865
17645
|
async function closeTerminalTabs(tabIds, { label = "selected terminal tabs", allowEmpty = false } = {}) {
|
|
16866
17646
|
const targetIds = [...new Set(tabIds.filter(Boolean))];
|
|
16867
17647
|
const targetTabs = targetIds.map((id) => tabs.find((item) => item.id === id)).filter(Boolean);
|
|
16868
17648
|
if (!targetTabs.length) return;
|
|
16869
|
-
|
|
17649
|
+
// Closing one idle tab is routine and reversible (its session stays resumable), so it closes at
|
|
17650
|
+
// once with an Undo instead of a confirmation. Anything with running work still asks first.
|
|
17651
|
+
const quickClose = targetTabs.length === 1 && !tabHasActiveAgent(targetTabs[0]) && !allowEmpty;
|
|
17652
|
+
if (!quickClose && !(await confirmCloseTerminalTabs(targetTabs, label))) return;
|
|
16870
17653
|
|
|
16871
17654
|
const closedActiveTab = targetTabs.some((tab) => tab.id === activeTabId);
|
|
16872
17655
|
const fallbackTabId = tabs.find((item) => !targetIds.includes(item.id))?.id || null;
|
|
@@ -16892,6 +17675,14 @@ async function closeTerminalTabs(tabIds, { label = "selected terminal tabs", all
|
|
|
16892
17675
|
syncTerminalCustomGroupsWithTabs(tabs);
|
|
16893
17676
|
clearOpenTerminalTabGroup(null, { force: true });
|
|
16894
17677
|
if (!tabs.length) setWorkspaceDashboardCollapsed(false, { persist: false });
|
|
17678
|
+
if (quickClose && closedIds.length === 1) {
|
|
17679
|
+
const closedTitle = targetTabs[0].title || "tab";
|
|
17680
|
+
offerUndo({
|
|
17681
|
+
message: `Closed ${closedTitle}.`,
|
|
17682
|
+
undo: () => reopenClosedTerminalTab(closedIds[0]),
|
|
17683
|
+
successMessage: `${closedTitle} reopened.`,
|
|
17684
|
+
});
|
|
17685
|
+
}
|
|
16895
17686
|
|
|
16896
17687
|
const activeTabNeedsFallback = closedIds.includes(activeTabId) || !tabs.some((item) => item.id === activeTabId);
|
|
16897
17688
|
if (activeTabNeedsFallback) {
|
|
@@ -16938,6 +17729,7 @@ async function initializeTabs() {
|
|
|
16938
17729
|
restoreTerminalCustomGroups();
|
|
16939
17730
|
syncTerminalCustomGroupsWithTabs(tabs, { persist: false });
|
|
16940
17731
|
restoreMobileContinuityState();
|
|
17732
|
+
restoreDesktopDrafts();
|
|
16941
17733
|
resetActiveTabUi();
|
|
16942
17734
|
renderTabs();
|
|
16943
17735
|
restoreActiveDraft();
|
|
@@ -16956,9 +17748,10 @@ async function initializeTabs() {
|
|
|
16956
17748
|
connectEvents(tabContext);
|
|
16957
17749
|
if (activeTabId) {
|
|
16958
17750
|
await refreshAll(tabContext);
|
|
17751
|
+
noteRecentFullRefresh();
|
|
16959
17752
|
if (isCurrentTabContext(tabContext)) markTabOutputSeen();
|
|
16960
17753
|
if (!subagentLaunchSlotDraftIsDirty() || subagentLaunchSlotConfigTabId !== activeTabId) {
|
|
16961
|
-
|
|
17754
|
+
loadSubagentLaunchSlotConfigWhenVisible().catch(() => {});
|
|
16962
17755
|
}
|
|
16963
17756
|
refreshSamplingParametersForTabContext(tabContext);
|
|
16964
17757
|
await refreshThemeCatalog(tabContext).catch((error) => addEvent(`Custom theme catalog refresh failed: ${error.message || String(error)}`, "warn"));
|
|
@@ -17016,7 +17809,7 @@ function jumpToChatEvent(line) {
|
|
|
17016
17809
|
}
|
|
17017
17810
|
}
|
|
17018
17811
|
|
|
17019
|
-
function addEvent(message, level = "info", { toolCallId = "" } = {}) {
|
|
17812
|
+
function addEvent(message, level = "info", { toolCallId = "", notify = true } = {}) {
|
|
17020
17813
|
const occurredAt = Date.now();
|
|
17021
17814
|
const line = make("button", `event ${level}`.trim());
|
|
17022
17815
|
line.type = "button";
|
|
@@ -17028,6 +17821,122 @@ function addEvent(message, level = "info", { toolCallId = "" } = {}) {
|
|
|
17028
17821
|
line.addEventListener("click", () => jumpToChatEvent(line));
|
|
17029
17822
|
elements.eventLog.prepend(line);
|
|
17030
17823
|
while (elements.eventLog.children.length > 120) elements.eventLog.lastElementChild?.remove();
|
|
17824
|
+
if (notify && (level === "error" || level === "warn")) {
|
|
17825
|
+
showNoticeToast(message, level);
|
|
17826
|
+
noteUnreadEvent();
|
|
17827
|
+
}
|
|
17828
|
+
}
|
|
17829
|
+
|
|
17830
|
+
// --- Non-blocking warn/error notices -------------------------------------------------------
|
|
17831
|
+
// The Events log lives in a collapsed Control Deck section, so on its own it makes failures look
|
|
17832
|
+
// like "nothing happened". Warnings and errors additionally surface as a short-lived toast (max 3,
|
|
17833
|
+
// deduplicated) with a shortcut to the Events log, and the Events header shows an unread count.
|
|
17834
|
+
function noticeToastTimeout(level) {
|
|
17835
|
+
return NOTICE_TOAST_TIMEOUT_MS[level] || (level === "error" ? NOTICE_TOAST_TIMEOUT_MS.error : NOTICE_TOAST_TIMEOUT_MS.warn);
|
|
17836
|
+
}
|
|
17837
|
+
|
|
17838
|
+
function removeNoticeToast(entry) {
|
|
17839
|
+
const index = noticeToasts.indexOf(entry);
|
|
17840
|
+
if (index >= 0) noticeToasts.splice(index, 1);
|
|
17841
|
+
clearTimeout(entry.timer);
|
|
17842
|
+
entry.node.remove();
|
|
17843
|
+
}
|
|
17844
|
+
|
|
17845
|
+
function armNoticeToastTimer(entry) {
|
|
17846
|
+
clearTimeout(entry.timer);
|
|
17847
|
+
entry.timer = setTimeout(() => removeNoticeToast(entry), noticeToastTimeout(entry.level));
|
|
17848
|
+
}
|
|
17849
|
+
|
|
17850
|
+
function showNoticeToast(message, level = "warn") {
|
|
17851
|
+
const stack = elements.noticeToastStack;
|
|
17852
|
+
const text = String(message || "").trim();
|
|
17853
|
+
if (!stack || !text) return null;
|
|
17854
|
+
const existing = noticeToasts.find((entry) => entry.level === level && entry.text === text);
|
|
17855
|
+
if (existing) {
|
|
17856
|
+
existing.count += 1;
|
|
17857
|
+
existing.countNode.textContent = `×${existing.count}`;
|
|
17858
|
+
existing.countNode.hidden = false;
|
|
17859
|
+
armNoticeToastTimer(existing);
|
|
17860
|
+
return existing;
|
|
17861
|
+
}
|
|
17862
|
+
const node = make("div", `notice-toast ${level}`);
|
|
17863
|
+
node.setAttribute("role", level === "error" ? "alert" : "status");
|
|
17864
|
+
const messageNode = make("span", "notice-toast-message", text);
|
|
17865
|
+
const countNode = make("span", "notice-toast-count", "");
|
|
17866
|
+
countNode.hidden = true;
|
|
17867
|
+
messageNode.append(countNode);
|
|
17868
|
+
const eventsButton = make("button", "notice-toast-events", "Events");
|
|
17869
|
+
eventsButton.type = "button";
|
|
17870
|
+
eventsButton.title = "Open the Events log in the Control Deck";
|
|
17871
|
+
const dismissButton = make("button", "notice-toast-dismiss", "×");
|
|
17872
|
+
dismissButton.type = "button";
|
|
17873
|
+
dismissButton.setAttribute("aria-label", "Dismiss notification");
|
|
17874
|
+
node.append(messageNode, eventsButton, dismissButton);
|
|
17875
|
+
const entry = { node, level, text, count: 1, countNode, timer: null };
|
|
17876
|
+
eventsButton.addEventListener("click", () => {
|
|
17877
|
+
removeNoticeToast(entry);
|
|
17878
|
+
revealEventsSection();
|
|
17879
|
+
});
|
|
17880
|
+
dismissButton.addEventListener("click", () => removeNoticeToast(entry));
|
|
17881
|
+
node.addEventListener("pointerenter", () => clearTimeout(entry.timer));
|
|
17882
|
+
node.addEventListener("pointerleave", () => armNoticeToastTimer(entry));
|
|
17883
|
+
noticeToasts.push(entry);
|
|
17884
|
+
stack.append(node);
|
|
17885
|
+
while (noticeToasts.length > NOTICE_TOAST_LIMIT) removeNoticeToast(noticeToasts[0]);
|
|
17886
|
+
armNoticeToastTimer(entry);
|
|
17887
|
+
return entry;
|
|
17888
|
+
}
|
|
17889
|
+
|
|
17890
|
+
function eventsSectionRecord() {
|
|
17891
|
+
return sidePanelSectionRecords().find((record) => record.id === "events") || null;
|
|
17892
|
+
}
|
|
17893
|
+
|
|
17894
|
+
function eventsSectionIsVisibleAndExpanded() {
|
|
17895
|
+
const record = eventsSectionRecord();
|
|
17896
|
+
if (!record || record.section.hidden || record.section.classList.contains("collapsed")) return false;
|
|
17897
|
+
return !document.body.classList.contains("side-panel-collapsed") || document.body.classList.contains("control-deck-left");
|
|
17898
|
+
}
|
|
17899
|
+
|
|
17900
|
+
function renderEventsUnreadBadge() {
|
|
17901
|
+
const badge = elements.eventsUnreadBadge;
|
|
17902
|
+
if (!badge) return;
|
|
17903
|
+
badge.textContent = eventsUnreadCount > 99 ? "99+" : String(eventsUnreadCount);
|
|
17904
|
+
badge.hidden = eventsUnreadCount === 0;
|
|
17905
|
+
badge.setAttribute("aria-label", `${eventsUnreadCount} unread warning${eventsUnreadCount === 1 ? "" : "s"} or errors`);
|
|
17906
|
+
}
|
|
17907
|
+
|
|
17908
|
+
function noteUnreadEvent() {
|
|
17909
|
+
if (eventsSectionIsVisibleAndExpanded()) return;
|
|
17910
|
+
eventsUnreadCount += 1;
|
|
17911
|
+
renderEventsUnreadBadge();
|
|
17912
|
+
}
|
|
17913
|
+
|
|
17914
|
+
function clearUnreadEvents() {
|
|
17915
|
+
if (!eventsUnreadCount) return;
|
|
17916
|
+
eventsUnreadCount = 0;
|
|
17917
|
+
renderEventsUnreadBadge();
|
|
17918
|
+
}
|
|
17919
|
+
|
|
17920
|
+
function revealSidePanelSectionById(id) {
|
|
17921
|
+
const record = sidePanelSectionRecords().find((entry) => entry.id === id);
|
|
17922
|
+
if (!record) return;
|
|
17923
|
+
if (record.section.hidden) setSidePanelSectionVisible(record, true);
|
|
17924
|
+
if (document.body.classList.contains("side-panel-collapsed") && !document.body.classList.contains("control-deck-left")) setSidePanelCollapsed(false, { focusPanel: true });
|
|
17925
|
+
if (record.section.classList.contains("collapsed")) setSidePanelSectionCollapsed(record, false);
|
|
17926
|
+
queueMicrotask(() => {
|
|
17927
|
+
record.section.scrollIntoView?.({ block: "nearest" });
|
|
17928
|
+
record.button?.focus?.({ preventScroll: true });
|
|
17929
|
+
});
|
|
17930
|
+
}
|
|
17931
|
+
|
|
17932
|
+
function revealEventsSection() {
|
|
17933
|
+
const record = eventsSectionRecord();
|
|
17934
|
+
if (!record) return;
|
|
17935
|
+
if (record.section.hidden) setSidePanelSectionVisible(record, true);
|
|
17936
|
+
if (document.body.classList.contains("side-panel-collapsed") && !document.body.classList.contains("control-deck-left")) setSidePanelCollapsed(false);
|
|
17937
|
+
if (record.section.classList.contains("collapsed")) setSidePanelSectionCollapsed(record, false);
|
|
17938
|
+
clearUnreadEvents();
|
|
17939
|
+
queueMicrotask(() => record.section.scrollIntoView?.({ block: "nearest" }));
|
|
17031
17940
|
}
|
|
17032
17941
|
|
|
17033
17942
|
function browserNotificationSupported() {
|
|
@@ -17322,6 +18231,24 @@ function formatDate(value) {
|
|
|
17322
18231
|
return Number.isNaN(date.getTime()) ? "" : date.toLocaleString();
|
|
17323
18232
|
}
|
|
17324
18233
|
|
|
18234
|
+
// "3 min ago", "yesterday 14:05", "Aug 3, 09:12" — for lists where raw ISO stamps were shown.
|
|
18235
|
+
function formatRelativeDate(value, now = Date.now()) {
|
|
18236
|
+
if (!value) return "";
|
|
18237
|
+
const date = typeof value === "number" ? new Date(value) : new Date(String(value));
|
|
18238
|
+
const time = date.getTime();
|
|
18239
|
+
if (Number.isNaN(time)) return String(value);
|
|
18240
|
+
const diff = Math.max(0, now - time);
|
|
18241
|
+
const minute = 60_000;
|
|
18242
|
+
const hour = 60 * minute;
|
|
18243
|
+
const day = 24 * hour;
|
|
18244
|
+
if (diff < minute) return "just now";
|
|
18245
|
+
if (diff < hour) return `${Math.round(diff / minute)} min ago`;
|
|
18246
|
+
if (diff < day && new Date(now).getDate() === date.getDate()) return `today ${date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}`;
|
|
18247
|
+
if (diff < 2 * day) return `yesterday ${date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}`;
|
|
18248
|
+
if (diff < 7 * day) return `${Math.round(diff / day)} days ago`;
|
|
18249
|
+
return date.toLocaleDateString([], { month: "short", day: "numeric", ...(new Date(now).getFullYear() === date.getFullYear() ? {} : { year: "numeric" }) });
|
|
18250
|
+
}
|
|
18251
|
+
|
|
17325
18252
|
function stripAnsi(text) {
|
|
17326
18253
|
return String(text ?? "").replace(/(?:\x1B|\u241B)(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
|
|
17327
18254
|
}
|
|
@@ -17472,7 +18399,9 @@ function formatStatusEntry(key, value) {
|
|
|
17472
18399
|
|
|
17473
18400
|
function shortModelLabel(model) {
|
|
17474
18401
|
if (!model) return "unknown";
|
|
17475
|
-
|
|
18402
|
+
// Model id first: when a narrow footer chip truncates from the end, the useful part survives
|
|
18403
|
+
// ("qwen3.6-35b-a3b · lmstu…" instead of "(lmstu…").
|
|
18404
|
+
return `${model.id} · ${model.provider}`;
|
|
17476
18405
|
}
|
|
17477
18406
|
|
|
17478
18407
|
function footerThinkingLevelLabel(level) {
|
|
@@ -17525,6 +18454,37 @@ function footerThinkingLevels() {
|
|
|
17525
18454
|
return levels.length ? levels : ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
17526
18455
|
}
|
|
17527
18456
|
|
|
18457
|
+
// Which thinking levels the active model actually honors (mirrors the server-side rule used for
|
|
18458
|
+
// launch slots): non-reasoning models only "off"; xhigh/max only when the model maps them.
|
|
18459
|
+
function activeModelSupportedThinkingLevels(model = currentState?.model) {
|
|
18460
|
+
const catalogModel = model && Array.isArray(availableModels)
|
|
18461
|
+
? availableModels.find((candidate) => candidate?.provider === model.provider && candidate?.id === model.id) || model
|
|
18462
|
+
: model;
|
|
18463
|
+
if (!catalogModel || typeof catalogModel.reasoning !== "boolean") return null; // unknown → don't restrict
|
|
18464
|
+
if (!catalogModel.reasoning) return ["off"];
|
|
18465
|
+
const mapping = catalogModel.thinkingLevelMap && typeof catalogModel.thinkingLevelMap === "object" ? catalogModel.thinkingLevelMap : {};
|
|
18466
|
+
return footerThinkingLevels().filter((level) => {
|
|
18467
|
+
if (mapping[level] === null) return false;
|
|
18468
|
+
if (["xhigh", "max"].includes(level)) return typeof mapping[level] === "string" || !Object.keys(mapping).length;
|
|
18469
|
+
return true;
|
|
18470
|
+
});
|
|
18471
|
+
}
|
|
18472
|
+
|
|
18473
|
+
function thinkingLevelSupportedByActiveModel(level) {
|
|
18474
|
+
const supported = activeModelSupportedThinkingLevels();
|
|
18475
|
+
return !supported || supported.includes(level);
|
|
18476
|
+
}
|
|
18477
|
+
|
|
18478
|
+
function syncThinkingSelectSupport() {
|
|
18479
|
+
const supported = activeModelSupportedThinkingLevels();
|
|
18480
|
+
for (const option of elements.thinkingSelect?.options || []) {
|
|
18481
|
+
const ok = !supported || supported.includes(option.value);
|
|
18482
|
+
option.disabled = !ok && option.value !== elements.thinkingSelect.value;
|
|
18483
|
+
const base = option.dataset.baseLabel || (option.dataset.baseLabel = option.textContent);
|
|
18484
|
+
option.textContent = ok ? base : `${base} (not supported by this model)`;
|
|
18485
|
+
}
|
|
18486
|
+
}
|
|
18487
|
+
|
|
17528
18488
|
function formatFooterTokenCount(value) {
|
|
17529
18489
|
const n = Math.max(0, Number(value) || 0);
|
|
17530
18490
|
if (n < 1000) return `${Math.round(n)}`;
|
|
@@ -18532,6 +19492,39 @@ function normalizeFooterPayloadChip(value, index) {
|
|
|
18532
19492
|
return chip;
|
|
18533
19493
|
}
|
|
18534
19494
|
|
|
19495
|
+
function normalizeFooterProviderUsageWindow(value) {
|
|
19496
|
+
if (!value || typeof value !== "object") return null;
|
|
19497
|
+
const label = cleanFooterPayloadText(value.label, "Usage window", 32);
|
|
19498
|
+
const usedPercent = Number(value.usedPercent);
|
|
19499
|
+
if (!Number.isFinite(usedPercent) || usedPercent < 0 || usedPercent > 100) return null;
|
|
19500
|
+
const window = { label, usedPercent };
|
|
19501
|
+
const windowMinutes = typeof value.windowMinutes === "number" ? value.windowMinutes : Number.NaN;
|
|
19502
|
+
if (Number.isFinite(windowMinutes) && windowMinutes > 0) window.windowMinutes = windowMinutes;
|
|
19503
|
+
const resetAt = typeof value.resetAt === "number" ? value.resetAt : Number.NaN;
|
|
19504
|
+
if (Number.isFinite(resetAt) && resetAt >= 0) window.resetAt = resetAt;
|
|
19505
|
+
const resetAfterSeconds = typeof value.resetAfterSeconds === "number" ? value.resetAfterSeconds : Number.NaN;
|
|
19506
|
+
if (Number.isFinite(resetAfterSeconds) && resetAfterSeconds >= 0) window.resetAfterSeconds = resetAfterSeconds;
|
|
19507
|
+
return window;
|
|
19508
|
+
}
|
|
19509
|
+
|
|
19510
|
+
function normalizeFooterProviderUsage(value) {
|
|
19511
|
+
if (!value || typeof value !== "object") return null;
|
|
19512
|
+
if (value.provider !== "anthropic" && value.provider !== "openai-codex") return null;
|
|
19513
|
+
const capturedAt = typeof value.capturedAt === "number" ? value.capturedAt : Number.NaN;
|
|
19514
|
+
if (!Number.isFinite(capturedAt) || capturedAt <= 0) return null;
|
|
19515
|
+
const primary = normalizeFooterProviderUsageWindow(value.primary);
|
|
19516
|
+
const secondary = normalizeFooterProviderUsageWindow(value.secondary);
|
|
19517
|
+
if (!primary && !secondary) return null;
|
|
19518
|
+
const plan = cleanFooterPayloadText(value.plan, "", 80);
|
|
19519
|
+
return {
|
|
19520
|
+
provider: value.provider,
|
|
19521
|
+
capturedAt,
|
|
19522
|
+
...(primary ? { primary } : {}),
|
|
19523
|
+
...(secondary ? { secondary } : {}),
|
|
19524
|
+
...(plan ? { plan } : {}),
|
|
19525
|
+
};
|
|
19526
|
+
}
|
|
19527
|
+
|
|
18535
19528
|
function currentGitFooterCacheCwd(tabId = activeTabId) {
|
|
18536
19529
|
const tab = tabs.find((item) => item.id === tabId) || activeTab();
|
|
18537
19530
|
return latestWorkspace?.cwd || tab?.cwd || "";
|
|
@@ -18545,8 +19538,9 @@ function parseGitFooterWebuiPayloadRaw(raw) {
|
|
|
18545
19538
|
const main = Array.isArray(parsed.main) ? parsed.main.map(normalizeFooterPayloadChip).filter(Boolean).slice(0, 8) : [];
|
|
18546
19539
|
const meta = Array.isArray(parsed.meta) ? parsed.meta.map(normalizeFooterPayloadChip).filter(Boolean).slice(0, 10) : [];
|
|
18547
19540
|
const visibility = normalizeGitFooterWebuiVisibility(parsed.visibility);
|
|
18548
|
-
|
|
18549
|
-
|
|
19541
|
+
const providerUsage = normalizeFooterProviderUsage(parsed.providerUsage);
|
|
19542
|
+
if (!main.length && !meta.length && !parsed.visibility && !providerUsage) return null;
|
|
19543
|
+
return { main, meta, visibility, ...(providerUsage ? { providerUsage } : {}) };
|
|
18550
19544
|
} catch {
|
|
18551
19545
|
return null;
|
|
18552
19546
|
}
|
|
@@ -19547,9 +20541,15 @@ function gitFileActionButtons(actions) {
|
|
|
19547
20541
|
const button = make("button", `git-file-action ${action.className || ""}`.trim(), action.label);
|
|
19548
20542
|
button.type = "button";
|
|
19549
20543
|
button.title = action.title || action.label;
|
|
20544
|
+
if (action.path) button.dataset.gitFileActionPath = action.path;
|
|
20545
|
+
if (action.path && gitChangesState.busyPath === action.path) {
|
|
20546
|
+
button.disabled = true;
|
|
20547
|
+
button.setAttribute("aria-busy", "true");
|
|
20548
|
+
}
|
|
19550
20549
|
button.addEventListener("click", (event) => {
|
|
19551
20550
|
event.preventDefault();
|
|
19552
20551
|
event.stopPropagation();
|
|
20552
|
+
if (button.disabled) return;
|
|
19553
20553
|
action.onClick();
|
|
19554
20554
|
});
|
|
19555
20555
|
wrap.append(button);
|
|
@@ -19633,14 +20633,14 @@ function gitChangesFileActionsFor(sectionKey, path) {
|
|
|
19633
20633
|
if (!path || gitChangesState.loading || gitChangesState.pulling || gitChangesState.fetching) return [];
|
|
19634
20634
|
if (sectionKey === "unstaged") {
|
|
19635
20635
|
return [
|
|
19636
|
-
{ label: "Stage", title: `git add -- ${path}`, onClick: () => runGitFileAction("stage", path) },
|
|
20636
|
+
{ label: "Stage", path, title: `git add -- ${path}`, onClick: () => runGitFileAction("stage", path) },
|
|
19637
20637
|
...gitChangesCommonFileActions(path),
|
|
19638
|
-
{ label: "Discard", className: "danger", title: `git restore -- ${path} (destructive)`, onClick: () => runGitFileAction("discard", path) },
|
|
20638
|
+
{ label: "Discard", path, className: "danger", title: `git restore -- ${path} (destructive)`, onClick: () => runGitFileAction("discard", path) },
|
|
19639
20639
|
];
|
|
19640
20640
|
}
|
|
19641
20641
|
if (sectionKey === "staged") {
|
|
19642
20642
|
return [
|
|
19643
|
-
{ label: "Unstage", title: `git restore --staged -- ${path}`, onClick: () => runGitFileAction("unstage", path) },
|
|
20643
|
+
{ label: "Unstage", path, title: `git restore --staged -- ${path}`, onClick: () => runGitFileAction("unstage", path) },
|
|
19644
20644
|
...gitChangesCommonFileActions(path),
|
|
19645
20645
|
];
|
|
19646
20646
|
}
|
|
@@ -19648,9 +20648,18 @@ function gitChangesFileActionsFor(sectionKey, path) {
|
|
|
19648
20648
|
return [];
|
|
19649
20649
|
}
|
|
19650
20650
|
|
|
20651
|
+
// Per-file fold state for the Git Changes dialog survives the full re-render that follows every
|
|
20652
|
+
// stage/unstage/discard, so files the user collapsed stay collapsed.
|
|
20653
|
+
const gitChangesCollapsedFiles = new Set();
|
|
20654
|
+
|
|
19651
20655
|
function renderGitDiffFile(file, actions = []) {
|
|
19652
20656
|
const details = make("details", `git-diff-file ${file.className || ""}`.trim());
|
|
19653
|
-
|
|
20657
|
+
const fileKey = file.path || "diff";
|
|
20658
|
+
details.open = !gitChangesCollapsedFiles.has(fileKey);
|
|
20659
|
+
details.addEventListener("toggle", () => {
|
|
20660
|
+
if (details.open) gitChangesCollapsedFiles.delete(fileKey);
|
|
20661
|
+
else gitChangesCollapsedFiles.add(fileKey);
|
|
20662
|
+
});
|
|
19654
20663
|
details.dataset.gitDiffFile = file.path || "diff";
|
|
19655
20664
|
const summary = make("summary", "git-diff-file-summary");
|
|
19656
20665
|
summary.append(
|
|
@@ -19771,9 +20780,9 @@ function renderGitUntrackedFile(entry) {
|
|
|
19771
20780
|
if (!gitChangesState.loading && !gitChangesState.pulling && !gitChangesState.fetching) {
|
|
19772
20781
|
const summary = node.querySelector("summary");
|
|
19773
20782
|
const actions = gitFileActionButtons([
|
|
19774
|
-
{ label: "Stage", title: `git add -- ${entry.path}`, onClick: () => runGitFileAction("stage", entry.path) },
|
|
20783
|
+
{ label: "Stage", path: entry.path, title: `git add -- ${entry.path}`, onClick: () => runGitFileAction("stage", entry.path) },
|
|
19775
20784
|
...gitChangesCommonFileActions(entry.path),
|
|
19776
|
-
{ label: "Delete", className: "danger", title: "Delete this untracked file from disk (destructive)", onClick: () => runGitFileAction("delete-untracked", entry.path) },
|
|
20785
|
+
{ label: "Delete", path: entry.path, className: "danger", title: "Delete this untracked file from disk (destructive)", onClick: () => runGitFileAction("delete-untracked", entry.path) },
|
|
19777
20786
|
]);
|
|
19778
20787
|
if (summary && actions) summary.append(actions);
|
|
19779
20788
|
}
|
|
@@ -20082,7 +21091,7 @@ function renderGitChangesDialog() {
|
|
|
20082
21091
|
return;
|
|
20083
21092
|
}
|
|
20084
21093
|
if (!data) {
|
|
20085
|
-
body.append(make("div", "git-changes-empty", "Open from the
|
|
21094
|
+
body.append(make("div", "git-changes-empty", "No diff loaded yet. Open this from the CHANGES chip in the footer, or expand a repository in the Git panel."));
|
|
20086
21095
|
return;
|
|
20087
21096
|
}
|
|
20088
21097
|
|
|
@@ -20124,7 +21133,8 @@ function renderGitChangesDialog() {
|
|
|
20124
21133
|
async function loadGitChangesDialog(tabContext = activeTabContext()) {
|
|
20125
21134
|
const requestSerial = ++gitChangesRequestSerial;
|
|
20126
21135
|
gitChangesUntrackedContentRequests.clear();
|
|
20127
|
-
|
|
21136
|
+
if (gitChangesState.tabId !== (tabContext.tabId || activeTabId)) gitChangesCollapsedFiles.clear();
|
|
21137
|
+
gitChangesState = { ...gitChangesState, loading: true, busyPath: "", error: "", errorCode: "", errorHint: "", message: "", pullResult: null, tabId: tabContext.tabId || activeTabId, mode: "changes", commit: null };
|
|
20128
21138
|
renderGitChangesDialog();
|
|
20129
21139
|
try {
|
|
20130
21140
|
const [response, operationResponse] = await Promise.all([
|
|
@@ -20366,16 +21376,30 @@ async function runGitFileAction(action, path) {
|
|
|
20366
21376
|
}[action];
|
|
20367
21377
|
if (!config) return;
|
|
20368
21378
|
if (config.confirm && !(await appConfirmText(config.confirm, { affected: path, confirmLabel: action }))) return;
|
|
21379
|
+
if (gitChangesState.busyPath) return; // one file action at a time; ignore double clicks
|
|
21380
|
+
// Remember which control had focus so it can be restored after the dialog re-renders.
|
|
21381
|
+
const focusedActionLabel = document.activeElement?.classList?.contains("git-file-action") ? document.activeElement.textContent : "";
|
|
21382
|
+
const restoreFocus = () => {
|
|
21383
|
+
if (!focusedActionLabel) return;
|
|
21384
|
+
const candidates = [...(elements.gitChangesBody?.querySelectorAll(`.git-file-action[data-git-file-action-path="${CSS.escape(path)}"]`) || [])];
|
|
21385
|
+
const target = candidates.find((node) => node.textContent === focusedActionLabel) || candidates[0]
|
|
21386
|
+
|| elements.gitChangesBody?.querySelector(".git-file-action") || elements.gitChangesDialog?.querySelector("button");
|
|
21387
|
+
target?.focus?.({ preventScroll: true });
|
|
21388
|
+
};
|
|
21389
|
+
gitChangesState = { ...gitChangesState, busyPath: path };
|
|
21390
|
+
renderGitChangesDialog();
|
|
20369
21391
|
try {
|
|
20370
21392
|
const response = await api(config.url, { method: "POST", body: config.body, tabId });
|
|
20371
21393
|
if (!response.ok) throw new Error([response.error, response.hint].filter(Boolean).join("\n") || `git ${action} failed`);
|
|
20372
|
-
gitChangesState = { ...gitChangesState, data: response.data?.changes || gitChangesState.data, message: config.label, error: "", errorCode: "", errorHint: "" };
|
|
21394
|
+
gitChangesState = { ...gitChangesState, busyPath: "", data: response.data?.changes || gitChangesState.data, message: config.label, error: "", errorCode: "", errorHint: "" };
|
|
20373
21395
|
addEvent(config.label, "success");
|
|
20374
21396
|
renderGitChangesDialog();
|
|
21397
|
+
restoreFocus();
|
|
20375
21398
|
requestGitFooterWebuiPayload(activeTabContext(tabId), { force: true });
|
|
20376
21399
|
} catch (error) {
|
|
20377
|
-
gitChangesState = { ...gitChangesState, error: error.message || String(error) };
|
|
21400
|
+
gitChangesState = { ...gitChangesState, busyPath: "", error: error.message || String(error) };
|
|
20378
21401
|
renderGitChangesDialog();
|
|
21402
|
+
restoreFocus();
|
|
20379
21403
|
addEvent(error.message || String(error), "error");
|
|
20380
21404
|
}
|
|
20381
21405
|
}
|
|
@@ -20772,8 +21796,8 @@ function renderGitUndoTools(body, data, busy) {
|
|
|
20772
21796
|
row.append(gitToolsButton(
|
|
20773
21797
|
"Amend last commit message",
|
|
20774
21798
|
{ disabled: busy || !data.canAmendMessage, title: data.canAmendMessage ? "git commit --amend -m <message>" : "Requires an unpushed commit and an empty staging area." },
|
|
20775
|
-
() => {
|
|
20776
|
-
const message =
|
|
21799
|
+
async () => {
|
|
21800
|
+
const message = await appPromptText({ title: "Amend last commit message", summary: `git commit --amend -m <message> · current: ${last?.subject || ""}`, defaultValue: last?.subject || "", confirmLabel: "Amend", validate: (value) => (String(value || "").trim() ? "" : "A commit message is required.") });
|
|
20777
21801
|
if (!message || !message.trim()) return;
|
|
20778
21802
|
runGitToolAction("undo", {
|
|
20779
21803
|
url: "/api/git-undo/amend-message",
|
|
@@ -20918,10 +21942,10 @@ function renderGitTagTools(body, data, busy) {
|
|
|
20918
21942
|
body.append(item);
|
|
20919
21943
|
}
|
|
20920
21944
|
const row = make("div", "git-operation-actions");
|
|
20921
|
-
row.append(gitToolsButton("Create annotated tag…", { disabled: busy, title: "git tag -a <name> -m <message> (never pushed automatically)" }, () => {
|
|
20922
|
-
const name =
|
|
21945
|
+
row.append(gitToolsButton("Create annotated tag…", { disabled: busy, title: "git tag -a <name> -m <message> (never pushed automatically)" }, async () => {
|
|
21946
|
+
const name = await appPromptText({ title: "Create annotated tag", summary: "git tag -a <name> -m <message> at HEAD. Tags are never pushed automatically.", placeholder: "v1.2.3", confirmLabel: "Next", validate: (value) => (String(value || "").trim() ? "" : "A tag name is required.") });
|
|
20923
21947
|
if (!name || !name.trim()) return;
|
|
20924
|
-
const message =
|
|
21948
|
+
const message = await appPromptText({ title: `Tag message for ${name.trim()}`, defaultValue: name.trim(), confirmLabel: "Create tag" });
|
|
20925
21949
|
if (message === null) return;
|
|
20926
21950
|
runGitToolAction("tags", {
|
|
20927
21951
|
url: "/api/git-tags/create",
|
|
@@ -21605,6 +22629,7 @@ function applyOptimisticGitFooterBranch(branch, tabContext = activeTabContext())
|
|
|
21605
22629
|
type: GIT_FOOTER_WEBUI_PAYLOAD_TYPE,
|
|
21606
22630
|
version: GIT_FOOTER_WEBUI_PAYLOAD_VERSION,
|
|
21607
22631
|
generatedAt: Date.now(),
|
|
22632
|
+
...(payload.providerUsage ? { providerUsage: payload.providerUsage } : {}),
|
|
21608
22633
|
main: payload.main,
|
|
21609
22634
|
meta: payload.meta.map((chip) => chip.key === "git" ? { ...chip, value: nextBranch, title: `git branch: ${nextBranch}` } : chip),
|
|
21610
22635
|
visibility: payload.visibility,
|
|
@@ -22582,7 +23607,8 @@ async function applyFooterThinking(level) {
|
|
|
22582
23607
|
} else if (response.data?.level) {
|
|
22583
23608
|
const requested = response.data.requestedLevel;
|
|
22584
23609
|
const effective = response.data.level;
|
|
22585
|
-
|
|
23610
|
+
if (requested && requested !== effective) addEvent(`Thinking effort set to ${effective}: the active model does not support ${requested}.`, "warn");
|
|
23611
|
+
else addEvent(`Thinking effort set to ${effective}.`, "info");
|
|
22586
23612
|
}
|
|
22587
23613
|
await refreshState(tabContext);
|
|
22588
23614
|
} catch (error) {
|
|
@@ -22604,12 +23630,14 @@ function renderFooterThinkingPicker() {
|
|
|
22604
23630
|
const current = currentState?.pendingThinkingLevel || currentState?.thinkingLevel || "off";
|
|
22605
23631
|
for (const level of footerThinkingLevels()) {
|
|
22606
23632
|
const selected = current === level;
|
|
22607
|
-
const
|
|
23633
|
+
const supported = thinkingLevelSupportedByActiveModel(level);
|
|
23634
|
+
const button = make("button", `footer-model-option${selected ? " active" : ""}${supported ? "" : " unsupported"}`);
|
|
22608
23635
|
button.type = "button";
|
|
22609
23636
|
button.setAttribute("role", "option");
|
|
22610
23637
|
button.setAttribute("aria-selected", selected ? "true" : "false");
|
|
22611
|
-
button.title = `Set thinking effort to ${level}`;
|
|
22612
|
-
button.
|
|
23638
|
+
button.title = supported ? `Set thinking effort to ${level}` : `${level} is not supported by the active model`;
|
|
23639
|
+
button.disabled = !supported && !selected;
|
|
23640
|
+
button.append(make("span", "footer-model-option-main", supported ? footerThinkingLevelLabel(level) : `${footerThinkingLevelLabel(level)} · not supported`));
|
|
22613
23641
|
button.addEventListener("click", () => applyFooterThinking(level));
|
|
22614
23642
|
picker.append(button);
|
|
22615
23643
|
}
|
|
@@ -22798,25 +23826,25 @@ function currentFastPick() {
|
|
|
22798
23826
|
function updateAddFastPickButton() {
|
|
22799
23827
|
if (!pathFastPicksReady) {
|
|
22800
23828
|
elements.pathPickerAddFastPickButton.disabled = true;
|
|
22801
|
-
elements.pathPickerAddFastPickButton.textContent = "Loading
|
|
23829
|
+
elements.pathPickerAddFastPickButton.textContent = "Loading pinned folders…";
|
|
22802
23830
|
return;
|
|
22803
23831
|
}
|
|
22804
23832
|
const pick = currentFastPick();
|
|
22805
23833
|
const exists = !!pick && loadFastPicks().some((item) => item.cwd === pick.cwd);
|
|
22806
23834
|
elements.pathPickerAddFastPickButton.disabled = !pick || exists;
|
|
22807
|
-
elements.pathPickerAddFastPickButton.textContent = exists ? "
|
|
23835
|
+
elements.pathPickerAddFastPickButton.textContent = exists ? "Pinned" : "Pin this folder";
|
|
22808
23836
|
}
|
|
22809
23837
|
|
|
22810
23838
|
function renderFastPicks() {
|
|
22811
23839
|
const picks = loadFastPicks();
|
|
22812
23840
|
elements.pathPickerFastPicks.replaceChildren();
|
|
22813
23841
|
if (!pathFastPicksReady) {
|
|
22814
|
-
elements.pathPickerFastPicks.append(make("div", "path-picker-fast-picks-empty muted", "Loading
|
|
23842
|
+
elements.pathPickerFastPicks.append(make("div", "path-picker-fast-picks-empty muted", "Loading pinned folders…"));
|
|
22815
23843
|
updateAddFastPickButton();
|
|
22816
23844
|
return;
|
|
22817
23845
|
}
|
|
22818
23846
|
if (picks.length === 0) {
|
|
22819
|
-
elements.pathPickerFastPicks.append(make("div", "path-picker-fast-picks-empty muted", "No
|
|
23847
|
+
elements.pathPickerFastPicks.append(make("div", "path-picker-fast-picks-empty muted", "No pinned folders yet. Pin the folders you switch to often."));
|
|
22820
23848
|
updateAddFastPickButton();
|
|
22821
23849
|
return;
|
|
22822
23850
|
}
|
|
@@ -22824,7 +23852,7 @@ function renderFastPicks() {
|
|
|
22824
23852
|
for (const pick of picks) {
|
|
22825
23853
|
const item = make("span", "path-picker-fast-pick");
|
|
22826
23854
|
const jump = pathPickerButton(fastPickLabel(pick), pick.cwd, () => loadPathPickerDirectory(pick.cwd), "path-picker-fast-pick-button");
|
|
22827
|
-
const remove = pathPickerButton("×", `
|
|
23855
|
+
const remove = pathPickerButton("×", `Unpin ${pick.cwd}`, async () => {
|
|
22828
23856
|
await saveFastPicks(loadFastPicks().filter((item) => item.cwd !== pick.cwd));
|
|
22829
23857
|
}, "path-picker-fast-pick-remove");
|
|
22830
23858
|
item.append(jump, remove);
|
|
@@ -22982,6 +24010,7 @@ async function changeActiveTabCwd() {
|
|
|
22982
24010
|
}
|
|
22983
24011
|
|
|
22984
24012
|
if (!(await appConfirmText(`Restart ${tab.title} in:\n${cwd}\n\nCurrent in-flight work in this tab will be stopped. The conversation continues in the new directory.`, { affected: tab.title, confirmLabel: "Change working folder" }))) return;
|
|
24013
|
+
if (activeFileViewer?.dirty && !(await confirmDiscardEdits({ what: "unsaved file edits", target: activeFileViewer.path }))) return;
|
|
22985
24014
|
|
|
22986
24015
|
saveActiveDraft();
|
|
22987
24016
|
if (isCurrentTabContext(tabContext)) {
|
|
@@ -23557,6 +24586,54 @@ function initializeCodexUsage() {
|
|
|
23557
24586
|
codexUsageRenderTimer = setInterval(renderCodexUsage, CODEX_USAGE_RENDER_TICK_MS);
|
|
23558
24587
|
}
|
|
23559
24588
|
|
|
24589
|
+
function claudeUsageWindowFromProvider(window, capturedAt) {
|
|
24590
|
+
if (!window) return null;
|
|
24591
|
+
const resetAt = Number(window.resetAt);
|
|
24592
|
+
const resetAfterSeconds = Number(window.resetAfterSeconds);
|
|
24593
|
+
const resetsAt = Number.isFinite(resetAt) && resetAt >= 0
|
|
24594
|
+
? new Date(resetAt).toISOString()
|
|
24595
|
+
: Number.isFinite(resetAfterSeconds) && resetAfterSeconds >= 0
|
|
24596
|
+
? new Date(capturedAt + resetAfterSeconds * 1000).toISOString()
|
|
24597
|
+
: undefined;
|
|
24598
|
+
return {
|
|
24599
|
+
label: window.label || "Usage window",
|
|
24600
|
+
usedPercent: window.usedPercent,
|
|
24601
|
+
...(Number.isFinite(window.windowMinutes) ? { windowMinutes: window.windowMinutes } : {}),
|
|
24602
|
+
...(resetsAt ? { resetsAt } : {}),
|
|
24603
|
+
};
|
|
24604
|
+
}
|
|
24605
|
+
|
|
24606
|
+
function claudeUsageFromGitFooterPayload(payload = parseGitFooterWebuiPayload()) {
|
|
24607
|
+
const providerUsage = payload?.providerUsage;
|
|
24608
|
+
if (providerUsage?.provider !== "anthropic") return null;
|
|
24609
|
+
const capturedAt = Number(providerUsage.capturedAt);
|
|
24610
|
+
if (!Number.isFinite(capturedAt) || capturedAt <= 0) return null;
|
|
24611
|
+
const windows = [providerUsage.primary, providerUsage.secondary]
|
|
24612
|
+
.map((window) => claudeUsageWindowFromProvider(window, capturedAt))
|
|
24613
|
+
.filter(Boolean);
|
|
24614
|
+
if (windows.length === 0) return null;
|
|
24615
|
+
return {
|
|
24616
|
+
available: true,
|
|
24617
|
+
providerId: "claude-code",
|
|
24618
|
+
source: "git-footer-status-provider-headers",
|
|
24619
|
+
fetchedAt: new Date(capturedAt).toISOString(),
|
|
24620
|
+
summary: "Live Anthropic subscription usage from provider response headers.",
|
|
24621
|
+
windows,
|
|
24622
|
+
activityTitle: "",
|
|
24623
|
+
activity: [],
|
|
24624
|
+
notes: [],
|
|
24625
|
+
};
|
|
24626
|
+
}
|
|
24627
|
+
|
|
24628
|
+
function syncClaudeUsageFromGitFooterPayload(payload = parseGitFooterWebuiPayload()) {
|
|
24629
|
+
const usage = claudeUsageFromGitFooterPayload(payload);
|
|
24630
|
+
if (!usage) return false;
|
|
24631
|
+
latestClaudeUsage = usage;
|
|
24632
|
+
claudeUsageError = null;
|
|
24633
|
+
renderClaudeUsage();
|
|
24634
|
+
return true;
|
|
24635
|
+
}
|
|
24636
|
+
|
|
23560
24637
|
function claudeUsageResetDate(window) {
|
|
23561
24638
|
const resetAt = window?.resetsAt ? new Date(window.resetsAt) : null;
|
|
23562
24639
|
if (resetAt && Number.isFinite(resetAt.getTime())) return resetAt;
|
|
@@ -23701,15 +24778,18 @@ function renderClaudeUsage() {
|
|
|
23701
24778
|
}
|
|
23702
24779
|
}
|
|
23703
24780
|
|
|
23704
|
-
async function refreshClaudeUsage() {
|
|
24781
|
+
async function refreshClaudeUsage({ forceCli = false } = {}) {
|
|
24782
|
+
if (!forceCli && syncClaudeUsageFromGitFooterPayload()) return;
|
|
23705
24783
|
if (claudeUsageLoading) return;
|
|
23706
24784
|
claudeUsageLoading = true;
|
|
23707
24785
|
renderClaudeUsage();
|
|
23708
24786
|
try {
|
|
23709
24787
|
const response = await api("/api/claude-usage", { scoped: false });
|
|
24788
|
+
if (!forceCli && syncClaudeUsageFromGitFooterPayload()) return;
|
|
23710
24789
|
latestClaudeUsage = response.data || null;
|
|
23711
24790
|
claudeUsageError = null;
|
|
23712
24791
|
} catch (error) {
|
|
24792
|
+
if (!forceCli && syncClaudeUsageFromGitFooterPayload()) return;
|
|
23713
24793
|
claudeUsageError = error;
|
|
23714
24794
|
} finally {
|
|
23715
24795
|
claudeUsageLoading = false;
|
|
@@ -25716,9 +26796,38 @@ async function reloadActiveTabForSubagentLaunchSlots() {
|
|
|
25716
26796
|
}
|
|
25717
26797
|
}
|
|
25718
26798
|
|
|
26799
|
+
// The launch-slot editor lives in a collapsed <details> inside the (usually collapsed) Subagents
|
|
26800
|
+
// section, yet its config payload is one of the largest boot requests (~290 KB uncompressed).
|
|
26801
|
+
// Load it lazily: only when the editor is actually visible, otherwise on first reveal.
|
|
26802
|
+
let subagentLaunchSlotConfigDeferred = false;
|
|
26803
|
+
|
|
26804
|
+
function subagentLaunchSlotsVisible() {
|
|
26805
|
+
const details = elements.subagentLaunchSlots;
|
|
26806
|
+
if (!details || !details.open) return false;
|
|
26807
|
+
const section = details.closest?.("[data-side-panel-section]");
|
|
26808
|
+
return !section || (!section.hidden && !section.classList.contains("collapsed"));
|
|
26809
|
+
}
|
|
26810
|
+
|
|
26811
|
+
function loadSubagentLaunchSlotConfigWhenVisible(options = {}) {
|
|
26812
|
+
if (subagentLaunchSlotsVisible()) {
|
|
26813
|
+
subagentLaunchSlotConfigDeferred = false;
|
|
26814
|
+
return loadSubagentLaunchSlotConfig(options);
|
|
26815
|
+
}
|
|
26816
|
+
subagentLaunchSlotConfigDeferred = true;
|
|
26817
|
+
renderSubagentLaunchSlots();
|
|
26818
|
+
return Promise.resolve();
|
|
26819
|
+
}
|
|
26820
|
+
|
|
26821
|
+
function revealSubagentLaunchSlotConfigIfDeferred() {
|
|
26822
|
+
if (!subagentLaunchSlotConfigDeferred || !subagentLaunchSlotsVisible()) return;
|
|
26823
|
+
subagentLaunchSlotConfigDeferred = false;
|
|
26824
|
+
loadSubagentLaunchSlotConfig().catch(() => {});
|
|
26825
|
+
}
|
|
26826
|
+
|
|
25719
26827
|
function initializeSubagentLaunchSlots() {
|
|
25720
26828
|
renderSubagentLaunchSlots();
|
|
25721
|
-
if (activeTabId)
|
|
26829
|
+
if (activeTabId) loadSubagentLaunchSlotConfigWhenVisible().catch(() => {});
|
|
26830
|
+
elements.subagentLaunchSlots?.addEventListener("toggle", () => revealSubagentLaunchSlotConfigIfDeferred());
|
|
25722
26831
|
}
|
|
25723
26832
|
|
|
25724
26833
|
function samplingParametersPath(tabId) {
|
|
@@ -26315,7 +27424,9 @@ function renderStatus() {
|
|
|
26315
27424
|
);
|
|
26316
27425
|
elements.stateDetails.append(overview, infoGrid);
|
|
26317
27426
|
|
|
26318
|
-
if (shownThinkingLevel
|
|
27427
|
+
if (controlsPendingThinkingValue && shownThinkingLevel === controlsPendingThinkingValue) setControlsPendingThinking("");
|
|
27428
|
+
if (shownThinkingLevel && !controlsPendingThinkingValue) elements.thinkingSelect.value = shownThinkingLevel;
|
|
27429
|
+
syncThinkingSelectSupport();
|
|
26319
27430
|
elements.compactButton.disabled = !!state?.isCompacting;
|
|
26320
27431
|
elements.compactButton.textContent = state?.isCompacting ? "Compacting…" : "Compact";
|
|
26321
27432
|
syncModelSelectToState();
|
|
@@ -28519,6 +29630,47 @@ function renderAppRunnerInputForm(run) {
|
|
|
28519
29630
|
return form;
|
|
28520
29631
|
}
|
|
28521
29632
|
|
|
29633
|
+
// Fast path for streaming app-runner output: same run, same lifecycle state, output only grew.
|
|
29634
|
+
function patchAppRunnerWidgetInPlace(tabId, previousRun, nextRun) {
|
|
29635
|
+
if (tabId !== activeTabId) return true; // not the visible tab; nothing to repaint here
|
|
29636
|
+
if (!previousRun || !nextRun || previousRun.id !== nextRun.id) return false;
|
|
29637
|
+
if (appRunnerIsRunning(previousRun) !== appRunnerIsRunning(nextRun)) return false;
|
|
29638
|
+
if ((previousRun.status || "") !== (nextRun.status || "") || Boolean(previousRun.truncated) !== Boolean(nextRun.truncated)) return false;
|
|
29639
|
+
const widget = elements.widgetArea?.querySelector(".app-runner-widget");
|
|
29640
|
+
const terminal = widget?.querySelector(".release-npm-terminal");
|
|
29641
|
+
if (!widget || !terminal) return false;
|
|
29642
|
+
const previousLines = appRunnerOutputLines(previousRun);
|
|
29643
|
+
const nextLines = appRunnerOutputLines(nextRun);
|
|
29644
|
+
if (nextLines.length < previousLines.length) return false;
|
|
29645
|
+
// The server keeps a bounded window; when it starts dropping the head, prefixes diverge.
|
|
29646
|
+
const sample = Math.min(previousLines.length, 3);
|
|
29647
|
+
for (let index = 0; index < sample; index += 1) {
|
|
29648
|
+
if (previousLines[previousLines.length - 1 - index] !== nextLines[previousLines.length - 1 - index]) return false;
|
|
29649
|
+
}
|
|
29650
|
+
const renderedCount = previousLines.length ? terminal.childElementCount : 0;
|
|
29651
|
+
if (renderedCount !== previousLines.length) return false;
|
|
29652
|
+
// A partial pending line is re-rendered as it grows: replace the last row when it changed.
|
|
29653
|
+
const pendingIndex = previousRun.pendingLine ? previousLines.length - 1 : -1;
|
|
29654
|
+
if (pendingIndex >= 0 && nextLines[pendingIndex] !== previousLines[pendingIndex]) {
|
|
29655
|
+
terminal.children[pendingIndex]?.remove();
|
|
29656
|
+
const rest = nextLines.slice(pendingIndex);
|
|
29657
|
+
if (!previousLines.length) terminal.replaceChildren();
|
|
29658
|
+
for (const line of rest) appendReleaseNpmTerminalLine(terminal, line);
|
|
29659
|
+
} else {
|
|
29660
|
+
if (!previousLines.length) terminal.replaceChildren();
|
|
29661
|
+
for (const line of nextLines.slice(previousLines.length)) appendReleaseNpmTerminalLine(terminal, line);
|
|
29662
|
+
}
|
|
29663
|
+
const count = widget.querySelector(".release-npm-stream-count");
|
|
29664
|
+
const lineCount = Math.max(nextRun.lineCount || 0, nextLines.length);
|
|
29665
|
+
if (count) count.textContent = `${lineCount} line${lineCount === 1 ? "" : "s"}`;
|
|
29666
|
+
const elapsedPill = widget.querySelector(".release-npm-pill.elapsed");
|
|
29667
|
+
const elapsed = appRunnerElapsedLabel(nextRun);
|
|
29668
|
+
if (elapsedPill && elapsed && elapsedPill.textContent !== elapsed) elapsedPill.textContent = elapsed;
|
|
29669
|
+
// Keep the terminal pinned to the bottom when it was already there.
|
|
29670
|
+
if (terminal.scrollHeight - terminal.scrollTop - terminal.clientHeight < 40) terminal.scrollTop = terminal.scrollHeight;
|
|
29671
|
+
return true;
|
|
29672
|
+
}
|
|
29673
|
+
|
|
28522
29674
|
function renderAppRunnerWidget() {
|
|
28523
29675
|
const data = activeAppRunnerData();
|
|
28524
29676
|
const run = data.activeRun;
|
|
@@ -31218,7 +32370,7 @@ function renderGitWorkflow() {
|
|
|
31218
32370
|
}
|
|
31219
32371
|
} else if (gitWorkflow.step === "generate") {
|
|
31220
32372
|
const commitInputButton = renderGitWorkflowManualCommitInput({ appendCommitButton: false });
|
|
31221
|
-
addGitWorkflowAction("
|
|
32373
|
+
addGitWorkflowAction("Generate commit message", () => runGitMessagePrompt(), "primary", false);
|
|
31222
32374
|
addGitWorkflowAction("Preview current message files", () => loadGitWorkflowMessage({ requireFresh: false }), "", false);
|
|
31223
32375
|
elements.gitWorkflowActions.append(commitInputButton);
|
|
31224
32376
|
} else if (gitWorkflow.step === "generating") {
|
|
@@ -31252,7 +32404,7 @@ function renderGitWorkflow() {
|
|
|
31252
32404
|
addGitWorkflowAction("Refresh PR description", () => loadGitWorkflowPr({ requireFresh: true }), "", false);
|
|
31253
32405
|
} else if (gitWorkflow.step === "prReview") {
|
|
31254
32406
|
addGitWorkflowAction("Create PR", () => createGitPrFromReview(), "primary", false);
|
|
31255
|
-
addGitWorkflowAction("Regenerate
|
|
32407
|
+
addGitWorkflowAction("Regenerate PR text", () => runGitPrPrompt(), "", false);
|
|
31256
32408
|
} else if (gitWorkflow.step === "prCreating") {
|
|
31257
32409
|
addGitWorkflowAction("Creating PR…", () => {}, "primary", true);
|
|
31258
32410
|
} else if (gitWorkflow.step === "done") {
|
|
@@ -31713,7 +32865,7 @@ async function promptGitInitReadme(status, { runId, tabId }) {
|
|
|
31713
32865
|
try {
|
|
31714
32866
|
await api("/api/prompt", { method: "POST", body: { message: gitInitReadmePromptMessage({ stack, status, repoName }) }, tabId });
|
|
31715
32867
|
if (!isCurrentGitWorkflowRun(runId, tabId)) return;
|
|
31716
|
-
appendGitWorkflowOutput("README.md request accepted. Waiting for
|
|
32868
|
+
appendGitWorkflowOutput("README.md request accepted. Waiting for Pi to finish, then README.md/.gitignore will be checked and staged. If Pi does not create README.md, Web UI will use a minimal fallback README.", { tabId });
|
|
31717
32869
|
if (isCurrentTabContext(tabContext)) scheduleRefreshState(120, tabContext);
|
|
31718
32870
|
setTimeout(() => {
|
|
31719
32871
|
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
@@ -31755,7 +32907,7 @@ async function promptGitInitGitignore(status, { runId, tabId }) {
|
|
|
31755
32907
|
try {
|
|
31756
32908
|
await api("/api/prompt", { method: "POST", body: { message: gitInitGitignorePromptMessage({ stack, status, repoName }) }, tabId });
|
|
31757
32909
|
if (!isCurrentGitWorkflowRun(runId, tabId)) return;
|
|
31758
|
-
appendGitWorkflowOutput(".gitignore request accepted. Waiting for
|
|
32910
|
+
appendGitWorkflowOutput(".gitignore request accepted. Waiting for Pi to finish, then README.md/.gitignore will be staged. If Pi does not create .gitignore, Web UI will use sane fallback patterns.", { tabId });
|
|
31759
32911
|
if (isCurrentTabContext(tabContext)) scheduleRefreshState(120, tabContext);
|
|
31760
32912
|
setTimeout(() => {
|
|
31761
32913
|
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
@@ -32009,16 +33161,16 @@ async function runGitMessagePrompt(tabId = gitWorkflowActionTabId()) {
|
|
|
32009
33161
|
error: "",
|
|
32010
33162
|
messageRequestedAt: requestedAt,
|
|
32011
33163
|
messageGenerationId: "",
|
|
32012
|
-
output: "
|
|
33164
|
+
output: "Asking Pi to write the commit message…\n\nCancel stops the request.",
|
|
32013
33165
|
}, { tabId });
|
|
32014
|
-
if (isCurrentTabContext(tabContext)) setRunIndicatorActivity("
|
|
33166
|
+
if (isCurrentTabContext(tabContext)) setRunIndicatorActivity("Generating commit message…");
|
|
32015
33167
|
try {
|
|
32016
33168
|
const generation = await gitWorkflowRequest("/api/git-workflow/generate", { body: { kind: "commit", ...(expectedStagedContentHash ? { expectedStagedContentHash } : {}) }, runId, tabId });
|
|
32017
33169
|
if (!generation || !isCurrentGitWorkflowRun(runId, tabId)) return;
|
|
32018
33170
|
const generationId = String(generation.generationId || "").trim();
|
|
32019
33171
|
if (!generationId) throw new Error("The WebUI server did not return a commit-message generation ID. Restart Pi Web UI and regenerate.");
|
|
32020
33172
|
setGitWorkflow({ messageGenerationId: generationId }, { tabId });
|
|
32021
|
-
appendGitWorkflowOutput(
|
|
33173
|
+
appendGitWorkflowOutput(`Commit message generation started with ${generation.generation.provider}/${generation.generation.modelId} at ${generation.generation.thinkingLevel} effort. Waiting for Pi to finish, then the short and long messages will be loaded.`, { tabId });
|
|
32022
33174
|
if (isCurrentTabContext(tabContext)) scheduleRefreshState(120, tabContext);
|
|
32023
33175
|
setTimeout(() => {
|
|
32024
33176
|
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
@@ -32180,7 +33332,7 @@ async function runGitBranchNamePrompt(tabId = gitWorkflowActionTabId()) {
|
|
|
32180
33332
|
try {
|
|
32181
33333
|
const generation = await gitWorkflowRequest("/api/git-workflow/generate", { body: { kind: "branch", ...(expectedStagedContentHash ? { expectedStagedContentHash } : {}) }, runId, tabId });
|
|
32182
33334
|
if (!generation || !isCurrentGitWorkflowRun(runId, tabId)) return;
|
|
32183
|
-
appendGitWorkflowOutput(`Branch-name request accepted with ${generation.generation.provider}/${generation.generation.modelId} at ${generation.generation.thinkingLevel} effort. Waiting for
|
|
33335
|
+
appendGitWorkflowOutput(`Branch-name request accepted with ${generation.generation.provider}/${generation.generation.modelId} at ${generation.generation.thinkingLevel} effort. Waiting for Pi to finish, then the branch name will be loaded.`, { tabId });
|
|
32184
33336
|
if (isCurrentTabContext(tabContext)) scheduleRefreshState(120, tabContext);
|
|
32185
33337
|
setTimeout(() => {
|
|
32186
33338
|
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
@@ -32252,7 +33404,7 @@ async function createGitPrBranchWithSuggestion(suggestion, tabId = gitWorkflowAc
|
|
|
32252
33404
|
const workflow = gitWorkflowForTab(tabId, { create: false });
|
|
32253
33405
|
if (!workflow) return;
|
|
32254
33406
|
const sourceWorkflow = { ...workflow, actionsDone: createGitWorkflowActionsDone(workflow.actionsDone) };
|
|
32255
|
-
const proposedBranch =
|
|
33407
|
+
const proposedBranch = await appPromptText({ title: "New PR branch worktree", summary: "Branch name for the pull-request worktree (example: type/feature-name).", defaultValue: suggestion || defaultGitPrBranchName(workflow.message), confirmLabel: "Create worktree" });
|
|
32256
33408
|
if (expectedRunId !== undefined && !isCurrentGitWorkflowRun(expectedRunId, tabId)) return;
|
|
32257
33409
|
if (proposedBranch === null) {
|
|
32258
33410
|
setGitWorkflow({ step: "message", busy: false, output: `${formatCommitMessagePreview(sourceWorkflow.message)}\n\nPR branch worktree creation cancelled. Use Create PR worktree to generate a branch name again or Manual worktree to type one.` }, { tabId });
|
|
@@ -32523,7 +33675,7 @@ async function runGitPrPrompt(tabId = gitWorkflowActionTabId(), { prefixOutput =
|
|
|
32523
33675
|
try {
|
|
32524
33676
|
const generation = await gitWorkflowRequest("/api/git-workflow/generate", { body: { kind: "pr" }, runId, tabId });
|
|
32525
33677
|
if (!generation || !isCurrentGitWorkflowRun(runId, tabId)) return;
|
|
32526
|
-
appendGitWorkflowOutput(
|
|
33678
|
+
appendGitWorkflowOutput(`PR text generation started with ${generation.generation.provider}/${generation.generation.modelId} at ${generation.generation.thinkingLevel} effort. Waiting for Pi to finish, then the PR description will be loaded.`, { tabId });
|
|
32527
33679
|
if (isCurrentTabContext(tabContext)) scheduleRefreshState(120, tabContext);
|
|
32528
33680
|
setTimeout(() => {
|
|
32529
33681
|
const currentWorkflow = gitWorkflowForTab(tabId, { create: false });
|
|
@@ -33641,9 +34793,22 @@ function appendInlineMarkdown(parent, text, depth = 0) {
|
|
|
33641
34793
|
continue;
|
|
33642
34794
|
}
|
|
33643
34795
|
}
|
|
34796
|
+
if (value[index] === "h" && (value.startsWith("http://", index) || value.startsWith("https://", index)) && !isMarkdownWordCharacter(value[index - 1])) {
|
|
34797
|
+
const match = value.slice(index).match(MARKDOWN_BARE_URL_REGEX);
|
|
34798
|
+
const href = match ? trimBareUrl(match[0]) : "";
|
|
34799
|
+
const safeHref = href ? safeMarkdownLinkHref(href) : "";
|
|
34800
|
+
if (safeHref) {
|
|
34801
|
+
const link = make("a");
|
|
34802
|
+
configureMarkdownLink(link, safeHref);
|
|
34803
|
+
link.textContent = href;
|
|
34804
|
+
parent.append(link);
|
|
34805
|
+
index += href.length;
|
|
34806
|
+
continue;
|
|
34807
|
+
}
|
|
34808
|
+
}
|
|
33644
34809
|
const strongMarker = value.startsWith("**", index) ? "**" : value.startsWith("__", index) ? "__" : "";
|
|
33645
|
-
if (strongMarker) {
|
|
33646
|
-
const end = value
|
|
34810
|
+
if (strongMarker && markdownCanOpenEmphasis(value, index, strongMarker)) {
|
|
34811
|
+
const end = findMarkdownEmphasisClose(value, index + 2, strongMarker);
|
|
33647
34812
|
if (end > index + 2) {
|
|
33648
34813
|
const strong = make("strong");
|
|
33649
34814
|
appendInlineMarkdown(strong, value.slice(index + 2, end), depth + 1);
|
|
@@ -33663,8 +34828,8 @@ function appendInlineMarkdown(parent, text, depth = 0) {
|
|
|
33663
34828
|
}
|
|
33664
34829
|
}
|
|
33665
34830
|
const emphasisMarker = value[index] === "*" || value[index] === "_" ? value[index] : "";
|
|
33666
|
-
if (emphasisMarker && value[index + 1] !== emphasisMarker) {
|
|
33667
|
-
const end = value
|
|
34831
|
+
if (emphasisMarker && value[index + 1] !== emphasisMarker && markdownCanOpenEmphasis(value, index, emphasisMarker)) {
|
|
34832
|
+
const end = findMarkdownEmphasisClose(value, index + 1, emphasisMarker);
|
|
33668
34833
|
if (end > index + 1) {
|
|
33669
34834
|
const em = make("em");
|
|
33670
34835
|
appendInlineMarkdown(em, value.slice(index + 1, end), depth + 1);
|
|
@@ -33673,13 +34838,59 @@ function appendInlineMarkdown(parent, text, depth = 0) {
|
|
|
33673
34838
|
continue;
|
|
33674
34839
|
}
|
|
33675
34840
|
}
|
|
33676
|
-
const nextSpecials = ["`", "[", "**", "__", "~~", "*", "_"]
|
|
34841
|
+
const nextSpecials = ["`", "[", "**", "__", "~~", "*", "_", "http://", "https://"]
|
|
33677
34842
|
.map((marker) => value.indexOf(marker, index + 1))
|
|
33678
34843
|
.filter((pos) => pos !== -1);
|
|
33679
34844
|
appendPlain(nextSpecials.length ? Math.min(...nextSpecials) : value.length);
|
|
33680
34845
|
}
|
|
33681
34846
|
}
|
|
33682
34847
|
|
|
34848
|
+
// CommonMark-ish flanking rules so identifiers such as snake_case_name, MAX_RETRY_COUNT or
|
|
34849
|
+
// 2*3*4 stop turning into emphasis. `_` never opens/closes inside a word; `*` may not open
|
|
34850
|
+
// before whitespace or close after whitespace.
|
|
34851
|
+
const MARKDOWN_BARE_URL_REGEX = /^https?:\/\/[^\s<>"'`]+/;
|
|
34852
|
+
|
|
34853
|
+
function isMarkdownWordCharacter(character) {
|
|
34854
|
+
return Boolean(character) && /[\p{L}\p{N}_]/u.test(character);
|
|
34855
|
+
}
|
|
34856
|
+
|
|
34857
|
+
function markdownCanOpenEmphasis(value, index, marker) {
|
|
34858
|
+
const after = value[index + marker.length];
|
|
34859
|
+
if (!after || /\s/.test(after)) return false;
|
|
34860
|
+
if (marker[0] === "_" && isMarkdownWordCharacter(value[index - 1])) return false;
|
|
34861
|
+
return true;
|
|
34862
|
+
}
|
|
34863
|
+
|
|
34864
|
+
function markdownCanCloseEmphasis(value, index, marker) {
|
|
34865
|
+
const before = value[index - 1];
|
|
34866
|
+
if (!before || /\s/.test(before)) return false;
|
|
34867
|
+
if (marker[0] === "_" && isMarkdownWordCharacter(value[index + marker.length])) return false;
|
|
34868
|
+
return true;
|
|
34869
|
+
}
|
|
34870
|
+
|
|
34871
|
+
function findMarkdownEmphasisClose(value, from, marker) {
|
|
34872
|
+
let cursor = from;
|
|
34873
|
+
while (cursor < value.length) {
|
|
34874
|
+
const candidate = value.indexOf(marker, cursor);
|
|
34875
|
+
if (candidate === -1) return -1;
|
|
34876
|
+
// Skip runs longer than the marker (e.g. "***" when looking for "*") — they are not a clean close.
|
|
34877
|
+
const runEnd = candidate + marker.length;
|
|
34878
|
+
const overlong = marker.length === 1 && value[runEnd] === marker;
|
|
34879
|
+
if (!overlong && markdownCanCloseEmphasis(value, candidate, marker)) return candidate;
|
|
34880
|
+
cursor = overlong ? runEnd + 1 : candidate + 1;
|
|
34881
|
+
}
|
|
34882
|
+
return -1;
|
|
34883
|
+
}
|
|
34884
|
+
|
|
34885
|
+
function trimBareUrl(url) {
|
|
34886
|
+
let text = String(url || "");
|
|
34887
|
+
// Trailing punctuation usually belongs to the sentence, not the link.
|
|
34888
|
+
while (/[.,;:!?'"]$/.test(text)) text = text.slice(0, -1);
|
|
34889
|
+
// Balance closing parentheses (Wikipedia-style links keep their own parens).
|
|
34890
|
+
while (text.endsWith(")") && (text.match(/\(/g) || []).length < (text.match(/\)/g) || []).length) text = text.slice(0, -1);
|
|
34891
|
+
return text;
|
|
34892
|
+
}
|
|
34893
|
+
|
|
33683
34894
|
function appendMarkdownParagraph(parent, lines) {
|
|
33684
34895
|
const paragraph = make("p");
|
|
33685
34896
|
lines.forEach((line, index) => {
|
|
@@ -33893,7 +35104,11 @@ function appendMarkdownMermaidBlock(parent, code) {
|
|
|
33893
35104
|
// reproduces the source exactly, and unknown/oversized blocks fall back to one
|
|
33894
35105
|
// plain token so copy, selection, and transcript search stay unchanged.
|
|
33895
35106
|
function appendMarkdownCodeTokens(codeNode, source, language) {
|
|
35107
|
+
const profileStart = streamIsolationDebugLedger ? performance.now() : 0;
|
|
33896
35108
|
const tokens = tokenizeCode(source, normalizedMarkdownLanguage(language));
|
|
35109
|
+
if (streamIsolationDebugLedger) {
|
|
35110
|
+
recordStreamProfileDiagnostic({ type: "tokenize", ms: performance.now() - profileStart, bytes: streamDiagnosticBytes(source), language: String(language || "") });
|
|
35111
|
+
}
|
|
33897
35112
|
if (!tokens.length) {
|
|
33898
35113
|
codeNode.textContent = source;
|
|
33899
35114
|
return;
|
|
@@ -33958,13 +35173,84 @@ function appendMarkdownTable(parent, rows) {
|
|
|
33958
35173
|
}
|
|
33959
35174
|
|
|
33960
35175
|
function markdownListMatch(line) {
|
|
33961
|
-
const unordered = line.match(
|
|
33962
|
-
if (unordered) return { ordered: false, text: unordered[1] };
|
|
33963
|
-
const ordered = line.match(
|
|
33964
|
-
if (ordered) return { ordered: true, start: Number(ordered[
|
|
35176
|
+
const unordered = line.match(/^(\s*)[-*+]\s+(.+)$/);
|
|
35177
|
+
if (unordered) return { ordered: false, text: unordered[2], indent: unordered[1].replace(/\t/g, " ").length, markerWidth: 2 };
|
|
35178
|
+
const ordered = line.match(/^(\s*)(\d+)[.)]\s+(.+)$/);
|
|
35179
|
+
if (ordered) return { ordered: true, start: Number(ordered[2]), text: ordered[3], indent: ordered[1].replace(/\t/g, " ").length, markerWidth: ordered[2].length + 2 };
|
|
33965
35180
|
return null;
|
|
33966
35181
|
}
|
|
33967
35182
|
|
|
35183
|
+
// Builds nested lists from a block of list lines using indentation: a marker line indented at
|
|
35184
|
+
// least two columns deeper than the current list starts a child list of the previous item;
|
|
35185
|
+
// indented non-marker lines continue the previous item's text.
|
|
35186
|
+
function parseMarkdownListTree(blockLines) {
|
|
35187
|
+
const lists = [];
|
|
35188
|
+
const stack = [];
|
|
35189
|
+
let lastItem = null;
|
|
35190
|
+
const newList = (match) => ({ ordered: match.ordered, start: match.ordered ? match.start : null, items: [], indent: match.indent });
|
|
35191
|
+
for (const line of blockLines) {
|
|
35192
|
+
const match = markdownListMatch(line);
|
|
35193
|
+
if (!match) {
|
|
35194
|
+
if (lastItem && line.trim()) lastItem.text += `\n${line.trim()}`;
|
|
35195
|
+
continue;
|
|
35196
|
+
}
|
|
35197
|
+
while (stack.length && match.indent < stack[stack.length - 1].indent) stack.pop();
|
|
35198
|
+
let top = stack[stack.length - 1];
|
|
35199
|
+
if (!top) {
|
|
35200
|
+
top = newList(match);
|
|
35201
|
+
lists.push(top);
|
|
35202
|
+
stack.push(top);
|
|
35203
|
+
} else if (match.indent >= top.indent + 2 && lastItem && lastItem.list === top) {
|
|
35204
|
+
top = newList(match);
|
|
35205
|
+
lastItem.children.push(top);
|
|
35206
|
+
stack.push(top);
|
|
35207
|
+
} else if (top.ordered !== match.ordered) {
|
|
35208
|
+
stack.pop();
|
|
35209
|
+
top = newList(match);
|
|
35210
|
+
const parentList = stack[stack.length - 1];
|
|
35211
|
+
const owner = parentList?.items[parentList.items.length - 1];
|
|
35212
|
+
if (owner) owner.children.push(top);
|
|
35213
|
+
else lists.push(top);
|
|
35214
|
+
stack.push(top);
|
|
35215
|
+
}
|
|
35216
|
+
const item = { text: match.text, children: [], list: top };
|
|
35217
|
+
top.items.push(item);
|
|
35218
|
+
lastItem = item;
|
|
35219
|
+
}
|
|
35220
|
+
return lists;
|
|
35221
|
+
}
|
|
35222
|
+
|
|
35223
|
+
function appendMarkdownListTree(parent, tree) {
|
|
35224
|
+
const build = (list) => {
|
|
35225
|
+
const element = make(list.ordered ? "ol" : "ul", "markdown-list");
|
|
35226
|
+
if (list.ordered && Number.isFinite(list.start) && list.start > 1) element.start = list.start;
|
|
35227
|
+
for (const item of list.items) {
|
|
35228
|
+
const li = make("li");
|
|
35229
|
+
const [firstLine, ...moreLines] = String(item.text).split("\n");
|
|
35230
|
+
const task = firstLine.match(/^\[( |x|X|-)\]\s+(.+)$/);
|
|
35231
|
+
if (task) {
|
|
35232
|
+
li.classList.add("markdown-task-item");
|
|
35233
|
+
const checkbox = make("input", "markdown-task-checkbox");
|
|
35234
|
+
checkbox.type = "checkbox";
|
|
35235
|
+
checkbox.disabled = true;
|
|
35236
|
+
checkbox.checked = task[1].toLowerCase() === "x";
|
|
35237
|
+
li.append(checkbox);
|
|
35238
|
+
appendInlineMarkdown(li, task[2]);
|
|
35239
|
+
} else {
|
|
35240
|
+
appendInlineMarkdown(li, firstLine);
|
|
35241
|
+
}
|
|
35242
|
+
for (const extra of moreLines) {
|
|
35243
|
+
li.append(make("br"));
|
|
35244
|
+
appendInlineMarkdown(li, extra);
|
|
35245
|
+
}
|
|
35246
|
+
for (const child of item.children) li.append(build(child));
|
|
35247
|
+
element.append(li);
|
|
35248
|
+
}
|
|
35249
|
+
return element;
|
|
35250
|
+
};
|
|
35251
|
+
for (const list of tree) parent.append(build(list));
|
|
35252
|
+
}
|
|
35253
|
+
|
|
33968
35254
|
function appendMarkdownList(parent, items, ordered = false, start = null) {
|
|
33969
35255
|
const list = make(ordered ? "ol" : "ul", "markdown-list");
|
|
33970
35256
|
if (ordered && Number.isFinite(start) && start > 1) list.start = start;
|
|
@@ -34004,13 +35290,15 @@ function renderMarkdownInto(parent, text) {
|
|
|
34004
35290
|
index += 1;
|
|
34005
35291
|
continue;
|
|
34006
35292
|
}
|
|
34007
|
-
const fence = line.match(/^\s
|
|
35293
|
+
const fence = line.match(/^\s*(`{3,}|~{3,})\s*([\w.+-]*)\s*$/);
|
|
34008
35294
|
if (fence) {
|
|
34009
35295
|
flushParagraph();
|
|
34010
|
-
const
|
|
35296
|
+
const delimiter = fence[1];
|
|
35297
|
+
const language = fence[2] || "";
|
|
35298
|
+
const closingFence = new RegExp(`^\\s*${delimiter[0] === "~" ? "~" : "\`"}{${delimiter.length},}\\s*$`);
|
|
34011
35299
|
const codeLines = [];
|
|
34012
35300
|
index += 1;
|
|
34013
|
-
while (index < lines.length &&
|
|
35301
|
+
while (index < lines.length && !closingFence.test(lines[index])) {
|
|
34014
35302
|
codeLines.push(lines[index]);
|
|
34015
35303
|
index += 1;
|
|
34016
35304
|
}
|
|
@@ -34061,16 +35349,25 @@ function renderMarkdownInto(parent, text) {
|
|
|
34061
35349
|
const listMatch = markdownListMatch(line);
|
|
34062
35350
|
if (listMatch) {
|
|
34063
35351
|
flushParagraph();
|
|
34064
|
-
|
|
34065
|
-
|
|
34066
|
-
const
|
|
35352
|
+
// Collect the whole list block: marker lines plus indented continuation lines. A blank line
|
|
35353
|
+
// followed by an indented line stays in the list (loose list); anything else ends it.
|
|
35354
|
+
const blockLines = [];
|
|
34067
35355
|
while (index < lines.length) {
|
|
34068
|
-
const
|
|
34069
|
-
if (
|
|
34070
|
-
|
|
34071
|
-
|
|
35356
|
+
const current = lines[index];
|
|
35357
|
+
if (markdownListMatch(current) || (blockLines.length && /^\s{2,}\S/.test(current))) {
|
|
35358
|
+
blockLines.push(current);
|
|
35359
|
+
index += 1;
|
|
35360
|
+
continue;
|
|
35361
|
+
}
|
|
35362
|
+
if (!current.trim() && blockLines.length && index + 1 < lines.length && /^\s{2,}\S/.test(lines[index + 1]) && (markdownListMatch(lines[index + 1]) || true)) {
|
|
35363
|
+
blockLines.push("");
|
|
35364
|
+
index += 1;
|
|
35365
|
+
continue;
|
|
35366
|
+
}
|
|
35367
|
+
break;
|
|
34072
35368
|
}
|
|
34073
|
-
|
|
35369
|
+
while (blockLines.length && !blockLines[blockLines.length - 1].trim()) blockLines.pop();
|
|
35370
|
+
appendMarkdownListTree(parent, parseMarkdownListTree(blockLines));
|
|
34074
35371
|
continue;
|
|
34075
35372
|
}
|
|
34076
35373
|
paragraph.push(line);
|
|
@@ -34092,51 +35389,127 @@ function renderMarkdown(block, text) {
|
|
|
34092
35389
|
}
|
|
34093
35390
|
|
|
34094
35391
|
/**
|
|
34095
|
-
*
|
|
34096
|
-
*
|
|
34097
|
-
*
|
|
34098
|
-
*
|
|
34099
|
-
* open tail is re-parsed per streaming tick, keeping per-tick cost flat
|
|
34100
|
-
* instead of O(message length).
|
|
35392
|
+
* Streaming Markdown keeps the boundary automaton in transcript-owned
|
|
35393
|
+
* per-surface state. The scanner consumes only appended suffixes; open fences
|
|
35394
|
+
* and bounded-fallback tails reuse one mounted live subtree until an
|
|
35395
|
+
* authoritative close/completion render.
|
|
34101
35396
|
*/
|
|
34102
|
-
|
|
34103
|
-
|
|
34104
|
-
function streamingMarkdownStableBoundary(text) {
|
|
34105
|
-
const lines = text.split("\n");
|
|
34106
|
-
let inFence = false;
|
|
34107
|
-
let boundary = 0;
|
|
34108
|
-
let offset = 0;
|
|
34109
|
-
// Exclude the final line: it may still be streaming in.
|
|
34110
|
-
for (let index = 0; index < lines.length - 1; index += 1) {
|
|
34111
|
-
const line = lines[index];
|
|
34112
|
-
if (inFence) {
|
|
34113
|
-
if (/^\s*```\s*$/.test(line)) inFence = false;
|
|
34114
|
-
} else if (/^\s*```\s*[\w.+-]*\s*$/.test(line)) {
|
|
34115
|
-
inFence = true;
|
|
34116
|
-
}
|
|
34117
|
-
offset += line.length + 1;
|
|
34118
|
-
if (!inFence && !line.trim()) boundary = offset;
|
|
34119
|
-
}
|
|
34120
|
-
return boundary;
|
|
35397
|
+
function streamingMarkdownStableBoundary(text, previousState, options) {
|
|
35398
|
+
return advanceStreamingMarkdownTail(previousState, text, options);
|
|
34121
35399
|
}
|
|
34122
35400
|
|
|
34123
35401
|
function clearStreamingMarkdownBlock(block) {
|
|
34124
35402
|
while (block.firstChild) block.firstChild.remove();
|
|
34125
35403
|
}
|
|
34126
35404
|
|
|
34127
|
-
function
|
|
35405
|
+
function streamingLiveCodeSource(tail, boundaryInfo) {
|
|
35406
|
+
const relativeOffset = Math.max(0, Number(boundaryInfo.fenceContentOffset) - Number(boundaryInfo.boundary));
|
|
35407
|
+
return String(tail || "").slice(relativeOffset).replace(/\n+$/g, "");
|
|
35408
|
+
}
|
|
35409
|
+
|
|
35410
|
+
function syncStreamingLiveCodeLanguage(wrapper, codeNode, language) {
|
|
35411
|
+
const value = String(language || "");
|
|
35412
|
+
let label = wrapper.querySelector(":scope > .markdown-code-language");
|
|
35413
|
+
if (value && !label) {
|
|
35414
|
+
label = make("div", "markdown-code-language");
|
|
35415
|
+
wrapper.prepend(label);
|
|
35416
|
+
}
|
|
35417
|
+
if (label) {
|
|
35418
|
+
label.textContent = value;
|
|
35419
|
+
if (!value) label.remove();
|
|
35420
|
+
}
|
|
35421
|
+
codeNode.className = value ? `language-${value.replace(/[^a-z0-9_-]/gi, "")}` : "";
|
|
35422
|
+
}
|
|
35423
|
+
|
|
35424
|
+
function renderStreamingMarkdownLiveTail(parent, tail, boundaryInfo) {
|
|
35425
|
+
if (boundaryInfo.liveMode === "open-fence") {
|
|
35426
|
+
const wrapper = make("div", "markdown-code-block");
|
|
35427
|
+
const pre = make("pre", "code-block markdown-code");
|
|
35428
|
+
const codeNode = make("code");
|
|
35429
|
+
codeNode.append(document.createTextNode(streamingLiveCodeSource(tail, boundaryInfo)));
|
|
35430
|
+
pre.append(codeNode);
|
|
35431
|
+
wrapper.append(pre);
|
|
35432
|
+
syncStreamingLiveCodeLanguage(wrapper, codeNode, boundaryInfo.fenceLanguage);
|
|
35433
|
+
attachMarkdownCodeCopyButton(wrapper);
|
|
35434
|
+
parent.append(wrapper);
|
|
35435
|
+
return;
|
|
35436
|
+
}
|
|
35437
|
+
const paragraph = make("p", "streaming-markdown-plain-tail");
|
|
35438
|
+
paragraph.append(document.createTextNode(String(tail || "")));
|
|
35439
|
+
parent.append(paragraph);
|
|
35440
|
+
}
|
|
35441
|
+
|
|
35442
|
+
function appendStreamingMarkdownLiveTail(nodes, previousTail, tail, boundaryInfo) {
|
|
35443
|
+
const root = nodes.find((node) => node.nodeType === Node.ELEMENT_NODE);
|
|
35444
|
+
const textNode = boundaryInfo.liveMode === "open-fence"
|
|
35445
|
+
? root?.querySelector(":scope > pre.markdown-code > code")?.firstChild
|
|
35446
|
+
: root?.firstChild;
|
|
35447
|
+
const value = boundaryInfo.liveMode === "open-fence"
|
|
35448
|
+
? streamingLiveCodeSource(tail, boundaryInfo)
|
|
35449
|
+
: String(tail || "");
|
|
35450
|
+
if (!textNode || textNode.nodeType !== Node.TEXT_NODE) return;
|
|
35451
|
+
if (boundaryInfo.liveMode === "open-fence") {
|
|
35452
|
+
const codeNode = textNode.parentElement;
|
|
35453
|
+
syncStreamingLiveCodeLanguage(root, codeNode, boundaryInfo.fenceLanguage);
|
|
35454
|
+
}
|
|
35455
|
+
if (value.startsWith(textNode.data)) textNode.appendData(value.slice(textNode.data.length));
|
|
35456
|
+
else textNode.data = value;
|
|
35457
|
+
}
|
|
35458
|
+
|
|
35459
|
+
function renderStreamingMarkdown(block, text, { complete = false } = {}) {
|
|
35460
|
+
const profileStart = streamIsolationDebugLedger ? performance.now() : 0;
|
|
34128
35461
|
const selectionSnapshot = captureChatTextSelection(block);
|
|
34129
35462
|
const bubble = block?.closest(".message");
|
|
34130
|
-
transcriptRenderer.reconcileMarkdownSurface({
|
|
35463
|
+
const result = transcriptRenderer.reconcileMarkdownSurface({
|
|
34131
35464
|
key: `stream:${bubble?.dataset?.transcriptMessageKey || bubble?.dataset?.itemKey || "assistant"}`,
|
|
34132
35465
|
surface: block,
|
|
34133
35466
|
messageKey: bubble?.dataset?.transcriptMessageKey || bubble?.dataset?.itemKey || "live:assistant",
|
|
34134
35467
|
kind: "assistant-final",
|
|
34135
35468
|
text,
|
|
35469
|
+
complete,
|
|
34136
35470
|
stableBoundary: streamingMarkdownStableBoundary,
|
|
34137
35471
|
renderInto: renderMarkdownInto,
|
|
35472
|
+
renderLiveTail: renderStreamingMarkdownLiveTail,
|
|
35473
|
+
appendLiveTail: appendStreamingMarkdownLiveTail,
|
|
34138
35474
|
});
|
|
34139
35475
|
restoreChatTextSelection(selectionSnapshot);
|
|
35476
|
+
if (streamIsolationDebugLedger) {
|
|
35477
|
+
const tailBytes = Math.max(0, streamDiagnosticBytes(text) - (Number(result.boundary) || 0) * 2);
|
|
35478
|
+
recordStreamProfileDiagnostic({ type: "markdown-commit", ms: performance.now() - profileStart, textBytes: streamDiagnosticBytes(text), tailBytes, tailKind: result.tailKind, boundaryScannedChars: result.scannedChars, reusedTail: result.reusedTail, authoritative: complete || result.liveMode === "authoritative" });
|
|
35479
|
+
}
|
|
35480
|
+
}
|
|
35481
|
+
|
|
35482
|
+
// Minimal lightbox: click an inline/transcript image (or attachment thumbnail) to view it large.
|
|
35483
|
+
let imageLightbox = null;
|
|
35484
|
+
function openImageLightbox(src, alt = "") {
|
|
35485
|
+
if (!src) return;
|
|
35486
|
+
if (!imageLightbox) {
|
|
35487
|
+
imageLightbox = document.createElement("dialog");
|
|
35488
|
+
imageLightbox.className = "image-lightbox";
|
|
35489
|
+
imageLightbox.setAttribute("aria-label", "Image preview");
|
|
35490
|
+
const figure = document.createElement("figure");
|
|
35491
|
+
const image = document.createElement("img");
|
|
35492
|
+
const caption = document.createElement("figcaption");
|
|
35493
|
+
const close = document.createElement("button");
|
|
35494
|
+
close.type = "button";
|
|
35495
|
+
close.className = "image-lightbox-close";
|
|
35496
|
+
close.textContent = "×";
|
|
35497
|
+
close.setAttribute("aria-label", "Close image preview");
|
|
35498
|
+
close.addEventListener("click", () => imageLightbox.close());
|
|
35499
|
+
imageLightbox.addEventListener("click", (event) => {
|
|
35500
|
+
if (event.target === imageLightbox) imageLightbox.close();
|
|
35501
|
+
});
|
|
35502
|
+
figure.append(image, caption);
|
|
35503
|
+
imageLightbox.append(close, figure);
|
|
35504
|
+
document.body.append(imageLightbox);
|
|
35505
|
+
}
|
|
35506
|
+
const image = imageLightbox.querySelector("img");
|
|
35507
|
+
const caption = imageLightbox.querySelector("figcaption");
|
|
35508
|
+
image.src = src;
|
|
35509
|
+
image.alt = alt || "";
|
|
35510
|
+
caption.textContent = alt || "";
|
|
35511
|
+
caption.hidden = !alt;
|
|
35512
|
+
if (!imageLightbox.open) imageLightbox.showModal();
|
|
34140
35513
|
}
|
|
34141
35514
|
|
|
34142
35515
|
function appendImage(parent, part) {
|
|
@@ -34147,7 +35520,14 @@ function appendImage(parent, part) {
|
|
|
34147
35520
|
img.style.maxWidth = "100%";
|
|
34148
35521
|
img.style.borderRadius = "0.6rem";
|
|
34149
35522
|
img.src = `data:${part.mimeType || "image/png"};base64,${part.data || part.content || ""}`;
|
|
34150
|
-
|
|
35523
|
+
// Click/Enter opens the image at full size (transcript images used to be view-only thumbnails).
|
|
35524
|
+
const button = make("button", "image-block-button");
|
|
35525
|
+
button.type = "button";
|
|
35526
|
+
button.title = "Open image at full size";
|
|
35527
|
+
button.setAttribute("aria-label", "Open image at full size");
|
|
35528
|
+
button.append(img);
|
|
35529
|
+
button.addEventListener("click", () => openImageLightbox(img.src, "attached image"));
|
|
35530
|
+
wrapper.append(button);
|
|
34151
35531
|
parent.append(wrapper);
|
|
34152
35532
|
}
|
|
34153
35533
|
|
|
@@ -34225,7 +35605,7 @@ async function sendLiveActionFeedback(item) {
|
|
|
34225
35605
|
if (isCurrentTabContext(tabContext)) addEvent(`sent ${ACTION_FEEDBACK_REACTIONS[item.reaction]?.icon || "feedback"} action feedback as live steering`);
|
|
34226
35606
|
}
|
|
34227
35607
|
|
|
34228
|
-
function setActionFeedback(message, messageIndex, reaction) {
|
|
35608
|
+
async function setActionFeedback(message, messageIndex, reaction) {
|
|
34229
35609
|
const tabId = activeTabId;
|
|
34230
35610
|
if (!tabId || !ACTION_FEEDBACK_REACTIONS[reaction]) return;
|
|
34231
35611
|
const key = actionFeedbackKey(message, messageIndex);
|
|
@@ -34233,7 +35613,7 @@ function setActionFeedback(message, messageIndex, reaction) {
|
|
|
34233
35613
|
const existing = map.get(key);
|
|
34234
35614
|
let comment = existing?.comment || "";
|
|
34235
35615
|
if (reaction === "down") {
|
|
34236
|
-
const nextComment =
|
|
35616
|
+
const nextComment = await appPromptText({ title: "What should Pi avoid?", summary: "Optional note sent with the thumbs-down feedback.", defaultValue: comment, confirmLabel: "Send feedback" });
|
|
34237
35617
|
if (nextComment === null) return;
|
|
34238
35618
|
comment = nextComment.trim();
|
|
34239
35619
|
}
|
|
@@ -34330,7 +35710,7 @@ function renderActionFeedbackControls(bubble, message, messageIndex) {
|
|
|
34330
35710
|
button.addEventListener("click", (event) => {
|
|
34331
35711
|
event.preventDefault();
|
|
34332
35712
|
event.stopPropagation();
|
|
34333
|
-
setActionFeedback(message, messageIndex, reaction);
|
|
35713
|
+
setActionFeedback(message, messageIndex, reaction).catch((error) => addEvent(error.message || String(error), "error"));
|
|
34334
35714
|
});
|
|
34335
35715
|
controls.append(button);
|
|
34336
35716
|
}
|
|
@@ -34436,7 +35816,7 @@ function renderContent(parent, content, { markdown = false } = {}) {
|
|
|
34436
35816
|
|
|
34437
35817
|
function messageTitle(message) {
|
|
34438
35818
|
if (message.role === "assistant") return message.title || "final output";
|
|
34439
|
-
if (message.title) return message.title;
|
|
35819
|
+
if (message.title) return message.repeatCount > 1 ? `${message.title} (×${message.repeatCount})` : message.title;
|
|
34440
35820
|
if (message.role === "thinking") return "thinking";
|
|
34441
35821
|
if (message.role === "toolCall") return `tool call: ${message.toolName || "unknown"}`;
|
|
34442
35822
|
if (message.role === "toolExecution") return toolExecutionTitle(message);
|
|
@@ -34481,7 +35861,7 @@ function visibleThinkingText(text) {
|
|
|
34481
35861
|
return value;
|
|
34482
35862
|
}
|
|
34483
35863
|
|
|
34484
|
-
function renderThinkingMarkdown(block, text) {
|
|
35864
|
+
function renderThinkingMarkdown(block, text, { complete = false } = {}) {
|
|
34485
35865
|
if (!block) return;
|
|
34486
35866
|
block._rawThinkingText = String(text || "");
|
|
34487
35867
|
const selectionSnapshot = captureChatTextSelection(block);
|
|
@@ -34492,8 +35872,11 @@ function renderThinkingMarkdown(block, text) {
|
|
|
34492
35872
|
messageKey: bubble?.dataset?.transcriptMessageKey || bubble?.dataset?.itemKey || "live:thinking",
|
|
34493
35873
|
kind: "assistant-thinking",
|
|
34494
35874
|
text: block._rawThinkingText,
|
|
35875
|
+
complete,
|
|
34495
35876
|
stableBoundary: streamingMarkdownStableBoundary,
|
|
34496
35877
|
renderInto: renderMarkdownInto,
|
|
35878
|
+
renderLiveTail: renderStreamingMarkdownLiveTail,
|
|
35879
|
+
appendLiveTail: appendStreamingMarkdownLiveTail,
|
|
34497
35880
|
});
|
|
34498
35881
|
restoreChatTextSelection(selectionSnapshot);
|
|
34499
35882
|
}
|
|
@@ -34684,8 +36067,44 @@ function assistantFinalOutputPart(part) {
|
|
|
34684
36067
|
return null;
|
|
34685
36068
|
}
|
|
34686
36069
|
|
|
36070
|
+
function latestPersistedAssistantFailureTimestamp(messages = latestMessages) {
|
|
36071
|
+
const lastUserIndex = (messages || []).findLastIndex((message) => message?.role === "user");
|
|
36072
|
+
for (let index = (messages || []).length - 1; index > lastUserIndex; index -= 1) {
|
|
36073
|
+
const message = messages[index];
|
|
36074
|
+
if (message?.role === "assistant" && message.stopReason === "error") return messageTimestampMs(message) || Date.now();
|
|
36075
|
+
}
|
|
36076
|
+
return 0;
|
|
36077
|
+
}
|
|
36078
|
+
|
|
36079
|
+
function assistantFailureDisplayMessage(message, base) {
|
|
36080
|
+
if (message?.stopReason === "error") {
|
|
36081
|
+
return {
|
|
36082
|
+
...base,
|
|
36083
|
+
role: "error",
|
|
36084
|
+
title: "assistant error",
|
|
36085
|
+
level: "error",
|
|
36086
|
+
content: describeAssistantFailure(String(message.errorMessage || "The assistant request failed without an error message.").trim()),
|
|
36087
|
+
persistedFailure: true,
|
|
36088
|
+
actions: assistantFailureActions(),
|
|
36089
|
+
};
|
|
36090
|
+
}
|
|
36091
|
+
if (message?.stopReason === "aborted") {
|
|
36092
|
+
return { ...base, role: "native", title: "aborted", level: "warn", content: "This turn was aborted before it finished.", persistedFailure: true };
|
|
36093
|
+
}
|
|
36094
|
+
return null;
|
|
36095
|
+
}
|
|
36096
|
+
|
|
34687
36097
|
function assistantDisplayMessages(message) {
|
|
34688
36098
|
if (message?.role !== "assistant") return [message];
|
|
36099
|
+
const failure = assistantFailureDisplayMessage(message, { timestamp: message.timestamp });
|
|
36100
|
+
if (failure) {
|
|
36101
|
+
const rest = assistantDisplayMessagesWithoutFailure({ ...message, stopReason: undefined });
|
|
36102
|
+
return [...rest, failure];
|
|
36103
|
+
}
|
|
36104
|
+
return assistantDisplayMessagesWithoutFailure(message);
|
|
36105
|
+
}
|
|
36106
|
+
|
|
36107
|
+
function assistantDisplayMessagesWithoutFailure(message) {
|
|
34689
36108
|
const base = { timestamp: message.timestamp };
|
|
34690
36109
|
const content = message.content;
|
|
34691
36110
|
if (typeof content === "string") {
|
|
@@ -35223,7 +36642,6 @@ function cleanupLiveToolRunsForMessages(messages = latestMessages) {
|
|
|
35223
36642
|
for (const id of liveToolRuns.keys()) {
|
|
35224
36643
|
if (results.has(id)) {
|
|
35225
36644
|
liveToolRuns.delete(id);
|
|
35226
|
-
cancelQueuedLiveToolRunRender(id);
|
|
35227
36645
|
}
|
|
35228
36646
|
}
|
|
35229
36647
|
}
|
|
@@ -36124,7 +37542,8 @@ function createMessageBubble(message, { streaming = false, messageIndex = -1, tr
|
|
|
36124
37542
|
if (role === "user") bubble.dataset.userPrompt = "true";
|
|
36125
37543
|
}
|
|
36126
37544
|
if (itemKey) bubble.dataset.itemKey = itemKey;
|
|
36127
|
-
const
|
|
37545
|
+
const collapsibleThinking = !streaming && !compactTranscript && message.role === "thinking" && !compactThinkingAggregate;
|
|
37546
|
+
const isCollapsibleOutput = compactThinkingAggregate || collapsibleThinking || (!streaming && (message.role === "toolResult" || message.role === "bashExecution" || message.role === "compactionSummary"));
|
|
36128
37547
|
|
|
36129
37548
|
const hideMessageHeader = message.role === "assistant" && !isCollapsibleOutput;
|
|
36130
37549
|
if (hideMessageHeader) bubble.setAttribute("aria-label", messageTitle(message));
|
|
@@ -36166,6 +37585,15 @@ function createMessageBubble(message, { streaming = false, messageIndex = -1, tr
|
|
|
36166
37585
|
const defaultExpanded = message.compactThinkingDefaultExpanded === true;
|
|
36167
37586
|
details.open = compactThinkingDisclosureExpanded(message.compactThinkingKey, defaultExpanded);
|
|
36168
37587
|
if (message.compactThinkingKey) details.addEventListener("toggle", () => setCompactThinkingDisclosureExpanded(message.compactThinkingKey, details.open, defaultExpanded));
|
|
37588
|
+
} else if (collapsibleThinking) {
|
|
37589
|
+
// Persisted thinking starts folded (a high-effort model can dominate the transcript with it);
|
|
37590
|
+
// each block remembers its own state per tab, like the compact-mode aggregate does.
|
|
37591
|
+
const thinkingKey = `thinking:${itemKey || messageIndex}:${segmentId}`;
|
|
37592
|
+
details.classList.add("thinking-disclosure");
|
|
37593
|
+
details.open = compactThinkingDisclosureExpanded(thinkingKey, false);
|
|
37594
|
+
details.addEventListener("toggle", () => setCompactThinkingDisclosureExpanded(thinkingKey, details.open, false));
|
|
37595
|
+
const previewText = String(message.thinking || textFromContent(message.content) || "").replace(/\s+/g, " ").trim().slice(0, 140);
|
|
37596
|
+
if (previewText) header.append(make("span", "thinking-disclosure-preview", previewText));
|
|
36169
37597
|
} else if (shouldOpenMessageCollapseByDefault(message)) details.open = true;
|
|
36170
37598
|
details.append(header, body);
|
|
36171
37599
|
bubble.append(details);
|
|
@@ -36179,6 +37607,22 @@ function createMessageBubble(message, { streaming = false, messageIndex = -1, tr
|
|
|
36179
37607
|
} else {
|
|
36180
37608
|
bubble.append(header, body);
|
|
36181
37609
|
}
|
|
37610
|
+
if (Array.isArray(message.actions) && message.actions.length) {
|
|
37611
|
+
const actions = make("div", "message-actions");
|
|
37612
|
+
for (const action of message.actions) {
|
|
37613
|
+
if (!action?.label) continue;
|
|
37614
|
+
const button = make("button", `message-action-button${action.primary ? " primary" : ""}`, action.label);
|
|
37615
|
+
button.type = "button";
|
|
37616
|
+
if (action.title) button.title = action.title;
|
|
37617
|
+
button.addEventListener("click", (event) => {
|
|
37618
|
+
event.preventDefault();
|
|
37619
|
+
event.stopPropagation();
|
|
37620
|
+
Promise.resolve(action.run?.()).catch((error) => addEvent(error?.message || String(error), "error"));
|
|
37621
|
+
});
|
|
37622
|
+
actions.append(button);
|
|
37623
|
+
}
|
|
37624
|
+
if (actions.childElementCount) (bubble.querySelector(":scope > .message-body") || bubble).after(actions);
|
|
37625
|
+
}
|
|
36182
37626
|
ownTranscriptBubble(bubble, body, message, { itemKey, streaming, transient, segmentId });
|
|
36183
37627
|
ensureToolInteractionDelegation();
|
|
36184
37628
|
if (message.role !== "workflowStatusStack") attachMessageCopyButton(bubble, message, body);
|
|
@@ -36274,7 +37718,7 @@ function appendTranscriptMessage(message, { streaming = false, messageIndex = -1
|
|
|
36274
37718
|
if (displayMessage.role === "toolCall" && displayMessage.toolCallId) {
|
|
36275
37719
|
transcriptMessage = toolExecutionMessageFromCall(displayMessage);
|
|
36276
37720
|
}
|
|
36277
|
-
if (compactTranscript && transcriptMessage.role !== "assistant") return;
|
|
37721
|
+
if (compactTranscript && transcriptMessage.role !== "assistant" && !transcriptMessage.persistedFailure) return;
|
|
36278
37722
|
if (transcriptMessage.role === "thinking" && !thinkingOutputVisible) return;
|
|
36279
37723
|
const created = appendMessage(transcriptMessage, {
|
|
36280
37724
|
streaming: false,
|
|
@@ -36409,7 +37853,11 @@ function createRunIndicatorBubble() {
|
|
|
36409
37853
|
pulse.setAttribute("aria-hidden", "true");
|
|
36410
37854
|
runIndicatorText = make("span", "run-indicator-text");
|
|
36411
37855
|
runIndicatorMeta = make("span", "run-indicator-meta");
|
|
36412
|
-
|
|
37856
|
+
// Elapsed time ticks every second; keep it out of the accessibility tree so the polite live
|
|
37857
|
+
// region only announces real activity changes, not "run time 12s / 13s / …".
|
|
37858
|
+
runIndicatorElapsed = make("span", "run-indicator-elapsed");
|
|
37859
|
+
runIndicatorElapsed.setAttribute("aria-hidden", "true");
|
|
37860
|
+
row.append(pulse, runIndicatorText, runIndicatorMeta, runIndicatorElapsed);
|
|
36413
37861
|
body.append(row);
|
|
36414
37862
|
runIndicatorBubble.append(body);
|
|
36415
37863
|
}
|
|
@@ -36426,8 +37874,10 @@ function updateRunIndicatorBubble() {
|
|
|
36426
37874
|
const headline = runIndicatorHeadline();
|
|
36427
37875
|
if (runIndicatorText.textContent !== headline) runIndicatorText.textContent = headline;
|
|
36428
37876
|
const detail = runIndicatorDetail();
|
|
36429
|
-
const meta =
|
|
37877
|
+
const meta = detail;
|
|
36430
37878
|
if (runIndicatorMeta.textContent !== meta) runIndicatorMeta.textContent = meta;
|
|
37879
|
+
const elapsed = runIndicatorShowsElapsed() ? ` · run time ${formatRunIndicatorElapsed()}` : "";
|
|
37880
|
+
if (runIndicatorElapsed && runIndicatorElapsed.textContent !== elapsed) runIndicatorElapsed.textContent = elapsed;
|
|
36431
37881
|
}
|
|
36432
37882
|
|
|
36433
37883
|
function removeRunIndicatorBubble() {
|
|
@@ -36436,6 +37886,7 @@ function removeRunIndicatorBubble() {
|
|
|
36436
37886
|
runIndicatorBubble = null;
|
|
36437
37887
|
runIndicatorText = null;
|
|
36438
37888
|
runIndicatorMeta = null;
|
|
37889
|
+
runIndicatorElapsed = null;
|
|
36439
37890
|
}
|
|
36440
37891
|
|
|
36441
37892
|
function renderRunIndicator({ scroll = false } = {}) {
|
|
@@ -36720,7 +38171,11 @@ function orderedTranscriptItems() {
|
|
|
36720
38171
|
if (resultId && assistantToolCallIds.has(resultId)) return;
|
|
36721
38172
|
items.push({ message, messageIndex: index, transient: false, timestampMs: messageTimestampMs(message), order: index });
|
|
36722
38173
|
});
|
|
38174
|
+
const persistedFailureAt = latestPersistedAssistantFailureTimestamp(latestMessages);
|
|
36723
38175
|
transientMessages.forEach((message, index) => {
|
|
38176
|
+
// Once Pi's authoritative transcript carries the failed assistant turn (stopReason error), the
|
|
38177
|
+
// live "Assistant error" cards for the same failure are redundant.
|
|
38178
|
+
if (persistedFailureAt && message?.role === "error" && message?.title === "Assistant error" && messageTimestampMs(message) <= persistedFailureAt + 5000) return;
|
|
36724
38179
|
items.push({ message, messageIndex: index, transient: true, timestampMs: messageTimestampMs(message), order: latestMessages.length + index });
|
|
36725
38180
|
});
|
|
36726
38181
|
let liveOrder = latestMessages.length + transientMessages.length;
|
|
@@ -37151,7 +38606,11 @@ function applyNativeSlashCommandEffects(response, message, tabContext = activeTa
|
|
|
37151
38606
|
if (warning) addEvent(String(warning), "warn");
|
|
37152
38607
|
}
|
|
37153
38608
|
for (const toast of data.toasts || []) {
|
|
37154
|
-
if (toast?.message)
|
|
38609
|
+
if (!toast?.message) continue;
|
|
38610
|
+
const level = toast.level || "info";
|
|
38611
|
+
addEvent(String(toast.message), level);
|
|
38612
|
+
// Extensions asked for a toast explicitly; info/success levels are not auto-surfaced by addEvent.
|
|
38613
|
+
if (level !== "warn" && level !== "error") showNoticeToast(String(toast.message), level);
|
|
37155
38614
|
}
|
|
37156
38615
|
|
|
37157
38616
|
if (data.copyText) {
|
|
@@ -37207,12 +38666,29 @@ function applyNativeSlashCommandEffects(response, message, tabContext = activeTa
|
|
|
37207
38666
|
if (refresh.includes("themes")) initializeThemes().catch((error) => addEvent(error.message || String(error), "error"));
|
|
37208
38667
|
}
|
|
37209
38668
|
|
|
37210
|
-
function addTransientMessage({ role = "notice", title, content, level = "info", ...details }) {
|
|
38669
|
+
function addTransientMessage({ role = "notice", title, content, level = "info", key = "", ...details }) {
|
|
38670
|
+
// `key` upserts (e.g. one live "auto retry" card that counts down instead of one card per
|
|
38671
|
+
// attempt); identical consecutive error/warn cards collapse into one with a repeat counter.
|
|
38672
|
+
const last = transientMessages[transientMessages.length - 1];
|
|
38673
|
+
if (key) {
|
|
38674
|
+
const existing = transientMessages.findLast((message) => message?.key === key);
|
|
38675
|
+
if (existing) {
|
|
38676
|
+
Object.assign(existing, { role, title, level, content, ...details, timestamp: Date.now() });
|
|
38677
|
+
renderAllMessages();
|
|
38678
|
+
return;
|
|
38679
|
+
}
|
|
38680
|
+
} else if (last && (level === "error" || level === "warn") && last.level === level && last.role === role && last.title === title && last.content === content && Date.now() - (last.timestamp || 0) < 120_000) {
|
|
38681
|
+
last.repeatCount = (last.repeatCount || 1) + 1;
|
|
38682
|
+
last.timestamp = Date.now();
|
|
38683
|
+
renderAllMessages();
|
|
38684
|
+
return;
|
|
38685
|
+
}
|
|
37211
38686
|
transientMessages.push({
|
|
37212
38687
|
role,
|
|
37213
38688
|
title,
|
|
37214
38689
|
level,
|
|
37215
38690
|
content,
|
|
38691
|
+
key,
|
|
37216
38692
|
...details,
|
|
37217
38693
|
timestamp: Date.now(),
|
|
37218
38694
|
});
|
|
@@ -37220,11 +38696,37 @@ function addTransientMessage({ role = "notice", title, content, level = "info",
|
|
|
37220
38696
|
renderAllMessages();
|
|
37221
38697
|
}
|
|
37222
38698
|
|
|
37223
|
-
function surfaceRuntimeDiagnostic(title, content, level = "error") {
|
|
38699
|
+
function surfaceRuntimeDiagnostic(title, content, level = "error", { actions = null } = {}) {
|
|
37224
38700
|
const message = String(content || "").trim();
|
|
37225
38701
|
if (!message) return;
|
|
37226
|
-
addEvent(message, level);
|
|
37227
|
-
addTransientMessage({ role: level === "error" ? "error" : "warn", title, content: message, level });
|
|
38702
|
+
addEvent(message, level, { notify: false }); // the transcript card below is the visible feedback
|
|
38703
|
+
addTransientMessage({ role: level === "error" ? "error" : "warn", title, content: message, level, ...(actions ? { actions } : {}) });
|
|
38704
|
+
}
|
|
38705
|
+
|
|
38706
|
+
// Recovery actions for a failed assistant turn: retry the last prompt as-is, or pick another model.
|
|
38707
|
+
function assistantFailureActions(tabId = activeTabId) {
|
|
38708
|
+
const entry = tabId ? lastUserPromptByTab.get(tabId) : null;
|
|
38709
|
+
const actions = [];
|
|
38710
|
+
if (entry?.text) {
|
|
38711
|
+
actions.push({
|
|
38712
|
+
label: "Retry",
|
|
38713
|
+
title: "Send the last prompt again",
|
|
38714
|
+
primary: true,
|
|
38715
|
+
run: () => sendPrompt("prompt", entry.text, { targetTabId: tabId }),
|
|
38716
|
+
});
|
|
38717
|
+
}
|
|
38718
|
+
actions.push({ label: "Change model…", title: "Choose another model for this tab (Ctrl/Cmd+L)", run: () => openNativeModelSelector() });
|
|
38719
|
+
return actions;
|
|
38720
|
+
}
|
|
38721
|
+
|
|
38722
|
+
// Provider errors are terse ("Connection error."). Add the model/provider so the user knows what
|
|
38723
|
+
// failed and where to look (LM Studio not running, wrong base URL, expired key, …).
|
|
38724
|
+
function describeAssistantFailure(message, state = currentState) {
|
|
38725
|
+
const model = state?.model;
|
|
38726
|
+
const text = String(message || "").trim();
|
|
38727
|
+
if (!model?.provider) return text;
|
|
38728
|
+
const where = `${model.provider}/${model.id || ""}`.replace(/\/$/, "");
|
|
38729
|
+
return text.includes(where) ? text : `${text} (model ${where})`;
|
|
37228
38730
|
}
|
|
37229
38731
|
|
|
37230
38732
|
function stderrDiagnosticLevel(content) {
|
|
@@ -37377,6 +38879,7 @@ function scrollChatToBottom({ force = false } = {}) {
|
|
|
37377
38879
|
function syncAutoFollowFromChatScroll() {
|
|
37378
38880
|
const nearBottom = isChatNearBottom();
|
|
37379
38881
|
const recentProgrammaticScroll = performance.now() - lastChatProgrammaticScrollAt <= CHAT_PROGRAMMATIC_SCROLL_GRACE_MS;
|
|
38882
|
+
if (streamIsolationDebugLedger) noteDetachedChatScrollMovement();
|
|
37380
38883
|
if (performance.now() <= chatPausedScrollRestoreUntil) {
|
|
37381
38884
|
autoFollowChat = false;
|
|
37382
38885
|
} else if (isChatUserScrollAwayIntentActive()) {
|
|
@@ -37456,7 +38959,40 @@ async function sendBtwPromptFromButton() {
|
|
|
37456
38959
|
await sendBtwQuestion(question, { clearComposerDraft: true });
|
|
37457
38960
|
}
|
|
37458
38961
|
|
|
38962
|
+
// Hover/focus-opened composer menus need an explicit "dismissed" state: after Escape or an item
|
|
38963
|
+
// choice the pointer usually still rests on the trigger (and the trigger keeps focus), so without
|
|
38964
|
+
// this the panel would immediately pop open again and Escape would appear broken.
|
|
38965
|
+
function armComposerMenuDismissal(container) {
|
|
38966
|
+
if (!container?.classList) return;
|
|
38967
|
+
const hovering = container.matches(":hover");
|
|
38968
|
+
const clear = () => {
|
|
38969
|
+
container.classList.remove("menu-dismissed");
|
|
38970
|
+
container.removeEventListener("pointerleave", clear);
|
|
38971
|
+
container.removeEventListener("focusout", onFocusOut);
|
|
38972
|
+
};
|
|
38973
|
+
const onFocusOut = () => setTimeout(() => {
|
|
38974
|
+
// Still hovered: keep the dismissal until the pointer leaves as well.
|
|
38975
|
+
if (!container.contains(document.activeElement) && !container.matches(":hover")) clear();
|
|
38976
|
+
}, 0);
|
|
38977
|
+
const focusedInside = container.contains(document.activeElement);
|
|
38978
|
+
if (!hovering && !focusedInside) return; // nothing would reopen it; no need to suppress
|
|
38979
|
+
container.classList.add("menu-dismissed");
|
|
38980
|
+
container.addEventListener("pointerleave", () => {
|
|
38981
|
+
if (!container.contains(document.activeElement)) clear();
|
|
38982
|
+
}, { once: true });
|
|
38983
|
+
container.addEventListener("focusout", onFocusOut);
|
|
38984
|
+
}
|
|
38985
|
+
|
|
38986
|
+
function composerMenuDismissed(container) {
|
|
38987
|
+
return Boolean(container?.classList?.contains("menu-dismissed"));
|
|
38988
|
+
}
|
|
38989
|
+
|
|
38990
|
+
function clearComposerMenuDismissal(container) {
|
|
38991
|
+
container?.classList?.remove("menu-dismissed");
|
|
38992
|
+
}
|
|
38993
|
+
|
|
37459
38994
|
function setPublishMenuOpen(open) {
|
|
38995
|
+
if (open && composerMenuDismissed(elements.publishButton?.parentElement)) return;
|
|
37460
38996
|
if (open && followUpQueueOpen) setFollowUpQueueOpen(false);
|
|
37461
38997
|
publishMenuOpen = !!open;
|
|
37462
38998
|
elements.publishButton.setAttribute("aria-expanded", publishMenuOpen ? "true" : "false");
|
|
@@ -37467,6 +39003,7 @@ function setPublishMenuOpen(open) {
|
|
|
37467
39003
|
}
|
|
37468
39004
|
|
|
37469
39005
|
function setNativeCommandMenuOpen(open) {
|
|
39006
|
+
if (open && composerMenuDismissed(elements.nativeCommandMenuButton?.parentElement)) return;
|
|
37470
39007
|
if (open && followUpQueueOpen) setFollowUpQueueOpen(false);
|
|
37471
39008
|
nativeCommandMenuOpen = !!open;
|
|
37472
39009
|
elements.nativeCommandMenuButton.setAttribute("aria-expanded", nativeCommandMenuOpen ? "true" : "false");
|
|
@@ -37477,6 +39014,7 @@ function setNativeCommandMenuOpen(open) {
|
|
|
37477
39014
|
}
|
|
37478
39015
|
|
|
37479
39016
|
function setAppRunnerMenuOpen(open) {
|
|
39017
|
+
if (open && composerMenuDismissed(elements.appRunnerMenuButton?.parentElement)) return;
|
|
37480
39018
|
if (open && followUpQueueOpen) setFollowUpQueueOpen(false);
|
|
37481
39019
|
appRunnerMenuOpen = !!open;
|
|
37482
39020
|
elements.appRunnerMenuButton?.setAttribute("aria-expanded", appRunnerMenuOpen ? "true" : "false");
|
|
@@ -37487,6 +39025,7 @@ function setAppRunnerMenuOpen(open) {
|
|
|
37487
39025
|
}
|
|
37488
39026
|
|
|
37489
39027
|
function setOptionsMenuOpen(open) {
|
|
39028
|
+
if (open && composerMenuDismissed(elements.optionsMenuButton?.parentElement)) return;
|
|
37490
39029
|
if (open && followUpQueueOpen) setFollowUpQueueOpen(false);
|
|
37491
39030
|
optionsMenuOpen = !!open;
|
|
37492
39031
|
elements.optionsMenuButton.setAttribute("aria-expanded", optionsMenuOpen ? "true" : "false");
|
|
@@ -38305,6 +39844,16 @@ function renderOptionalFeatureMigrationSurface() {
|
|
|
38305
39844
|
ensureOptionalFeatureMigrationRenderTimer();
|
|
38306
39845
|
return;
|
|
38307
39846
|
}
|
|
39847
|
+
// A healthy "ready" audit is not actionable: don't cover the header with a banner on every
|
|
39848
|
+
// page load. The summary stays available in Optional features and the Events log; only a
|
|
39849
|
+
// deferred migration (restorable companions) still surfaces here.
|
|
39850
|
+
if (snapshot.phase === "ready" && !optionalFeatureRestartNotice && !(summary.migratable > 0) && !conflicts.length) {
|
|
39851
|
+
clearOptionalFeatureReadyDismissTimer();
|
|
39852
|
+
surface.replaceChildren();
|
|
39853
|
+
surface.hidden = true;
|
|
39854
|
+
ensureOptionalFeatureMigrationRenderTimer();
|
|
39855
|
+
return;
|
|
39856
|
+
}
|
|
38308
39857
|
if (noticeDismissKey && optionalFeatureMigrationDismissedNoticeKey === noticeDismissKey) {
|
|
38309
39858
|
surface.replaceChildren();
|
|
38310
39859
|
surface.hidden = true;
|
|
@@ -39094,11 +40643,14 @@ function renderOptionalFeatureControls() {
|
|
|
39094
40643
|
}
|
|
39095
40644
|
|
|
39096
40645
|
const hasGitWorkflow = isOptionalFeatureEnabled("gitWorkflow");
|
|
39097
|
-
|
|
40646
|
+
// Committing/pushing is a core expectation: keep the entry point visible (disabled, with the
|
|
40647
|
+
// install hint) when the companion package is merely missing; hide it only when the user
|
|
40648
|
+
// explicitly disabled the feature.
|
|
40649
|
+
elements.gitWorkflowButton.hidden = !hasGitWorkflow && isOptionalFeatureDisabled("gitWorkflow");
|
|
39098
40650
|
setOptionalControlState(
|
|
39099
40651
|
elements.gitWorkflowButton,
|
|
39100
40652
|
hasGitWorkflow,
|
|
39101
|
-
optionalFeatureUnavailableMessage("gitWorkflow"),
|
|
40653
|
+
`${optionalFeatureUnavailableMessage("gitWorkflow")} Until then, stage and review changes from the Git panel or the CHANGES footer chip.`,
|
|
39102
40654
|
);
|
|
39103
40655
|
|
|
39104
40656
|
elements.releaseNpmButton.hidden = !isOptionalFeatureEnabled("releaseNpm");
|
|
@@ -39921,18 +41473,120 @@ function nativeSelectorMatches(item, query) {
|
|
|
39921
41473
|
.some((value) => String(value).toLowerCase().includes(needle));
|
|
39922
41474
|
}
|
|
39923
41475
|
|
|
41476
|
+
// Keyboard navigation for native selector dialogs (/model, /theme, /resume, …):
|
|
41477
|
+
// the search box owns focus, ArrowUp/Down move a visible highlight, Enter selects
|
|
41478
|
+
// the highlighted choice, Home/End jump. The highlight defaults to the current
|
|
41479
|
+
// choice (when unfiltered) so Enter is never destructive by surprise.
|
|
41480
|
+
let nativeSelectorHighlightIndex = -1;
|
|
41481
|
+
|
|
41482
|
+
function nativeSelectorItemButtons() {
|
|
41483
|
+
return Array.from(elements.nativeCommandBody.querySelectorAll(".native-selector-item:not([disabled])"));
|
|
41484
|
+
}
|
|
41485
|
+
|
|
41486
|
+
function syncNativeSelectorHighlight({ scroll = true } = {}) {
|
|
41487
|
+
const buttons = nativeSelectorItemButtons();
|
|
41488
|
+
if (!buttons.length) {
|
|
41489
|
+
nativeSelectorHighlightIndex = -1;
|
|
41490
|
+
elements.nativeCommandSearch.removeAttribute("aria-activedescendant");
|
|
41491
|
+
return null;
|
|
41492
|
+
}
|
|
41493
|
+
nativeSelectorHighlightIndex = Math.min(Math.max(nativeSelectorHighlightIndex, 0), buttons.length - 1);
|
|
41494
|
+
let highlighted = null;
|
|
41495
|
+
buttons.forEach((button, index) => {
|
|
41496
|
+
const on = index === nativeSelectorHighlightIndex;
|
|
41497
|
+
button.classList.toggle("keyboard-active", on);
|
|
41498
|
+
button.setAttribute("aria-selected", on ? "true" : "false");
|
|
41499
|
+
if (on) highlighted = button;
|
|
41500
|
+
});
|
|
41501
|
+
if (highlighted) {
|
|
41502
|
+
elements.nativeCommandSearch.setAttribute("aria-activedescendant", highlighted.id);
|
|
41503
|
+
if (scroll) highlighted.scrollIntoView({ block: "nearest" });
|
|
41504
|
+
}
|
|
41505
|
+
return highlighted;
|
|
41506
|
+
}
|
|
41507
|
+
|
|
41508
|
+
function moveNativeSelectorHighlight(delta, { absolute = false } = {}) {
|
|
41509
|
+
const buttons = nativeSelectorItemButtons();
|
|
41510
|
+
if (!buttons.length) return;
|
|
41511
|
+
const last = buttons.length - 1;
|
|
41512
|
+
let next = absolute ? delta : nativeSelectorHighlightIndex + delta;
|
|
41513
|
+
if (next < 0) next = absolute ? 0 : last;
|
|
41514
|
+
if (next > last) next = absolute ? last : 0;
|
|
41515
|
+
nativeSelectorHighlightIndex = next;
|
|
41516
|
+
syncNativeSelectorHighlight();
|
|
41517
|
+
}
|
|
41518
|
+
|
|
41519
|
+
function activateNativeSelectorHighlight() {
|
|
41520
|
+
const highlighted = syncNativeSelectorHighlight({ scroll: false });
|
|
41521
|
+
if (!highlighted) return false;
|
|
41522
|
+
highlighted.click();
|
|
41523
|
+
return true;
|
|
41524
|
+
}
|
|
41525
|
+
|
|
41526
|
+
function handleNativeSelectorSearchKeydown(event) {
|
|
41527
|
+
if (event.isComposing || elements.nativeCommandSearch.hidden) return;
|
|
41528
|
+
if (!nativeSelectorItemButtons().length) return;
|
|
41529
|
+
switch (event.key) {
|
|
41530
|
+
case "ArrowDown":
|
|
41531
|
+
event.preventDefault();
|
|
41532
|
+
moveNativeSelectorHighlight(1);
|
|
41533
|
+
return;
|
|
41534
|
+
case "ArrowUp":
|
|
41535
|
+
event.preventDefault();
|
|
41536
|
+
moveNativeSelectorHighlight(-1);
|
|
41537
|
+
return;
|
|
41538
|
+
case "Home":
|
|
41539
|
+
if (elements.nativeCommandSearch.value) return;
|
|
41540
|
+
event.preventDefault();
|
|
41541
|
+
moveNativeSelectorHighlight(0, { absolute: true });
|
|
41542
|
+
return;
|
|
41543
|
+
case "End":
|
|
41544
|
+
if (elements.nativeCommandSearch.value) return;
|
|
41545
|
+
event.preventDefault();
|
|
41546
|
+
moveNativeSelectorHighlight(Number.MAX_SAFE_INTEGER, { absolute: true });
|
|
41547
|
+
return;
|
|
41548
|
+
case "PageDown":
|
|
41549
|
+
event.preventDefault();
|
|
41550
|
+
moveNativeSelectorHighlight(8);
|
|
41551
|
+
return;
|
|
41552
|
+
case "PageUp":
|
|
41553
|
+
event.preventDefault();
|
|
41554
|
+
moveNativeSelectorHighlight(-8);
|
|
41555
|
+
return;
|
|
41556
|
+
case "Enter":
|
|
41557
|
+
if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
41558
|
+
event.preventDefault();
|
|
41559
|
+
activateNativeSelectorHighlight();
|
|
41560
|
+
return;
|
|
41561
|
+
default:
|
|
41562
|
+
}
|
|
41563
|
+
}
|
|
41564
|
+
|
|
39924
41565
|
function renderNativeSelectorItems(items, { emptyText = "No choices.", onSelect, activeId, numbered = false } = {}) {
|
|
39925
41566
|
const query = elements.nativeCommandSearch.value.trim();
|
|
39926
41567
|
const filtered = items.filter((item) => nativeSelectorMatches(item, query));
|
|
39927
41568
|
elements.nativeCommandBody.replaceChildren();
|
|
41569
|
+
elements.nativeCommandSearch.removeAttribute("aria-activedescendant");
|
|
39928
41570
|
if (!filtered.length) {
|
|
41571
|
+
nativeSelectorHighlightIndex = -1;
|
|
39929
41572
|
elements.nativeCommandBody.append(make("div", "native-command-empty muted", emptyText));
|
|
39930
41573
|
return;
|
|
39931
41574
|
}
|
|
39932
41575
|
const list = make("div", "native-selector-list");
|
|
41576
|
+
list.setAttribute("role", "listbox");
|
|
41577
|
+
list.id = "nativeSelectorList";
|
|
41578
|
+
let lastGroup = null;
|
|
39933
41579
|
for (const [index, item] of filtered.entries()) {
|
|
41580
|
+
if (item.group && item.group !== lastGroup && !item.badge) {
|
|
41581
|
+
const heading = make("div", "native-selector-group", item.group);
|
|
41582
|
+
heading.setAttribute("role", "presentation");
|
|
41583
|
+
list.append(heading);
|
|
41584
|
+
}
|
|
41585
|
+
if (item.group) lastGroup = item.group;
|
|
39934
41586
|
const button = make("button", `native-selector-item${item.id === activeId ? " active" : ""}`);
|
|
39935
41587
|
button.type = "button";
|
|
41588
|
+
button.id = `nativeSelectorItem-${index}`;
|
|
41589
|
+
button.setAttribute("role", "option");
|
|
39936
41590
|
button.disabled = item.disabled === true;
|
|
39937
41591
|
if (typeof item.pressed === "boolean") button.setAttribute("aria-pressed", String(item.pressed));
|
|
39938
41592
|
button.addEventListener("click", () => onSelect?.(item));
|
|
@@ -39962,6 +41616,12 @@ function renderNativeSelectorItems(items, { emptyText = "No choices.", onSelect,
|
|
|
39962
41616
|
list.append(button);
|
|
39963
41617
|
}
|
|
39964
41618
|
elements.nativeCommandBody.append(list);
|
|
41619
|
+
// Unfiltered: highlight (and reveal) the current choice; filtered: the best match on top.
|
|
41620
|
+
const enabled = nativeSelectorItemButtons();
|
|
41621
|
+
const currentIndex = query ? -1 : enabled.findIndex((button) => button.classList.contains("active"));
|
|
41622
|
+
nativeSelectorHighlightIndex = currentIndex >= 0 ? currentIndex : 0;
|
|
41623
|
+
const highlighted = syncNativeSelectorHighlight({ scroll: false });
|
|
41624
|
+
if (highlighted && !query && currentIndex >= 0) queueMicrotask(() => highlighted.scrollIntoView({ block: "center" }));
|
|
39965
41625
|
}
|
|
39966
41626
|
|
|
39967
41627
|
function setNativeActionBusy(button, busy, label = "Working…") {
|
|
@@ -39986,10 +41646,17 @@ async function openNativeModelSelector() {
|
|
|
39986
41646
|
id: modelOptionLabel(model),
|
|
39987
41647
|
label: modelOptionLabel(model),
|
|
39988
41648
|
description: model.name || model.description || "",
|
|
39989
|
-
meta:
|
|
41649
|
+
meta: [
|
|
41650
|
+
model.contextWindow ? `context ${formatFooterTokenCount(model.contextWindow)}` : "",
|
|
41651
|
+
model.reasoning ? "reasoning" : "",
|
|
41652
|
+
Array.isArray(model.input) && model.input.includes("image") ? "images" : "",
|
|
41653
|
+
].filter(Boolean).join(" · ") || model.provider,
|
|
41654
|
+
group: model.provider,
|
|
39990
41655
|
model,
|
|
39991
41656
|
badge: modelOptionLabel(model) === activeId ? "current" : "",
|
|
39992
41657
|
}));
|
|
41658
|
+
// The current model goes first so it is visible without scrolling through hundreds of rows.
|
|
41659
|
+
items.sort((a, b) => (b.badge === "current") - (a.badge === "current"));
|
|
39993
41660
|
const render = () => renderNativeSelectorItems(items, {
|
|
39994
41661
|
emptyText: "No models match this filter.",
|
|
39995
41662
|
activeId,
|
|
@@ -41437,8 +43104,9 @@ function openNativeNameDialog() {
|
|
|
41437
43104
|
});
|
|
41438
43105
|
}
|
|
41439
43106
|
|
|
41440
|
-
async function openNativeResumeSelector(scope = "current") {
|
|
41441
|
-
openNativeCommandDialog({ title: "
|
|
43107
|
+
async function openNativeResumeSelector(scope = "current", { query = "" } = {}) {
|
|
43108
|
+
openNativeCommandDialog({ title: "Resume a session", message: "Select a session, then resume, rename metadata, or delete it.", searchPlaceholder: "Filter sessions…" });
|
|
43109
|
+
if (query) elements.nativeCommandSearch.value = query;
|
|
41442
43110
|
renderNativeLoading("Loading sessions…");
|
|
41443
43111
|
const selectedScope = scope === "all" ? "all" : "current";
|
|
41444
43112
|
let selectedItem = null;
|
|
@@ -41463,13 +43131,13 @@ async function openNativeResumeSelector(scope = "current") {
|
|
|
41463
43131
|
|
|
41464
43132
|
const renameButton = addNativeCommandAction("Rename", async () => {
|
|
41465
43133
|
if (!selectedItem) return;
|
|
41466
|
-
const nextName =
|
|
43134
|
+
const nextName = await appPromptText({ title: "Rename session", summary: "Display name stored in the session metadata.", defaultValue: selectedItem.session.name || selectedItem.label || "", confirmLabel: "Rename" });
|
|
41467
43135
|
if (nextName === null) return;
|
|
41468
43136
|
setNativeCommandError("");
|
|
41469
43137
|
try {
|
|
41470
43138
|
const result = await nativeCommandApi("/api/session-rename", { method: "POST", body: { sessionPath: selectedItem.session.path, name: nextName } });
|
|
41471
43139
|
addTransientMessage({ role: "native", title: "/resume", content: result.data?.message || "Renamed session metadata.", level: "info" });
|
|
41472
|
-
await openNativeResumeSelector(selectedScope);
|
|
43140
|
+
await openNativeResumeSelector(selectedScope, { query: elements.nativeCommandSearch.value });
|
|
41473
43141
|
} catch (error) {
|
|
41474
43142
|
setNativeCommandError(error.message || String(error));
|
|
41475
43143
|
}
|
|
@@ -41488,7 +43156,7 @@ async function openNativeResumeSelector(scope = "current") {
|
|
|
41488
43156
|
try {
|
|
41489
43157
|
const result = await nativeCommandApi("/api/session-delete", { method: "POST", body: { sessionPath: selectedItem.session.path, confirmed: true } });
|
|
41490
43158
|
addTransientMessage({ role: "native", title: "/resume", content: result.data?.message || "Session deleted.", level: "warn" });
|
|
41491
|
-
await openNativeResumeSelector(selectedScope);
|
|
43159
|
+
await openNativeResumeSelector(selectedScope, { query: elements.nativeCommandSearch.value });
|
|
41492
43160
|
} catch (error) {
|
|
41493
43161
|
setNativeCommandError(error.message || String(error));
|
|
41494
43162
|
resumeDeleteArmed = false;
|
|
@@ -41507,7 +43175,7 @@ async function openNativeResumeSelector(scope = "current") {
|
|
|
41507
43175
|
id: session.path,
|
|
41508
43176
|
label: session.name || session.firstMessage || session.id || session.path,
|
|
41509
43177
|
description: session.firstMessage || "(no messages)",
|
|
41510
|
-
meta: `${session.cwd || "unknown cwd"} · ${session.messageCount || 0} messages · ${session.modified
|
|
43178
|
+
meta: `${session.cwd || "unknown cwd"} · ${session.messageCount || 0} messages · ${session.modified ? formatRelativeDate(session.modified) : "unknown time"}`,
|
|
41511
43179
|
badge: session.current ? "current" : "",
|
|
41512
43180
|
disabled: session.current,
|
|
41513
43181
|
session,
|
|
@@ -42357,6 +44025,7 @@ function acceptOutputModeAcknowledgement(event) {
|
|
|
42357
44025
|
}
|
|
42358
44026
|
|
|
42359
44027
|
function transitionNormalLiveOutputToCompact() {
|
|
44028
|
+
flushNormalStreamRenders("output-mode-transition");
|
|
42360
44029
|
compactLiveState = seedFastOutputLiveState({ text: streamRawText, thinking: streamThinkingRawText });
|
|
42361
44030
|
setStreamRawText("");
|
|
42362
44031
|
setStreamThinkingRawText("");
|
|
@@ -42377,6 +44046,8 @@ function transitionCompactLiveOutputToNormal(tabContext = activeTabContext()) {
|
|
|
42377
44046
|
|
|
42378
44047
|
function applyOutputModeControl(event, tabContext = activeTabContext()) {
|
|
42379
44048
|
if (event?.protocolVersion !== 1 || !["normal", "compact-v1"].includes(event.activeMode)) return false;
|
|
44049
|
+
flushNormalStreamRenders("output-mode-change");
|
|
44050
|
+
fallbackStreamDerivedOutput("output-mode-change");
|
|
42380
44051
|
const previousMode = activeOutputMode;
|
|
42381
44052
|
if (previousMode === "normal" && event.activeMode === "compact-v1") {
|
|
42382
44053
|
transitionNormalLiveOutputToCompact();
|
|
@@ -42404,23 +44075,67 @@ function removeStreamBubble() {
|
|
|
42404
44075
|
renderRunIndicator({ scroll: false });
|
|
42405
44076
|
}
|
|
42406
44077
|
|
|
42407
|
-
function
|
|
42408
|
-
|
|
44078
|
+
function ensureStreamDerivedOutputState() {
|
|
44079
|
+
const todoProgressDetected = isOptionalFeatureDetected("todoProgressWidget");
|
|
44080
|
+
if (!streamDerivedOutputState) {
|
|
44081
|
+
streamDerivedOutputState = createStreamDerivedOutputState({
|
|
44082
|
+
todoProgressDetected,
|
|
44083
|
+
shadow: !!streamIsolationDebugLedger,
|
|
44084
|
+
});
|
|
44085
|
+
} else {
|
|
44086
|
+
streamDerivedOutputState.setTodoProgressDetected(todoProgressDetected);
|
|
44087
|
+
}
|
|
44088
|
+
return streamDerivedOutputState;
|
|
44089
|
+
}
|
|
44090
|
+
|
|
44091
|
+
function recordStreamDerivedOutputDiagnostic(diagnostic, ms = 0) {
|
|
44092
|
+
if (!streamIsolationDebugLedger || (!diagnostic.scannedCodeUnits && !diagnostic.fallbackReason && !diagnostic.shadowMismatch)) return;
|
|
44093
|
+
const bytes = diagnostic.scannedCodeUnits * 2;
|
|
44094
|
+
recordStreamProfileDiagnostic({ type: "derive", ms, bytes });
|
|
44095
|
+
if (diagnostic.fallbackReason) recordStreamProfileDiagnostic({ type: "derive-fallback", reason: diagnostic.fallbackReason, bytes });
|
|
44096
|
+
if (diagnostic.shadowMismatch) recordStreamProfileDiagnostic({ type: "derive-shadow-mismatch", reason: diagnostic.fallbackReason || "shadow-mismatch" });
|
|
44097
|
+
}
|
|
44098
|
+
|
|
44099
|
+
function captureStreamDerivedOutputProfile(startedAt) {
|
|
44100
|
+
recordStreamDerivedOutputDiagnostic(
|
|
44101
|
+
ensureStreamDerivedOutputState().takeDiagnostics(),
|
|
44102
|
+
streamIsolationDebugLedger ? performance.now() - startedAt : 0,
|
|
44103
|
+
);
|
|
42409
44104
|
}
|
|
42410
44105
|
|
|
42411
|
-
function
|
|
44106
|
+
function resetStreamDerivedOutputState(reason = "reset") {
|
|
44107
|
+
if (!streamDerivedOutputState) return;
|
|
44108
|
+
streamDerivedOutputState.reset({
|
|
44109
|
+
todoProgressDetected: isOptionalFeatureDetected("todoProgressWidget"),
|
|
44110
|
+
reason,
|
|
44111
|
+
});
|
|
44112
|
+
recordStreamDerivedOutputDiagnostic(streamDerivedOutputState.takeDiagnostics());
|
|
44113
|
+
}
|
|
44114
|
+
|
|
44115
|
+
function fallbackStreamDerivedOutput(reason) {
|
|
44116
|
+
if (!streamRawText || !streamDerivedOutputState) return;
|
|
44117
|
+
const profileStart = streamIsolationDebugLedger ? performance.now() : 0;
|
|
44118
|
+
ensureStreamDerivedOutputState().replace(streamRawText, { reason, force: true });
|
|
44119
|
+
captureStreamDerivedOutputProfile(profileStart);
|
|
44120
|
+
}
|
|
44121
|
+
|
|
44122
|
+
function setStreamRawText(text, { reason = "snapshot" } = {}) {
|
|
42412
44123
|
const nextText = String(text || "");
|
|
42413
44124
|
if (nextText === streamRawText) return false;
|
|
44125
|
+
const profileStart = streamIsolationDebugLedger ? performance.now() : 0;
|
|
42414
44126
|
streamRawText = nextText;
|
|
42415
|
-
|
|
44127
|
+
ensureStreamDerivedOutputState().replace(nextText, { reason });
|
|
44128
|
+
captureStreamDerivedOutputProfile(profileStart);
|
|
42416
44129
|
return true;
|
|
42417
44130
|
}
|
|
42418
44131
|
|
|
42419
44132
|
function appendStreamRawText(delta) {
|
|
42420
44133
|
const text = String(delta || "");
|
|
42421
44134
|
if (!text) return false;
|
|
44135
|
+
const profileStart = streamIsolationDebugLedger ? performance.now() : 0;
|
|
42422
44136
|
streamRawText += text;
|
|
42423
|
-
|
|
44137
|
+
ensureStreamDerivedOutputState().append(text);
|
|
44138
|
+
captureStreamDerivedOutputProfile(profileStart);
|
|
42424
44139
|
return true;
|
|
42425
44140
|
}
|
|
42426
44141
|
|
|
@@ -42442,12 +44157,13 @@ function syncStreamRawTextFromUpdate(event, update) {
|
|
|
42442
44157
|
}
|
|
42443
44158
|
|
|
42444
44159
|
function streamDerivedText() {
|
|
42445
|
-
|
|
42446
|
-
|
|
42447
|
-
|
|
42448
|
-
|
|
42449
|
-
|
|
42450
|
-
|
|
44160
|
+
const state = ensureStreamDerivedOutputState();
|
|
44161
|
+
if (state.value().rawText !== streamRawText) {
|
|
44162
|
+
const profileStart = streamIsolationDebugLedger ? performance.now() : 0;
|
|
44163
|
+
state.replace(streamRawText, { reason: "state-divergence" });
|
|
44164
|
+
captureStreamDerivedOutputProfile(profileStart);
|
|
44165
|
+
}
|
|
44166
|
+
return state.value();
|
|
42451
44167
|
}
|
|
42452
44168
|
|
|
42453
44169
|
function streamRenderableAssistantText() {
|
|
@@ -42522,27 +44238,28 @@ function scheduleStreamBubbleHide() {
|
|
|
42522
44238
|
}, delayMs);
|
|
42523
44239
|
}
|
|
42524
44240
|
|
|
42525
|
-
function syncStreamingThinkingFormat() {
|
|
44241
|
+
function syncStreamingThinkingFormat({ complete = false } = {}) {
|
|
42526
44242
|
const parsed = streamDerivedText().thinkingFormat;
|
|
42527
44243
|
if (!parsed?.hasThinkingFormat) return null;
|
|
42528
44244
|
const thinking = visibleThinkingText(parsed.thinkingText);
|
|
42529
|
-
if (thinking) setStreamingThinkingText(thinking);
|
|
44245
|
+
if (thinking) setStreamingThinkingText(thinking, { complete: complete || parsed.complete });
|
|
42530
44246
|
if (parsed.complete && streamThinkingBubble) streamThinkingBubble.classList.add("complete");
|
|
42531
44247
|
return parsed;
|
|
42532
44248
|
}
|
|
42533
44249
|
|
|
42534
|
-
function renderStreamingAssistantText() {
|
|
42535
|
-
const thinkingFormat = syncStreamingThinkingFormat();
|
|
44250
|
+
function renderStreamingAssistantText({ complete = false } = {}) {
|
|
44251
|
+
const thinkingFormat = syncStreamingThinkingFormat({ complete });
|
|
42536
44252
|
const finalText = thinkingFormat?.hasThinkingFormat ? streamDerivedText().finalText : streamRenderableAssistantText();
|
|
42537
44253
|
if (finalText) {
|
|
42538
44254
|
ensureStreamBubble();
|
|
42539
|
-
renderStreamingMarkdown(streamText, finalText);
|
|
44255
|
+
renderStreamingMarkdown(streamText, finalText, { complete });
|
|
42540
44256
|
} else {
|
|
42541
44257
|
scheduleStreamBubbleHide();
|
|
42542
44258
|
}
|
|
42543
44259
|
}
|
|
42544
44260
|
|
|
42545
44261
|
function suppressStreamingAssistantTextBeforeToolCall() {
|
|
44262
|
+
flushNormalStreamRenders("tool-call-boundary");
|
|
42546
44263
|
setStreamRawText("");
|
|
42547
44264
|
removeStreamBubble();
|
|
42548
44265
|
}
|
|
@@ -42637,14 +44354,14 @@ function showStreamingThinking(initialText = "") {
|
|
|
42637
44354
|
}
|
|
42638
44355
|
|
|
42639
44356
|
function resetStreamBubble({ preserveCompact = false } = {}) {
|
|
44357
|
+
cancelNormalStreamRenders();
|
|
42640
44358
|
resetCompactLiveOutput({ remove: !preserveCompact });
|
|
42641
44359
|
cancelStreamBubbleHide();
|
|
42642
44360
|
streamBubble = null;
|
|
42643
44361
|
streamText = null;
|
|
42644
44362
|
streamRawText = "";
|
|
42645
44363
|
streamThinkingRawText = "";
|
|
42646
|
-
|
|
42647
|
-
streamMarkdownState = null;
|
|
44364
|
+
resetStreamDerivedOutputState("reset");
|
|
42648
44365
|
streamBubbleVisibleSince = 0;
|
|
42649
44366
|
streamToolCallSeen = false;
|
|
42650
44367
|
resetStreamingToolCallState({ remove: true });
|
|
@@ -42810,11 +44527,11 @@ function assistantThinkingTextFromMessage(message, { streaming = false } = {}) {
|
|
|
42810
44527
|
return parts.length ? parts.join("\n\n") : "";
|
|
42811
44528
|
}
|
|
42812
44529
|
|
|
42813
|
-
function setStreamingThinkingText(text) {
|
|
44530
|
+
function setStreamingThinkingText(text, { complete = false } = {}) {
|
|
42814
44531
|
const thinking = visibleThinkingText(text);
|
|
42815
44532
|
if (!thinkingOutputVisible || !thinking) return false;
|
|
42816
44533
|
showStreamingThinking("");
|
|
42817
|
-
if (streamThinking) renderThinkingMarkdown(streamThinking, thinking);
|
|
44534
|
+
if (streamThinking) renderThinkingMarkdown(streamThinking, thinking, { complete });
|
|
42818
44535
|
return true;
|
|
42819
44536
|
}
|
|
42820
44537
|
|
|
@@ -42839,16 +44556,17 @@ function appendStreamThinkingText(delta) {
|
|
|
42839
44556
|
return true;
|
|
42840
44557
|
}
|
|
42841
44558
|
|
|
42842
|
-
function syncStreamingThinkingFromUpdate(event, update, { placeholder = "" } = {}) {
|
|
44559
|
+
function syncStreamingThinkingFromUpdate(event, update, { placeholder = "", render = true } = {}) {
|
|
42843
44560
|
if (!thinkingOutputVisible) return true;
|
|
42844
44561
|
const delta = thinkingDeltaText(update);
|
|
42845
44562
|
if (update.type === "thinking_delta" && delta) {
|
|
42846
44563
|
appendStreamThinkingText(delta);
|
|
42847
|
-
return setStreamingThinkingText(streamThinkingRawText || placeholder);
|
|
44564
|
+
return render ? setStreamingThinkingText(streamThinkingRawText || placeholder) : true;
|
|
42848
44565
|
}
|
|
42849
44566
|
if (update.type === "thinking_start") {
|
|
42850
44567
|
if (delta) setStreamThinkingRawText(delta);
|
|
42851
|
-
|
|
44568
|
+
if (!streamThinkingRawText) return false;
|
|
44569
|
+
return render ? setStreamingThinkingText(streamThinkingRawText || placeholder) : true;
|
|
42852
44570
|
}
|
|
42853
44571
|
if (update.type === "thinking_end") {
|
|
42854
44572
|
if (delta) setStreamThinkingRawText(delta, { reconcile: true });
|
|
@@ -42856,12 +44574,12 @@ function syncStreamingThinkingFromUpdate(event, update, { placeholder = "" } = {
|
|
|
42856
44574
|
const fallback = streamingThinkingTextFallback(event);
|
|
42857
44575
|
if (fallback !== null) setStreamThinkingRawText(fallback, { reconcile: true });
|
|
42858
44576
|
}
|
|
42859
|
-
return setStreamingThinkingText(streamThinkingRawText || placeholder);
|
|
44577
|
+
return render ? setStreamingThinkingText(streamThinkingRawText || placeholder, { complete: true }) : true;
|
|
42860
44578
|
}
|
|
42861
44579
|
const fallback = streamingThinkingTextFallback(event);
|
|
42862
44580
|
if (fallback === null) return false;
|
|
42863
44581
|
setStreamThinkingRawText(fallback);
|
|
42864
|
-
return setStreamingThinkingText(streamThinkingRawText || placeholder);
|
|
44582
|
+
return render ? setStreamingThinkingText(streamThinkingRawText || placeholder) : true;
|
|
42865
44583
|
}
|
|
42866
44584
|
|
|
42867
44585
|
function assistantStreamErrorMessage(event, update = event?.assistantMessageEvent || {}) {
|
|
@@ -42878,20 +44596,20 @@ function assistantStreamErrorMessage(event, update = event?.assistantMessageEven
|
|
|
42878
44596
|
function handleMessageUpdate(event) {
|
|
42879
44597
|
if (compactOutputActive() && handleCompactMessageUpdate(event)) return;
|
|
42880
44598
|
const update = event.assistantMessageEvent || {};
|
|
42881
|
-
if (update.type === "thinking_start") {
|
|
42882
|
-
syncStreamingThinkingFromUpdate(event, update);
|
|
42883
|
-
|
|
42884
|
-
const delta = thinkingDeltaText(update);
|
|
42885
|
-
const synced = syncStreamingThinkingFromUpdate(event, update);
|
|
42886
|
-
if (thinkingOutputVisible && delta && (!synced || !streamThinking?.textContent)) {
|
|
42887
|
-
showStreamingThinking("");
|
|
42888
|
-
if (streamThinking) renderThinkingMarkdown(streamThinking, `${streamThinking._rawThinkingText || ""}${delta}`);
|
|
42889
|
-
}
|
|
44599
|
+
if (update.type === "thinking_start" || update.type === "thinking_delta") {
|
|
44600
|
+
syncStreamingThinkingFromUpdate(event, update, { render: false });
|
|
44601
|
+
if (thinkingOutputVisible && streamThinkingRawText) thinkingStreamRenderScheduler.request({ complete: false });
|
|
42890
44602
|
} else if (update.type === "thinking_end") {
|
|
42891
|
-
|
|
44603
|
+
syncStreamingThinkingFromUpdate(event, update, { render: false });
|
|
44604
|
+
if (thinkingOutputVisible && streamThinkingRawText) {
|
|
44605
|
+
thinkingStreamRenderScheduler.request({ complete: true });
|
|
44606
|
+
thinkingStreamRenderScheduler.flushNow("thinking_end");
|
|
44607
|
+
}
|
|
42892
44608
|
} else if (update.type === "text_delta" || update.type === "text_end") {
|
|
42893
44609
|
syncStreamRawTextFromUpdate(event, update);
|
|
42894
|
-
|
|
44610
|
+
if (update.type === "text_end") fallbackStreamDerivedOutput("settlement:text_end");
|
|
44611
|
+
assistantStreamRenderScheduler.request({ complete: update.type === "text_end" });
|
|
44612
|
+
if (update.type === "text_end") assistantStreamRenderScheduler.flushNow("text_end");
|
|
42895
44613
|
} else if (update.type === "toolcall_start") {
|
|
42896
44614
|
streamToolCallSeen = true;
|
|
42897
44615
|
suppressStreamingAssistantTextBeforeToolCall();
|
|
@@ -43349,6 +45067,7 @@ function renderModelSearchResults(models = []) {
|
|
|
43349
45067
|
);
|
|
43350
45068
|
button.addEventListener("click", () => {
|
|
43351
45069
|
if (elements.modelSelect) elements.modelSelect.value = value;
|
|
45070
|
+
setControlsPendingModel(value);
|
|
43352
45071
|
renderModelSearchResults(models);
|
|
43353
45072
|
});
|
|
43354
45073
|
button.addEventListener("dblclick", () => elements.setModelButton?.click());
|
|
@@ -43412,9 +45131,23 @@ function hideModelSearchInput() {
|
|
|
43412
45131
|
scheduleDeferredUiFlushAfterDropdownClose();
|
|
43413
45132
|
}
|
|
43414
45133
|
|
|
45134
|
+
function setControlsPendingModel(value) {
|
|
45135
|
+
controlsPendingModelValue = value || "";
|
|
45136
|
+
elements.setModelButton?.classList.toggle("pending", Boolean(controlsPendingModelValue));
|
|
45137
|
+
if (elements.setModelButton) elements.setModelButton.title = controlsPendingModelValue ? "Apply the selected model (not applied yet)" : "Apply selected model";
|
|
45138
|
+
}
|
|
45139
|
+
|
|
45140
|
+
function setControlsPendingThinking(value) {
|
|
45141
|
+
controlsPendingThinkingValue = value || "";
|
|
45142
|
+
elements.setThinkingButton?.classList.toggle("pending", Boolean(controlsPendingThinkingValue));
|
|
45143
|
+
if (elements.setThinkingButton) elements.setThinkingButton.title = controlsPendingThinkingValue ? "Apply the selected thinking effort (not applied yet)" : "Apply selected thinking effort";
|
|
45144
|
+
}
|
|
45145
|
+
|
|
43415
45146
|
function syncModelSelectToState() {
|
|
43416
45147
|
if (!currentState?.model || !elements.modelSelect.options.length) return;
|
|
43417
45148
|
const value = JSON.stringify({ provider: currentState.model.provider, modelId: currentState.model.id });
|
|
45149
|
+
if (controlsPendingModelValue && controlsPendingModelValue === value) setControlsPendingModel("");
|
|
45150
|
+
if (controlsPendingModelValue) return; // keep the user's unapplied choice visible
|
|
43418
45151
|
for (const option of elements.modelSelect.options) {
|
|
43419
45152
|
if (option.value === value) {
|
|
43420
45153
|
elements.modelSelect.value = value;
|
|
@@ -43542,6 +45275,8 @@ function getCommandTrigger() {
|
|
|
43542
45275
|
if (!match) return null;
|
|
43543
45276
|
|
|
43544
45277
|
const query = match[2] || "";
|
|
45278
|
+
// "/etc/hosts" or "/tmp/x.txt" mid-sentence is a path, not a slash command.
|
|
45279
|
+
if (query.includes("/")) return null;
|
|
43545
45280
|
return {
|
|
43546
45281
|
start: cursor - query.length - 1,
|
|
43547
45282
|
end: cursor,
|
|
@@ -43650,6 +45385,15 @@ function cancelBangSuggestionRequest() {
|
|
|
43650
45385
|
function showCommandSuggestionList() {
|
|
43651
45386
|
elements.commandSuggest.hidden = false;
|
|
43652
45387
|
elements.promptInput?.setAttribute("aria-expanded", "true");
|
|
45388
|
+
const hasChoices = elements.commandSuggest.querySelector(".command-suggest-item") !== null;
|
|
45389
|
+
let hint = elements.commandSuggest.querySelector(".command-suggest-hint");
|
|
45390
|
+
if (hasChoices && !hint) {
|
|
45391
|
+
hint = make("div", "command-suggest-hint", "↑↓ navigate · Enter or Tab accept · Esc close");
|
|
45392
|
+
hint.setAttribute("aria-hidden", "true");
|
|
45393
|
+
elements.commandSuggest.append(hint);
|
|
45394
|
+
} else if (!hasChoices && hint) {
|
|
45395
|
+
hint.remove();
|
|
45396
|
+
}
|
|
43653
45397
|
}
|
|
43654
45398
|
|
|
43655
45399
|
function hideCommandSuggestions() {
|
|
@@ -43813,6 +45557,9 @@ async function renderPathSuggestions(trigger, { keepIndex = false } = {}) {
|
|
|
43813
45557
|
elements.commandSuggest.setAttribute("aria-busy", "true");
|
|
43814
45558
|
|
|
43815
45559
|
try {
|
|
45560
|
+
// Debounce keystrokes: one directory scan per pause instead of one per character.
|
|
45561
|
+
await new Promise((resolve) => setTimeout(resolve, PATH_SUGGEST_DEBOUNCE_MS));
|
|
45562
|
+
if (requestSerial !== pathSuggestRequestSerial || controller.signal.aborted) return;
|
|
43816
45563
|
const response = await api(`/api/path-suggestions?query=${encodeURIComponent(trigger.query)}`, { signal: controller.signal });
|
|
43817
45564
|
if (requestSerial !== pathSuggestRequestSerial || document.activeElement !== elements.promptInput) return;
|
|
43818
45565
|
pathSuggestions = normalizePathSuggestions(response.data?.suggestions || []);
|
|
@@ -44102,6 +45849,16 @@ function commandPaletteCoreItems() {
|
|
|
44102
45849
|
{ kind: "Pi", label: "/scoped-models", description: "Manage model cycling scope", keywords: "models cycle ctrl p", run: () => runNativeCommandMenu("/scoped-models") },
|
|
44103
45850
|
{ kind: "Pi", label: "/tools", description: "Manage active tools", keywords: "capabilities", run: () => runNativeCommandMenu("/tools") },
|
|
44104
45851
|
{ kind: "Pi", label: "/skills", description: "Manage active skills", keywords: "system prompt", run: () => runNativeCommandMenu("/skills") },
|
|
45852
|
+
{ kind: "Pi", label: "/theme", description: "Choose the Web UI theme", keywords: "dark light colors appearance", run: () => openNativeThemeSelector() },
|
|
45853
|
+
{ kind: "Git", label: "Guided Git workflow", description: "Stage, commit, push, or open a pull request step by step", keywords: "git commit push pr publish", run: () => startGitWorkflow() },
|
|
45854
|
+
{ kind: "Git", label: "Git changes", description: "Review and stage local changes with diffs", keywords: "git diff stage unstage discard status", run: () => openGitChangesDialog() },
|
|
45855
|
+
{ kind: "Action", label: "Files panel", description: "Open the Files section of the Control Deck", keywords: "tree browse project explorer", run: () => revealSidePanelSectionById("files") },
|
|
45856
|
+
{ kind: "Action", label: "Git panel", description: "Open the Git section of the Control Deck", keywords: "repository status history", run: () => revealSidePanelSectionById("git") },
|
|
45857
|
+
{ kind: "Action", label: "Events log", description: "Open the Events section of the Control Deck", keywords: "errors warnings log diagnostics", run: () => revealEventsSection() },
|
|
45858
|
+
{ kind: "Action", label: thinkingOutputVisible ? "Hide thinking output" : "Show thinking output", description: "Toggle thinking cards in the transcript (Ctrl/Cmd+T in the composer)", keywords: "reasoning thinking toggle", run: () => setThinkingOutputVisible(!thinkingOutputVisible, { announce: true }) },
|
|
45859
|
+
{ kind: "Action", label: toolOutputGloballyExpanded ? "Collapse tool output" : "Expand tool output", description: "Toggle tool result cards (Ctrl/Cmd+O in the composer)", keywords: "tools results collapse expand", run: () => setToolOutputGloballyExpanded(!toolOutputGloballyExpanded, { announce: true }) },
|
|
45860
|
+
{ kind: "Action", label: "Show all controls", description: "Restore every hidden button and input tag", keywords: "visibility hidden restore controls buttons", run: () => showAllControls() },
|
|
45861
|
+
{ kind: "Action", label: "Reset control visibility", description: "Return hidden/visible controls to the defaults", keywords: "visibility defaults controls buttons", run: () => resetControlVisibilityDefaults() },
|
|
44105
45862
|
];
|
|
44106
45863
|
if (tabs.length) {
|
|
44107
45864
|
items.push({ kind: "Workspace", label: "Workspace: Save", description: "Capture all open tabs, sessions, groups, and the active tab", keywords: "workspace snapshot save sessions groups", run: () => saveWebuiWorkspace({ triggerButton: elements.commandPaletteButton }) });
|
|
@@ -44160,10 +45917,32 @@ function buildCommandPaletteItems() {
|
|
|
44160
45917
|
];
|
|
44161
45918
|
}
|
|
44162
45919
|
|
|
45920
|
+
// Ranking: label prefix > label word-start > label contains > description/keywords only.
|
|
45921
|
+
// Ties keep catalog order (actions, tabs, models, commands), so results stay predictable.
|
|
45922
|
+
function paletteItemScore(item, query) {
|
|
45923
|
+
const label = paletteText(item.label);
|
|
45924
|
+
const tokens = query.split(/\s+/).filter(Boolean);
|
|
45925
|
+
let score = 0;
|
|
45926
|
+
for (const token of tokens) {
|
|
45927
|
+
if (label.startsWith(token)) score += 40;
|
|
45928
|
+
else if (label.replace(/^\//, "").startsWith(token)) score += 36;
|
|
45929
|
+
else if (new RegExp(`(^|[\\s/_-])${token.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`).test(label)) score += 24;
|
|
45930
|
+
else if (label.includes(token)) score += 12;
|
|
45931
|
+
else score += 1;
|
|
45932
|
+
}
|
|
45933
|
+
return score;
|
|
45934
|
+
}
|
|
45935
|
+
|
|
44163
45936
|
function filteredCommandPaletteItems() {
|
|
44164
45937
|
const query = paletteText(elements.commandPaletteInput?.value || "").trim();
|
|
44165
45938
|
const items = buildCommandPaletteItems();
|
|
44166
|
-
|
|
45939
|
+
if (!query) return items.slice(0, 80);
|
|
45940
|
+
return items
|
|
45941
|
+
.map((item, index) => ({ item, index, score: paletteItemMatches(item, query) ? paletteItemScore(item, query) : -1 }))
|
|
45942
|
+
.filter((entry) => entry.score >= 0)
|
|
45943
|
+
.sort((a, b) => b.score - a.score || a.index - b.index)
|
|
45944
|
+
.slice(0, 80)
|
|
45945
|
+
.map((entry) => entry.item);
|
|
44167
45946
|
}
|
|
44168
45947
|
|
|
44169
45948
|
function setCommandPaletteIndex(index) {
|
|
@@ -44267,6 +46046,7 @@ function reportRefreshFailures(results, prefix = "") {
|
|
|
44267
46046
|
|
|
44268
46047
|
async function refreshAll(tabContext = activeTabContext()) {
|
|
44269
46048
|
if (!tabContext.tabId) return;
|
|
46049
|
+
noteRecentFullRefresh();
|
|
44270
46050
|
const results = await Promise.allSettled([
|
|
44271
46051
|
refreshState(tabContext),
|
|
44272
46052
|
refreshMessages(tabContext),
|
|
@@ -44358,7 +46138,16 @@ async function reconcileForegroundState(reason = "resume") {
|
|
|
44358
46138
|
renderMobilePhoneExperience();
|
|
44359
46139
|
}
|
|
44360
46140
|
|
|
46141
|
+
// A tab activation/boot just ran the full refresh; the immediately following "event stream
|
|
46142
|
+
// reconnect" and "page show" signals would otherwise repeat every catalog fetch a second time.
|
|
46143
|
+
let recentFullRefreshFreshUntil = 0;
|
|
46144
|
+
|
|
46145
|
+
function noteRecentFullRefresh() {
|
|
46146
|
+
recentFullRefreshFreshUntil = performance.now() + 3_000;
|
|
46147
|
+
}
|
|
46148
|
+
|
|
44361
46149
|
function scheduleForegroundReconcile(reason = "resume", delay = FOREGROUND_RECONCILE_DELAY_MS) {
|
|
46150
|
+
if ((reason === "event stream reconnect" || reason === "page show") && performance.now() < recentFullRefreshFreshUntil && !foregroundTranscriptCatchUpRequired) return;
|
|
44362
46151
|
clearTimeout(foregroundReconcileTimer);
|
|
44363
46152
|
foregroundReconcileTimer = setTimeout(() => {
|
|
44364
46153
|
foregroundReconcileTimer = null;
|
|
@@ -44613,10 +46402,31 @@ function clearPromptFromShortcut() {
|
|
|
44613
46402
|
if (document.activeElement !== input) return false;
|
|
44614
46403
|
if (input.selectionStart !== input.selectionEnd) return false;
|
|
44615
46404
|
if (!input.value) return false;
|
|
44616
|
-
input.value
|
|
46405
|
+
const previous = input.value;
|
|
46406
|
+
// Go through the editing command so the browser's own Ctrl+Z can bring the text back.
|
|
46407
|
+
let cleared = false;
|
|
46408
|
+
try {
|
|
46409
|
+
input.select();
|
|
46410
|
+
cleared = document.execCommand("delete");
|
|
46411
|
+
} catch {
|
|
46412
|
+
cleared = false;
|
|
46413
|
+
}
|
|
46414
|
+
if (!cleared || input.value) input.value = "";
|
|
44617
46415
|
resizePromptInput();
|
|
44618
46416
|
renderCommandSuggestions();
|
|
44619
46417
|
addEvent("prompt cleared", "info");
|
|
46418
|
+
offerUndo({
|
|
46419
|
+
message: "Prompt cleared (Ctrl/Cmd+C with nothing selected).",
|
|
46420
|
+
undo: () => {
|
|
46421
|
+
input.value = previous;
|
|
46422
|
+
resizePromptInput();
|
|
46423
|
+
renderCommandSuggestions();
|
|
46424
|
+
input.focus({ preventScroll: true });
|
|
46425
|
+
input.setSelectionRange(previous.length, previous.length);
|
|
46426
|
+
},
|
|
46427
|
+
successMessage: "Prompt restored.",
|
|
46428
|
+
timeoutMs: 8000,
|
|
46429
|
+
});
|
|
44620
46430
|
return true;
|
|
44621
46431
|
}
|
|
44622
46432
|
|
|
@@ -44993,13 +46803,15 @@ function handleExtensionUiRequest(request) {
|
|
|
44993
46803
|
if (request.statusText) {
|
|
44994
46804
|
statusEntries.set(statusKey, request.statusText);
|
|
44995
46805
|
if (statusKey === GIT_FOOTER_WEBUI_STATUS_KEY) {
|
|
44996
|
-
const
|
|
46806
|
+
const footerPayload = parseGitFooterWebuiPayloadRaw(request.statusText);
|
|
46807
|
+
const validPayload = !!footerPayload;
|
|
44997
46808
|
cacheGitFooterWebuiPayload(request.statusText, request.tabId);
|
|
44998
46809
|
settleGitFooterPayload(
|
|
44999
46810
|
request.tabId || activeTabId,
|
|
45000
46811
|
validPayload ? "ready" : "failed",
|
|
45001
46812
|
validPayload ? "" : "Git footer returned invalid status data — refresh to retry",
|
|
45002
46813
|
);
|
|
46814
|
+
if (footerPayload) syncClaudeUsageFromGitFooterPayload(footerPayload);
|
|
45003
46815
|
}
|
|
45004
46816
|
} else {
|
|
45005
46817
|
statusEntries.delete(statusKey);
|
|
@@ -45506,7 +47318,7 @@ function scheduleSupervisorContinuityRefresh(event, { gap = false } = {}) {
|
|
|
45506
47318
|
|
|
45507
47319
|
if (gap && !supervisorGapWarnings.has(key)) {
|
|
45508
47320
|
supervisorGapWarnings.add(key);
|
|
45509
|
-
addEvent("Buffered live output may be incomplete; refreshing tabs, state, and transcript from Pi.", "
|
|
47321
|
+
addEvent("Buffered live output may be incomplete; refreshing tabs, state, and transcript from Pi.", "info");
|
|
45510
47322
|
}
|
|
45511
47323
|
if (supervisorContinuityRefreshes.has(key)) return;
|
|
45512
47324
|
|
|
@@ -45578,6 +47390,7 @@ const TRANSCRIPT_STREAM_BARRIER_EVENT_TYPES = new Set([
|
|
|
45578
47390
|
function beginForegroundTranscriptCatchUp() {
|
|
45579
47391
|
foregroundTranscriptCatchUpRequired = true;
|
|
45580
47392
|
backgroundReconnectSnapshotFresh = false;
|
|
47393
|
+
flushNormalStreamRenders("visibility-hidden");
|
|
45581
47394
|
streamOutputController.cancel();
|
|
45582
47395
|
if (!eventSource) return;
|
|
45583
47396
|
eventStreamPausedForBackground = true;
|
|
@@ -45602,6 +47415,10 @@ function dispatchTranscriptStreamEvent(event) {
|
|
|
45602
47415
|
function flushTranscriptStreamBarrier(event) {
|
|
45603
47416
|
if (!TRANSCRIPT_STREAM_BARRIER_EVENT_TYPES.has(event?.type)) return;
|
|
45604
47417
|
streamOutputController.barrier(event.type);
|
|
47418
|
+
if (["message_end", "agent_end", "agent_settled", "compaction_end", "pi_process_exit", "pi_process_error"].includes(event.type)) {
|
|
47419
|
+
fallbackStreamDerivedOutput(`settlement:${event.type}`);
|
|
47420
|
+
}
|
|
47421
|
+
flushNormalStreamRenders(event.type);
|
|
45605
47422
|
reconcileUnknownTranscriptEvidenceAtBarrier(event);
|
|
45606
47423
|
if (event.type === "pi_process_exit" || event.type === "pi_process_error") streamOutputController.cancel();
|
|
45607
47424
|
}
|
|
@@ -45728,12 +47545,18 @@ function handleEvent(event) {
|
|
|
45728
47545
|
}
|
|
45729
47546
|
break;
|
|
45730
47547
|
}
|
|
45731
|
-
case "webui_app_runner_update":
|
|
45732
|
-
|
|
47548
|
+
case "webui_app_runner_update": {
|
|
47549
|
+
const runTabId = event.tabId || activeTabId;
|
|
47550
|
+
const previousRun = appRunnerDataByTab.get(runTabId)?.activeRun || null;
|
|
47551
|
+
setAppRunnerData(runTabId, { cwd: event.cwd, activeRun: event.activeRun });
|
|
45733
47552
|
renderAppRunnerControls();
|
|
45734
|
-
|
|
45735
|
-
|
|
47553
|
+
// A chatty dev server sends several updates per second; append only the new lines to the
|
|
47554
|
+
// existing widget instead of rebuilding every widget and the tab strip each time.
|
|
47555
|
+
if (!patchAppRunnerWidgetInPlace(runTabId, previousRun, event.activeRun)) renderWidgets();
|
|
47556
|
+
const runningChanged = Boolean(previousRun && appRunnerIsRunning(previousRun)) !== Boolean(event.activeRun && appRunnerIsRunning(event.activeRun));
|
|
47557
|
+
if (!previousRun !== !event.activeRun || runningChanged || previousRun?.id !== event.activeRun?.id) renderTabs();
|
|
45736
47558
|
break;
|
|
47559
|
+
}
|
|
45737
47560
|
case "webui_git_changed":
|
|
45738
47561
|
invalidateGitPanelRepository(event.root);
|
|
45739
47562
|
break;
|
|
@@ -45832,7 +47655,7 @@ function handleEvent(event) {
|
|
|
45832
47655
|
if (!assistantErrorSurfacedThisRun && event.willRetry !== true) {
|
|
45833
47656
|
const message = assistantErrorFromAgentEnd(event);
|
|
45834
47657
|
if (message) {
|
|
45835
|
-
surfaceRuntimeDiagnostic("Assistant error", message);
|
|
47658
|
+
surfaceRuntimeDiagnostic("Assistant error", describeAssistantFailure(message), "error", { actions: assistantFailureActions(event.tabId || activeTabId) });
|
|
45836
47659
|
assistantErrorSurfacedThisRun = true;
|
|
45837
47660
|
}
|
|
45838
47661
|
}
|
|
@@ -45852,7 +47675,7 @@ function handleEvent(event) {
|
|
|
45852
47675
|
streamMessageActive = false;
|
|
45853
47676
|
if (event.message?.role === "assistant" && event.message.stopReason === "error") {
|
|
45854
47677
|
const message = String(event.message.errorMessage || streamProviderErrorText || "The assistant request failed without an error message.").trim();
|
|
45855
|
-
surfaceRuntimeDiagnostic("Assistant error", message);
|
|
47678
|
+
surfaceRuntimeDiagnostic("Assistant error", describeAssistantFailure(message), "error", { actions: assistantFailureActions(event.tabId || activeTabId) });
|
|
45856
47679
|
assistantErrorSurfacedThisRun = true;
|
|
45857
47680
|
}
|
|
45858
47681
|
streamProviderErrorText = "";
|
|
@@ -45955,22 +47778,24 @@ function handleEvent(event) {
|
|
|
45955
47778
|
const seconds = Math.max(0, Math.ceil(Number(event.delayMs || 0) / 1000));
|
|
45956
47779
|
const retryText = `Retrying (${event.attempt || "?"}/${event.maxAttempts || "?"}) in ${seconds}s after: ${event.errorMessage || "model/provider error"}`;
|
|
45957
47780
|
setRunIndicatorActivity(retryText);
|
|
45958
|
-
addEvent(retryText, "warn");
|
|
45959
|
-
addTransientMessage({ role: "warn", title: "auto retry", content: retryText, level: "warn" });
|
|
47781
|
+
addEvent(retryText, "warn", { notify: false });
|
|
47782
|
+
addTransientMessage({ role: "warn", title: "auto retry", content: retryText, level: "warn", key: "auto-retry" });
|
|
45960
47783
|
break;
|
|
45961
47784
|
}
|
|
45962
47785
|
case "auto_retry_end":
|
|
45963
47786
|
if (event.success === false) {
|
|
45964
47787
|
const retryError = `Retry failed after ${event.attempt || "?"} attempt(s): ${event.finalError || "Unknown error"}`;
|
|
45965
|
-
addEvent(retryError, "error");
|
|
45966
|
-
addTransientMessage({ role: "error", title: "auto retry failed", content: retryError, level: "error" });
|
|
47788
|
+
addEvent(retryError, "error", { notify: false });
|
|
47789
|
+
addTransientMessage({ role: "error", title: "auto retry failed", content: describeAssistantFailure(retryError), level: "error", key: "auto-retry", actions: assistantFailureActions(event.tabId || activeTabId) });
|
|
45967
47790
|
} else {
|
|
45968
47791
|
addEvent(`retry recovered after ${event.attempt || "?"} attempt(s)`);
|
|
47792
|
+
transientMessages = transientMessages.filter((message) => message?.key !== "auto-retry");
|
|
47793
|
+
renderAllMessages();
|
|
45969
47794
|
}
|
|
45970
47795
|
break;
|
|
45971
47796
|
case "extension_error": {
|
|
45972
47797
|
const message = `${event.extensionPath || "extension"}${event.event ? ` during ${event.event}` : ""}: ${event.error || "unknown extension error"}`;
|
|
45973
|
-
addEvent(message, "error");
|
|
47798
|
+
addEvent(message, "error", { notify: false });
|
|
45974
47799
|
addTransientMessage({ role: "error", title: "extension error", content: message, level: "error" });
|
|
45975
47800
|
break;
|
|
45976
47801
|
}
|
|
@@ -46008,9 +47833,12 @@ function handleEvent(event) {
|
|
|
46008
47833
|
}
|
|
46009
47834
|
|
|
46010
47835
|
function connectEvents(tabContext = activeTabContext(), { requestedMode = "auto", fallbackAttempted = false } = {}) {
|
|
47836
|
+
flushNormalStreamRenders("reconnect");
|
|
47837
|
+
cancelNormalStreamRenders();
|
|
46011
47838
|
eventSource?.close();
|
|
46012
47839
|
eventSource = null;
|
|
46013
47840
|
streamOutputController.cancel();
|
|
47841
|
+
fallbackStreamDerivedOutput("reconnect");
|
|
46014
47842
|
resetCompactLiveOutput();
|
|
46015
47843
|
activeOutputMode = "normal";
|
|
46016
47844
|
outputModeAcknowledged = false;
|
|
@@ -46042,7 +47870,9 @@ function connectEvents(tabContext = activeTabContext(), { requestedMode = "auto"
|
|
|
46042
47870
|
source.onerror = () => {
|
|
46043
47871
|
if (eventSource !== source || !isCurrentTabContext(tabContext)) return;
|
|
46044
47872
|
streamOutputController.flush();
|
|
47873
|
+
flushNormalStreamRenders("disconnect");
|
|
46045
47874
|
streamOutputController.cancel();
|
|
47875
|
+
fallbackStreamDerivedOutput("disconnect");
|
|
46046
47876
|
if (compactOutputActive()) compactLiveScheduler.flushNow();
|
|
46047
47877
|
addEvent("event stream disconnected; browser will retry", "warn");
|
|
46048
47878
|
fetch("/api/health", { cache: "no-store" }).catch((error) => setBackendOffline(true, error));
|
|
@@ -46071,12 +47901,22 @@ elements.promptListSaveButton?.addEventListener("click", saveDisplayedPromptList
|
|
|
46071
47901
|
elements.promptListRunListButton?.addEventListener("click", () => runDisplayedPromptList());
|
|
46072
47902
|
elements.promptListCloseButton?.addEventListener("click", () => elements.promptListDialog?.close());
|
|
46073
47903
|
elements.promptListDialog?.querySelector("form")?.addEventListener("submit", (event) => event.preventDefault());
|
|
46074
|
-
elements.attachmentTextCancelButton?.addEventListener("click", closeTextAttachmentEditor);
|
|
47904
|
+
elements.attachmentTextCancelButton?.addEventListener("click", () => closeTextAttachmentEditor());
|
|
46075
47905
|
elements.attachmentTextSaveButton?.addEventListener("click", saveTextAttachmentEdit);
|
|
46076
47906
|
elements.attachmentTextEditor?.addEventListener("input", () => {
|
|
47907
|
+
if (activeTextAttachmentEditor) activeTextAttachmentEditor.dirty = true;
|
|
46077
47908
|
renderTextAttachmentEditorMeta();
|
|
46078
47909
|
setAttachmentTextStatus("Unsaved attachment edits.", "warn");
|
|
46079
47910
|
});
|
|
47911
|
+
elements.attachmentTextDialog?.addEventListener("cancel", (event) => {
|
|
47912
|
+
if (!activeTextAttachmentEditor?.dirty) return;
|
|
47913
|
+
event.preventDefault();
|
|
47914
|
+
confirmDiscardEdits({ what: "unsaved attachment edits", target: "The attachment text" }).then((confirmed) => {
|
|
47915
|
+
if (!confirmed) return;
|
|
47916
|
+
if (activeTextAttachmentEditor) activeTextAttachmentEditor.dirty = false;
|
|
47917
|
+
elements.attachmentTextDialog.close();
|
|
47918
|
+
});
|
|
47919
|
+
});
|
|
46080
47920
|
elements.attachmentTextDialog?.addEventListener("close", () => {
|
|
46081
47921
|
activeTextAttachmentEditor = null;
|
|
46082
47922
|
if (elements.attachmentTextEditor) elements.attachmentTextEditor.value = "";
|
|
@@ -46088,9 +47928,21 @@ elements.attachmentTextDialog?.addEventListener("keydown", (event) => {
|
|
|
46088
47928
|
if (!elements.attachmentTextSaveButton?.disabled) saveTextAttachmentEdit();
|
|
46089
47929
|
});
|
|
46090
47930
|
elements.attachmentTextDialog?.querySelector("form")?.addEventListener("submit", (event) => event.preventDefault());
|
|
46091
|
-
elements.skillEditorCancelButton?.addEventListener("click", closeSkillEditor);
|
|
47931
|
+
elements.skillEditorCancelButton?.addEventListener("click", () => closeSkillEditor());
|
|
46092
47932
|
elements.skillEditorSaveButton?.addEventListener("click", saveSkillEditor);
|
|
46093
|
-
elements.skillEditorText?.addEventListener("input", () =>
|
|
47933
|
+
elements.skillEditorText?.addEventListener("input", () => {
|
|
47934
|
+
if (activeSkillEditor) activeSkillEditor.dirty = true;
|
|
47935
|
+
setSkillEditorStatus("Unsaved skill edits.", "warn");
|
|
47936
|
+
});
|
|
47937
|
+
elements.skillEditorDialog?.addEventListener("cancel", (event) => {
|
|
47938
|
+
if (!activeSkillEditor?.dirty) return;
|
|
47939
|
+
event.preventDefault();
|
|
47940
|
+
confirmDiscardEdits({ what: "unsaved skill edits", target: activeSkillEditor?.path || activeSkillEditor?.name || "SKILL.md" }).then((confirmed) => {
|
|
47941
|
+
if (!confirmed) return;
|
|
47942
|
+
if (activeSkillEditor) activeSkillEditor.dirty = false;
|
|
47943
|
+
elements.skillEditorDialog.close();
|
|
47944
|
+
});
|
|
47945
|
+
});
|
|
46094
47946
|
elements.skillEditorDialog?.addEventListener("close", () => {
|
|
46095
47947
|
activeSkillEditor = null;
|
|
46096
47948
|
if (elements.skillEditorText) elements.skillEditorText.value = "";
|
|
@@ -46182,6 +48034,18 @@ elements.btwButton?.addEventListener("click", () => sendBtwPromptFromButton());
|
|
|
46182
48034
|
elements.terminalTabsToggleButton.addEventListener("click", () => {
|
|
46183
48035
|
setMobileTabsExpanded(!document.body.classList.contains("mobile-tabs-expanded"), { restoreFocus: true });
|
|
46184
48036
|
});
|
|
48037
|
+
// Tablist keyboard semantics: Left/Right/Home/End move focus between terminal tabs.
|
|
48038
|
+
elements.tabBar?.addEventListener("keydown", (event) => {
|
|
48039
|
+
if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key) || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
48040
|
+
const tabsInStrip = [...elements.tabBar.querySelectorAll('[role="tab"]')].filter((node) => !node.disabled && node.offsetParent !== null);
|
|
48041
|
+
const index = tabsInStrip.indexOf(document.activeElement);
|
|
48042
|
+
if (index === -1) return;
|
|
48043
|
+
event.preventDefault();
|
|
48044
|
+
const next = event.key === "Home" ? 0
|
|
48045
|
+
: event.key === "End" ? tabsInStrip.length - 1
|
|
48046
|
+
: (index + (event.key === "ArrowRight" ? 1 : -1) + tabsInStrip.length) % tabsInStrip.length;
|
|
48047
|
+
tabsInStrip[next]?.focus({ preventScroll: false });
|
|
48048
|
+
});
|
|
46185
48049
|
elements.newTabButton.addEventListener("click", (event) => {
|
|
46186
48050
|
event.stopPropagation();
|
|
46187
48051
|
openNewTabMenu();
|
|
@@ -46235,6 +48099,7 @@ elements.gitWorkflowButton.addEventListener("click", () => {
|
|
|
46235
48099
|
});
|
|
46236
48100
|
const publishMenuContainer = elements.publishButton.parentElement;
|
|
46237
48101
|
elements.publishButton.addEventListener("click", () => {
|
|
48102
|
+
clearComposerMenuDismissal(elements.publishButton.parentElement);
|
|
46238
48103
|
setNativeCommandMenuOpen(false);
|
|
46239
48104
|
setAppRunnerMenuOpen(false);
|
|
46240
48105
|
setOptionsMenuOpen(false);
|
|
@@ -46260,6 +48125,7 @@ publishMenuContainer?.addEventListener("focusout", () => {
|
|
|
46260
48125
|
});
|
|
46261
48126
|
const nativeCommandMenuContainer = elements.nativeCommandMenuButton.parentElement;
|
|
46262
48127
|
elements.nativeCommandMenuButton.addEventListener("click", () => {
|
|
48128
|
+
clearComposerMenuDismissal(elements.nativeCommandMenuButton.parentElement);
|
|
46263
48129
|
setPublishMenuOpen(false);
|
|
46264
48130
|
setAppRunnerMenuOpen(false);
|
|
46265
48131
|
setOptionsMenuOpen(false);
|
|
@@ -46327,6 +48193,7 @@ appRunnerMenuContainer?.addEventListener("focusout", () => {
|
|
|
46327
48193
|
});
|
|
46328
48194
|
const optionsMenuContainer = elements.optionsMenuButton.parentElement;
|
|
46329
48195
|
elements.optionsMenuButton.addEventListener("click", () => {
|
|
48196
|
+
clearComposerMenuDismissal(elements.optionsMenuButton.parentElement);
|
|
46330
48197
|
setPublishMenuOpen(false);
|
|
46331
48198
|
setNativeCommandMenuOpen(false);
|
|
46332
48199
|
setAppRunnerMenuOpen(false);
|
|
@@ -46501,6 +48368,13 @@ elements.nativeCommandDialog.addEventListener("cancel", (event) => {
|
|
|
46501
48368
|
event.preventDefault();
|
|
46502
48369
|
closeNativeCommandDialog();
|
|
46503
48370
|
});
|
|
48371
|
+
// The dialog form uses method="dialog"; without this, Enter inside the filter box (or any
|
|
48372
|
+
// settings text field) implicitly submits and closes the dialog without choosing anything.
|
|
48373
|
+
elements.nativeCommandDialog.querySelector("form")?.addEventListener("submit", (event) => {
|
|
48374
|
+
event.preventDefault();
|
|
48375
|
+
if (document.activeElement === elements.nativeCommandSearch) activateNativeSelectorHighlight();
|
|
48376
|
+
});
|
|
48377
|
+
elements.nativeCommandSearch.addEventListener("keydown", handleNativeSelectorSearchKeydown);
|
|
46504
48378
|
elements.nativeCommandDialog.addEventListener("close", () => {
|
|
46505
48379
|
elements.nativeCommandSearch.oninput = null;
|
|
46506
48380
|
nativeSettingsDirty = false;
|
|
@@ -46508,6 +48382,18 @@ elements.nativeCommandDialog.addEventListener("close", () => {
|
|
|
46508
48382
|
});
|
|
46509
48383
|
elements.undoToastButton?.addEventListener("click", () => runOfferedUndo());
|
|
46510
48384
|
elements.undoToastDismissButton?.addEventListener("click", dismissUndoToast);
|
|
48385
|
+
elements.textPromptDialog?.querySelector("form")?.addEventListener("submit", (event) => {
|
|
48386
|
+
event.preventDefault();
|
|
48387
|
+
submitTextPrompt();
|
|
48388
|
+
});
|
|
48389
|
+
elements.textPromptCancelButton?.addEventListener("click", () => finishTextPrompt(null));
|
|
48390
|
+
elements.textPromptDialog?.addEventListener("cancel", (event) => {
|
|
48391
|
+
event.preventDefault();
|
|
48392
|
+
finishTextPrompt(null);
|
|
48393
|
+
});
|
|
48394
|
+
elements.textPromptDialog?.addEventListener("close", () => {
|
|
48395
|
+
if (activeTextPromptResolve) finishTextPrompt(null);
|
|
48396
|
+
});
|
|
46511
48397
|
elements.confirmationCancelButton?.addEventListener("click", () => finishApplicationConfirmation(false));
|
|
46512
48398
|
elements.confirmationConfirmButton?.addEventListener("click", () => finishApplicationConfirmation(true));
|
|
46513
48399
|
elements.gitPullErrorMergeButton?.addEventListener("click", () => integrateGitPullDivergence("merge"));
|
|
@@ -46605,7 +48491,21 @@ function abortButtonHoldSeconds() {
|
|
|
46605
48491
|
}
|
|
46606
48492
|
|
|
46607
48493
|
function abortButtonReadyTitle() {
|
|
46608
|
-
return `Hold Esc or the Abort button for ${abortButtonHoldSeconds()}
|
|
48494
|
+
return `Hold Esc or the Abort button for about ${abortButtonHoldSeconds()} second to abort the active Pi run`;
|
|
48495
|
+
}
|
|
48496
|
+
|
|
48497
|
+
// A quick tap/click on Abort deliberately does nothing (the hold prevents accidental aborts), but
|
|
48498
|
+
// silently doing nothing reads as "broken". Show what to do for a moment instead.
|
|
48499
|
+
function showAbortTapHint() {
|
|
48500
|
+
if (!isAbortAvailable() || isAbortLongPressActive() || abortRequestInFlight) return;
|
|
48501
|
+
clearTimeout(abortTapHintTimer);
|
|
48502
|
+
elements.abortButton.classList.add("tap-hint");
|
|
48503
|
+
elements.abortButton.textContent = "Hold to abort";
|
|
48504
|
+
abortTapHintTimer = setTimeout(() => {
|
|
48505
|
+
abortTapHintTimer = null;
|
|
48506
|
+
elements.abortButton.classList.remove("tap-hint");
|
|
48507
|
+
if (!isAbortLongPressActive() && !abortRequestInFlight) elements.abortButton.textContent = "Abort";
|
|
48508
|
+
}, ABORT_TAP_HINT_MS);
|
|
46609
48509
|
}
|
|
46610
48510
|
|
|
46611
48511
|
function suppressEmptyPromptEscapeAction({ untilKeyup = false, graceMs = EMPTY_PROMPT_ESCAPE_AFTER_ABORT_GRACE_MS } = {}) {
|
|
@@ -46713,7 +48613,7 @@ function resetAbortLongPressAffordance() {
|
|
|
46713
48613
|
abortLongPressReleasePending = false;
|
|
46714
48614
|
elements.abortButton.classList.remove("long-pressing");
|
|
46715
48615
|
elements.abortButton.style.removeProperty("--abort-long-press-duration");
|
|
46716
|
-
if (!abortRequestInFlight) {
|
|
48616
|
+
if (!abortRequestInFlight && !abortTapHintTimer) {
|
|
46717
48617
|
elements.abortButton.textContent = "Abort";
|
|
46718
48618
|
elements.abortButton.title = isAbortAvailable() ? abortButtonReadyTitle() : "Abort is available while Pi is running";
|
|
46719
48619
|
elements.abortButton.setAttribute("aria-label", elements.abortButton.title);
|
|
@@ -46724,6 +48624,7 @@ async function abortActiveRun({ source = "button" } = {}) {
|
|
|
46724
48624
|
if (abortRequestInFlight || !isAbortAvailable()) return;
|
|
46725
48625
|
const tabContext = activeTabContext();
|
|
46726
48626
|
streamOutputController.barrier("user-abort");
|
|
48627
|
+
flushNormalStreamRenders("user-abort");
|
|
46727
48628
|
reconcileUnknownTranscriptEvidenceAtBarrier({ type: "user_abort", tabId: tabContext.tabId });
|
|
46728
48629
|
abortRequestInFlight = true;
|
|
46729
48630
|
resetAbortLongPressAffordance();
|
|
@@ -46793,7 +48694,11 @@ elements.abortButton.addEventListener("keyup", (event) => {
|
|
|
46793
48694
|
});
|
|
46794
48695
|
elements.abortButton.addEventListener("click", (event) => {
|
|
46795
48696
|
event.preventDefault();
|
|
46796
|
-
if (abortLongPressHandled)
|
|
48697
|
+
if (abortLongPressHandled) {
|
|
48698
|
+
abortLongPressHandled = false;
|
|
48699
|
+
return;
|
|
48700
|
+
}
|
|
48701
|
+
showAbortTapHint();
|
|
46797
48702
|
});
|
|
46798
48703
|
elements.newSessionButton.addEventListener("click", async () => {
|
|
46799
48704
|
setComposerActionsOpen(false);
|
|
@@ -46856,6 +48761,8 @@ elements.modelSearchInput?.addEventListener("keydown", (event) => {
|
|
|
46856
48761
|
elements.modelSearchInput.focus();
|
|
46857
48762
|
}
|
|
46858
48763
|
});
|
|
48764
|
+
elements.modelSelect?.addEventListener("change", () => setControlsPendingModel(elements.modelSelect.value));
|
|
48765
|
+
elements.thinkingSelect?.addEventListener("change", () => setControlsPendingThinking(elements.thinkingSelect.value));
|
|
46859
48766
|
elements.setModelButton.addEventListener("click", async () => {
|
|
46860
48767
|
if (!elements.modelSelect.value) return;
|
|
46861
48768
|
const tabContext = activeTabContext();
|
|
@@ -46863,6 +48770,7 @@ elements.setModelButton.addEventListener("click", async () => {
|
|
|
46863
48770
|
const selected = JSON.parse(elements.modelSelect.value);
|
|
46864
48771
|
const response = await api("/api/model", { method: "POST", body: selected, tabId: tabContext.tabId });
|
|
46865
48772
|
if (isCurrentTabContext(tabContext)) {
|
|
48773
|
+
setControlsPendingModel("");
|
|
46866
48774
|
applyOptimisticModelSelection(response.data || selected, tabContext);
|
|
46867
48775
|
await refreshState(tabContext);
|
|
46868
48776
|
}
|
|
@@ -46875,13 +48783,15 @@ elements.setThinkingButton.addEventListener("click", async () => {
|
|
|
46875
48783
|
try {
|
|
46876
48784
|
const response = await api("/api/thinking", { method: "POST", body: { level: elements.thinkingSelect.value }, tabId: tabContext.tabId });
|
|
46877
48785
|
if (isCurrentTabContext(tabContext)) {
|
|
48786
|
+
setControlsPendingThinking("");
|
|
46878
48787
|
applyOptimisticThinkingSelection(response.data, tabContext);
|
|
46879
48788
|
if (response.data?.pending) {
|
|
46880
48789
|
addEvent(response.data.message || `Thinking level ${response.data.level} will apply to the next prompt.`, "info");
|
|
46881
48790
|
} else if (response.data?.level) {
|
|
46882
48791
|
const requested = response.data.requestedLevel;
|
|
46883
48792
|
const effective = response.data.level;
|
|
46884
|
-
|
|
48793
|
+
if (requested && requested !== effective) addEvent(`Thinking level set to ${effective}: the active model does not support ${requested}.`, "warn");
|
|
48794
|
+
else addEvent(`Thinking level set to ${effective}.`, "info");
|
|
46885
48795
|
}
|
|
46886
48796
|
await refreshState(tabContext);
|
|
46887
48797
|
}
|
|
@@ -47140,6 +49050,7 @@ elements.sidePanelBackdrop.addEventListener("click", () => {
|
|
|
47140
49050
|
setSidePanelCollapsed(true);
|
|
47141
49051
|
});
|
|
47142
49052
|
bindSidePanelContextMenu();
|
|
49053
|
+
initializeControlVisibility();
|
|
47143
49054
|
elements.stickyUserPromptButton?.addEventListener("click", jumpToStickyUserPrompt);
|
|
47144
49055
|
elements.jumpToLatestButton.addEventListener("click", jumpToLatest);
|
|
47145
49056
|
elements.chat.addEventListener("wheel", noteChatUserScrollIntent, { passive: true });
|
|
@@ -47231,6 +49142,13 @@ function shouldHandleNativeAppShortcut(event) {
|
|
|
47231
49142
|
return event.target === elements.promptInput || !isTextEntryTarget(event.target);
|
|
47232
49143
|
}
|
|
47233
49144
|
|
|
49145
|
+
// TUI-parity chords (Ctrl+P model cycle, Ctrl+T thinking output, Ctrl+O tool output, Ctrl+C
|
|
49146
|
+
// clear, Shift+Tab thinking level) only apply while the composer has focus. Elsewhere they must
|
|
49147
|
+
// keep their browser meaning (print, reverse Tab navigation, copy, …).
|
|
49148
|
+
function isComposerScopedShortcutTarget(event) {
|
|
49149
|
+
return event.target === elements.promptInput;
|
|
49150
|
+
}
|
|
49151
|
+
|
|
47234
49152
|
function handleNativeAppShortcut(event) {
|
|
47235
49153
|
if (!shouldHandleNativeAppShortcut(event)) return;
|
|
47236
49154
|
const key = event.key;
|
|
@@ -47247,6 +49165,17 @@ function handleNativeAppShortcut(event) {
|
|
|
47247
49165
|
openNativeModelSelector();
|
|
47248
49166
|
return;
|
|
47249
49167
|
}
|
|
49168
|
+
if (!ctrlOrMeta && !event.metaKey && event.altKey && key === "Enter") {
|
|
49169
|
+
event.preventDefault();
|
|
49170
|
+
if (hasComposerPayload()) sendPrompt("follow-up");
|
|
49171
|
+
return;
|
|
49172
|
+
}
|
|
49173
|
+
if (!ctrlOrMeta && event.altKey && key === "ArrowUp") {
|
|
49174
|
+
event.preventDefault();
|
|
49175
|
+
restoreQueuedMessagesToComposerFromShortcut();
|
|
49176
|
+
return;
|
|
49177
|
+
}
|
|
49178
|
+
if (!isComposerScopedShortcutTarget(event)) return;
|
|
47250
49179
|
if (ctrlOrMeta && !event.altKey && lowerKey === "p") {
|
|
47251
49180
|
event.preventDefault();
|
|
47252
49181
|
cycleModelFromShortcut(event.shiftKey ? "backward" : "forward");
|
|
@@ -47269,16 +49198,6 @@ function handleNativeAppShortcut(event) {
|
|
|
47269
49198
|
if (!event.ctrlKey && !event.metaKey && !event.altKey && event.shiftKey && key === "Tab") {
|
|
47270
49199
|
event.preventDefault();
|
|
47271
49200
|
cycleThinkingFromShortcut();
|
|
47272
|
-
return;
|
|
47273
|
-
}
|
|
47274
|
-
if (!event.ctrlKey && !event.metaKey && event.altKey && key === "Enter") {
|
|
47275
|
-
event.preventDefault();
|
|
47276
|
-
if (hasComposerPayload()) sendPrompt("follow-up");
|
|
47277
|
-
return;
|
|
47278
|
-
}
|
|
47279
|
-
if (!event.ctrlKey && !event.metaKey && event.altKey && key === "ArrowUp") {
|
|
47280
|
-
event.preventDefault();
|
|
47281
|
-
restoreQueuedMessagesToComposerFromShortcut();
|
|
47282
49201
|
}
|
|
47283
49202
|
}
|
|
47284
49203
|
|
|
@@ -47439,6 +49358,8 @@ elements.chatSearchNextButton?.addEventListener("click", () => stepChatSearch(1)
|
|
|
47439
49358
|
elements.chatSearchCloseButton?.addEventListener("click", closeChatSearch);
|
|
47440
49359
|
window.addEventListener("keydown", (event) => {
|
|
47441
49360
|
if ((event.ctrlKey || event.metaKey) && !event.altKey && !event.shiftKey && event.key.toLowerCase() === "f") {
|
|
49361
|
+
// Inside a modal dialog (settings, palette, pickers) leave the browser's own find alone.
|
|
49362
|
+
if (document.querySelector("dialog[open]")) return;
|
|
47442
49363
|
event.preventDefault();
|
|
47443
49364
|
if (activeFileViewer && elements.fileViewerPane?.contains(event.target)) openFileViewerSearch();
|
|
47444
49365
|
else openChatSearch();
|
|
@@ -47448,6 +49369,7 @@ window.addEventListener("keydown", (event) => {
|
|
|
47448
49369
|
window.addEventListener("keydown", handleNativeAppShortcut, { capture: true });
|
|
47449
49370
|
document.addEventListener("visibilitychange", () => {
|
|
47450
49371
|
if (document.visibilityState === "visible") {
|
|
49372
|
+
flushNormalStreamRenders("visibility-recovery");
|
|
47451
49373
|
scheduleForegroundReconcile("visibility resume", 0);
|
|
47452
49374
|
refreshSubagents().finally(() => scheduleRefreshSubagents());
|
|
47453
49375
|
} else {
|
|
@@ -47501,6 +49423,13 @@ window.addEventListener("storage", (event) => {
|
|
|
47501
49423
|
}
|
|
47502
49424
|
if (event.key === COMPOSER_ACTION_ORDER_STORAGE_KEY) restoreComposerActionOrder();
|
|
47503
49425
|
if (event.key === COMPOSER_ACTION_LAYOUT_STORAGE_KEY) restoreComposerActionSlotLayout();
|
|
49426
|
+
if (event.key === CONTROL_VISIBILITY_HIDDEN_IDS_STORAGE_KEY) {
|
|
49427
|
+
// A pending local mutation stays visually authoritative for this tab;
|
|
49428
|
+
// adopting another tab's cache value here would revert the dirty change
|
|
49429
|
+
// that is still waiting for its acknowledged server write.
|
|
49430
|
+
const dirtyVisibility = durableLayoutDirtyFields.get("controlVisibility");
|
|
49431
|
+
applyControlVisibility(dirtyVisibility ? dirtyVisibility.value?.hiddenIds : undefined);
|
|
49432
|
+
}
|
|
47504
49433
|
if (event.key === SIDE_PANEL_WIDTH_STORAGE_KEY && !ignoreLegacySidePanelEvent("panelWidths", Boolean(sidePanelResizeState))) {
|
|
47505
49434
|
const width = readStoredSidePanelWidth();
|
|
47506
49435
|
if (width && !isSidePanelOverlayView()) applySidePanelWidth(width);
|
|
@@ -47542,18 +49471,26 @@ window.addEventListener("keydown", (event) => {
|
|
|
47542
49471
|
}
|
|
47543
49472
|
if (publishMenuOpen) {
|
|
47544
49473
|
setPublishMenuOpen(false);
|
|
49474
|
+
armComposerMenuDismissal(elements.publishButton?.parentElement);
|
|
49475
|
+
elements.publishButton?.focus({ preventScroll: true });
|
|
47545
49476
|
return;
|
|
47546
49477
|
}
|
|
47547
49478
|
if (nativeCommandMenuOpen) {
|
|
47548
49479
|
setNativeCommandMenuOpen(false);
|
|
49480
|
+
armComposerMenuDismissal(elements.nativeCommandMenuButton?.parentElement);
|
|
49481
|
+
elements.nativeCommandMenuButton?.focus({ preventScroll: true });
|
|
47549
49482
|
return;
|
|
47550
49483
|
}
|
|
47551
49484
|
if (appRunnerMenuOpen) {
|
|
47552
49485
|
setAppRunnerMenuOpen(false);
|
|
49486
|
+
armComposerMenuDismissal(elements.appRunnerMenuButton?.parentElement);
|
|
49487
|
+
elements.appRunnerMenuButton?.focus({ preventScroll: true });
|
|
47553
49488
|
return;
|
|
47554
49489
|
}
|
|
47555
49490
|
if (optionsMenuOpen) {
|
|
47556
49491
|
setOptionsMenuOpen(false);
|
|
49492
|
+
armComposerMenuDismissal(elements.optionsMenuButton?.parentElement);
|
|
49493
|
+
elements.optionsMenuButton?.focus({ preventScroll: true });
|
|
47557
49494
|
return;
|
|
47558
49495
|
}
|
|
47559
49496
|
if (conversationVoiceMenuOpen) {
|
|
@@ -47665,7 +49602,7 @@ elements.refreshCodexUsageButton?.addEventListener("click", () => {
|
|
|
47665
49602
|
refreshCodexUsage({ forceAuthRefresh: true }).finally(() => scheduleRefreshCodexUsage());
|
|
47666
49603
|
});
|
|
47667
49604
|
elements.refreshClaudeUsageButton?.addEventListener("click", () => {
|
|
47668
|
-
refreshClaudeUsage().finally(() => scheduleRefreshClaudeUsage());
|
|
49605
|
+
refreshClaudeUsage({ forceCli: true }).finally(() => scheduleRefreshClaudeUsage());
|
|
47669
49606
|
});
|
|
47670
49607
|
elements.fileTreeRefreshButton?.addEventListener("click", () => refreshFileTreeRoot().catch((error) => addEvent(error.message || String(error), "error")));
|
|
47671
49608
|
elements.fileTreeRoot?.addEventListener("keydown", handleFileTreeKeydown);
|
|
@@ -47728,6 +49665,55 @@ elements.sidePanelContextMenu?.addEventListener("keydown", (event) => {
|
|
|
47728
49665
|
items[event.key === "Home" ? 0 : items.length - 1]?.focus({ preventScroll: true });
|
|
47729
49666
|
}
|
|
47730
49667
|
});
|
|
49668
|
+
function visibilityContextMenuItems() {
|
|
49669
|
+
return [...elements.visibilityContextMenu.querySelectorAll('[role="menuitem"], [role="menuitemcheckbox"]')];
|
|
49670
|
+
}
|
|
49671
|
+
elements.visibilityContextMenu?.addEventListener("keydown", (event) => {
|
|
49672
|
+
const items = visibilityContextMenuItems();
|
|
49673
|
+
const index = items.indexOf(document.activeElement);
|
|
49674
|
+
if (event.key === "Escape") {
|
|
49675
|
+
event.preventDefault();
|
|
49676
|
+
closeVisibilityContextMenu();
|
|
49677
|
+
} else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
49678
|
+
event.preventDefault();
|
|
49679
|
+
const direction = event.key === "ArrowDown" ? 1 : -1;
|
|
49680
|
+
items[(Math.max(0, index) + direction + items.length) % items.length]?.focus({ preventScroll: true });
|
|
49681
|
+
} else if (event.key === "Home" || event.key === "End") {
|
|
49682
|
+
event.preventDefault();
|
|
49683
|
+
items[event.key === "Home" ? 0 : items.length - 1]?.focus({ preventScroll: true });
|
|
49684
|
+
}
|
|
49685
|
+
});
|
|
49686
|
+
elements.visibilityContextMenu?.addEventListener("click", (event) => {
|
|
49687
|
+
const button = event.target?.closest?.("[data-visibility-menu-toggle], [data-visibility-menu-action]");
|
|
49688
|
+
if (!button) return;
|
|
49689
|
+
const toggleId = button.dataset.visibilityMenuToggle;
|
|
49690
|
+
if (toggleId) {
|
|
49691
|
+
const hiddenSet = new Set(userControlHiddenIds());
|
|
49692
|
+
setControlVisibilityHidden(toggleId, !hiddenSet.has(toggleId));
|
|
49693
|
+
button.setAttribute("aria-checked", hiddenSet.has(toggleId) ? "true" : "false");
|
|
49694
|
+
return;
|
|
49695
|
+
}
|
|
49696
|
+
const action = button.dataset.visibilityMenuAction;
|
|
49697
|
+
if (action === "hide") {
|
|
49698
|
+
const entryId = visibilityContextMenuState?.entryId;
|
|
49699
|
+
closeVisibilityContextMenu();
|
|
49700
|
+
if (entryId) {
|
|
49701
|
+
const label = CONTROL_VISIBILITY_REGISTRY.get(entryId)?.label || "control";
|
|
49702
|
+
setControlVisibilityHidden(entryId, true);
|
|
49703
|
+
offerUndo({
|
|
49704
|
+
message: `Hid ${label}. Right-click a toolbar area (or use the command palette) to show hidden controls again.`,
|
|
49705
|
+
undo: () => setControlVisibilityHidden(entryId, false),
|
|
49706
|
+
successMessage: `${label} is visible again.`,
|
|
49707
|
+
});
|
|
49708
|
+
}
|
|
49709
|
+
} else if (action === "show-all") {
|
|
49710
|
+
closeVisibilityContextMenu();
|
|
49711
|
+
showAllControls();
|
|
49712
|
+
} else if (action === "reset-defaults") {
|
|
49713
|
+
closeVisibilityContextMenu();
|
|
49714
|
+
resetControlVisibilityDefaults();
|
|
49715
|
+
}
|
|
49716
|
+
});
|
|
47731
49717
|
elements.gitFooterContextMenu?.addEventListener("keydown", (event) => {
|
|
47732
49718
|
const items = [...elements.gitFooterContextMenu.querySelectorAll('[role="menuitem"]:not([disabled])')];
|
|
47733
49719
|
const index = items.indexOf(document.activeElement);
|
|
@@ -47752,6 +49738,7 @@ elements.gitFooterContextMenu?.addEventListener("click", (event) => {
|
|
|
47752
49738
|
if (action === "disable") void disableGitFooterContextChip(state.key, state.label);
|
|
47753
49739
|
else if (action === "visibility") openGitFooterVisibilityDialog();
|
|
47754
49740
|
});
|
|
49741
|
+
elements.fileTreeNewFileButton?.addEventListener("click", () => createFileTreeEntry(null, "file").catch((error) => addEvent(error.message || String(error), "error")));
|
|
47755
49742
|
elements.fileContextMenu?.addEventListener("click", (event) => {
|
|
47756
49743
|
const button = event.target?.closest?.("[data-file-menu-action]");
|
|
47757
49744
|
if (!button) return;
|
|
@@ -47762,6 +49749,8 @@ elements.fileContextMenu?.addEventListener("click", (event) => {
|
|
|
47762
49749
|
if (action === "open-default") openPathInDefaultEditor(entry.path).catch((error) => addEvent(error.message || String(error), "error"));
|
|
47763
49750
|
else if (action === "open-webui") openFileTreeEntryInWebui(entry).catch((error) => addEvent(error.message || String(error), "error"));
|
|
47764
49751
|
else if (action === "move") moveFileTreeEntry(entry).catch((error) => addEvent(error.message || String(error), "error"));
|
|
49752
|
+
else if (action === "new-file") createFileTreeEntry(entry, "file").catch((error) => addEvent(error.message || String(error), "error"));
|
|
49753
|
+
else if (action === "new-folder") createFileTreeEntry(entry, "directory").catch((error) => addEvent(error.message || String(error), "error"));
|
|
47765
49754
|
else if (action === "delete") deleteFileTreeEntry(entry).catch((error) => addEvent(error.message || String(error), "error"));
|
|
47766
49755
|
});
|
|
47767
49756
|
elements.fileViewerOpenDefaultButton?.addEventListener("click", () => openPathInDefaultEditor(currentFileViewerPath()));
|
|
@@ -47774,7 +49763,20 @@ elements.terminalTabsResizeHandle?.addEventListener("keydown", handleTerminalTab
|
|
|
47774
49763
|
elements.fileViewerResizeHandle?.addEventListener("pointerdown", beginFileViewerResize);
|
|
47775
49764
|
elements.fileViewerResizeHandle?.addEventListener("keydown", handleFileViewerResizeKeydown);
|
|
47776
49765
|
elements.fileViewerSaveButton?.addEventListener("click", () => saveActiveFileViewer());
|
|
47777
|
-
elements.fileViewerCloseButton?.addEventListener("click",
|
|
49766
|
+
elements.fileViewerCloseButton?.addEventListener("click", async () => {
|
|
49767
|
+
if (activeFileViewer?.dirty && !(await confirmDiscardEdits({ what: "unsaved file edits", target: activeFileViewer.path }))) return;
|
|
49768
|
+
closeFileViewer();
|
|
49769
|
+
});
|
|
49770
|
+
// Reload/close with unsaved file edits or a non-empty composer asks first (browser-native prompt).
|
|
49771
|
+
window.addEventListener("pagehide", () => persistDesktopDrafts());
|
|
49772
|
+
window.addEventListener("beforeunload", (event) => {
|
|
49773
|
+
persistDesktopDrafts();
|
|
49774
|
+
// Text drafts are persisted above; only unsaved file edits and file attachments would be lost.
|
|
49775
|
+
const attachmentsPending = activeTabId ? attachmentsForTab(activeTabId).some((attachment) => attachment?.file) : false;
|
|
49776
|
+
if (!activeFileViewer?.dirty && !attachmentsPending) return;
|
|
49777
|
+
event.preventDefault();
|
|
49778
|
+
event.returnValue = "";
|
|
49779
|
+
});
|
|
47778
49780
|
elements.fileViewerChangesModeButton?.addEventListener("click", () => setFileViewerMode("changes"));
|
|
47779
49781
|
elements.fileViewerSourceModeButton?.addEventListener("click", () => setFileViewerMode("source"));
|
|
47780
49782
|
elements.fileViewerPreviewModeButton?.addEventListener("click", () => setFileViewerMode("preview"));
|
|
@@ -47874,9 +49876,60 @@ elements.promptInput.addEventListener("paste", handleAttachmentPaste);
|
|
|
47874
49876
|
elements.composer.addEventListener("dragover", handleComposerDragOver);
|
|
47875
49877
|
elements.composer.addEventListener("dragleave", handleComposerDragLeave);
|
|
47876
49878
|
elements.composer.addEventListener("drop", handleComposerDrop);
|
|
49879
|
+
// A file dropped anywhere else (transcript, panels, empty chrome) must never navigate the tab
|
|
49880
|
+
// away from the app; treat the whole window as an attachment drop zone unless a more specific
|
|
49881
|
+
// target (composer, file tree) already handled it.
|
|
49882
|
+
window.addEventListener("dragover", (event) => {
|
|
49883
|
+
if (event.defaultPrevented || !isFileDrag(event)) return;
|
|
49884
|
+
event.preventDefault();
|
|
49885
|
+
if (event.dataTransfer) event.dataTransfer.dropEffect = "copy";
|
|
49886
|
+
});
|
|
49887
|
+
window.addEventListener("drop", (event) => {
|
|
49888
|
+
if (event.defaultPrevented || !isFileDrag(event)) return;
|
|
49889
|
+
event.preventDefault();
|
|
49890
|
+
elements.composer.classList.remove("drag-over");
|
|
49891
|
+
addAttachmentFiles(event.dataTransfer?.files, "drop");
|
|
49892
|
+
});
|
|
49893
|
+
|
|
49894
|
+
// Enter accepts the highlighted suggestion (like Tab) unless the token already equals it,
|
|
49895
|
+
// in which case Enter falls through to send. Ctrl/Cmd+Enter always sends.
|
|
49896
|
+
function highlightedSuggestionAlreadyTyped() {
|
|
49897
|
+
const index = commandSuggestIndex;
|
|
49898
|
+
if (suggestionMode === "path") {
|
|
49899
|
+
const suggestion = pathSuggestions[index];
|
|
49900
|
+
const trigger = getPathTrigger();
|
|
49901
|
+
if (!suggestion || !trigger) return true;
|
|
49902
|
+
const typed = String(trigger.query || "").replace(/\\/g, "/");
|
|
49903
|
+
const target = String(suggestion.path || "").replace(/\\/g, "/");
|
|
49904
|
+
return typed === target || typed === target.replace(/\/$/, "");
|
|
49905
|
+
}
|
|
49906
|
+
if (suggestionMode === "bang") {
|
|
49907
|
+
const suggestion = bangSuggestions[index];
|
|
49908
|
+
const trigger = getBangTrigger();
|
|
49909
|
+
if (!suggestion || !trigger) return true;
|
|
49910
|
+
const typed = `${trigger.bangPrefix || ""}${trigger.query || ""}`;
|
|
49911
|
+
return typed === String(suggestion.insertText || "");
|
|
49912
|
+
}
|
|
49913
|
+
const command = commandSuggestions[index];
|
|
49914
|
+
const trigger = getCommandTrigger();
|
|
49915
|
+
if (!command || !trigger) return true;
|
|
49916
|
+
const typed = String(trigger.query || "").toLowerCase();
|
|
49917
|
+
return typed === String(command.name || "").toLowerCase() || typed === String(command.invokeName || "").toLowerCase();
|
|
49918
|
+
}
|
|
49919
|
+
|
|
49920
|
+
function shouldAcceptSuggestionFromEnter(event) {
|
|
49921
|
+
if (event.key !== "Enter" || event.shiftKey || event.ctrlKey || event.metaKey || event.altKey || event.isComposing) return false;
|
|
49922
|
+
if (elements.commandSuggest.hidden || activeSuggestionCount() === 0) return false;
|
|
49923
|
+
return !highlightedSuggestionAlreadyTyped();
|
|
49924
|
+
}
|
|
47877
49925
|
|
|
47878
49926
|
elements.promptInput.addEventListener("keydown", (event) => {
|
|
47879
49927
|
if (event.defaultPrevented || insertNumpadDecimal(event)) return;
|
|
49928
|
+
if (shouldAcceptSuggestionFromEnter(event)) {
|
|
49929
|
+
event.preventDefault();
|
|
49930
|
+
insertCommandSuggestion();
|
|
49931
|
+
return;
|
|
49932
|
+
}
|
|
47880
49933
|
if (shouldSendPromptFromEnter(event)) {
|
|
47881
49934
|
event.preventDefault();
|
|
47882
49935
|
hideCommandSuggestions();
|
|
@@ -47885,12 +49938,12 @@ elements.promptInput.addEventListener("keydown", (event) => {
|
|
|
47885
49938
|
}
|
|
47886
49939
|
|
|
47887
49940
|
if (!elements.commandSuggest.hidden) {
|
|
47888
|
-
if (event.key === "ArrowDown") {
|
|
49941
|
+
if (event.key === "ArrowDown" && activeSuggestionCount() > 0) {
|
|
47889
49942
|
event.preventDefault();
|
|
47890
49943
|
setActiveCommandSuggestion(commandSuggestIndex + 1);
|
|
47891
49944
|
return;
|
|
47892
49945
|
}
|
|
47893
|
-
if (event.key === "ArrowUp") {
|
|
49946
|
+
if (event.key === "ArrowUp" && activeSuggestionCount() > 0) {
|
|
47894
49947
|
event.preventDefault();
|
|
47895
49948
|
setActiveCommandSuggestion(commandSuggestIndex - 1);
|
|
47896
49949
|
return;
|
|
@@ -47917,7 +49970,8 @@ elements.promptInput.addEventListener("keydown", (event) => {
|
|
|
47917
49970
|
|
|
47918
49971
|
elements.promptInput.addEventListener("input", () => {
|
|
47919
49972
|
resetPromptHistoryNavigation();
|
|
47920
|
-
|
|
49973
|
+
// Typed text always stays editable in the composer; only large pastes become attachments
|
|
49974
|
+
// (handleAttachmentPaste). Ripping a prompt out mid-typing was surprising and lossy.
|
|
47921
49975
|
resizePromptInput();
|
|
47922
49976
|
renderCommandSuggestions();
|
|
47923
49977
|
scheduleMobileContinuityPersist();
|