openclacky 1.5.21 → 1.5.23
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +119 -0
- data/docs/secretary-prototype.md +286 -0
- data/lib/clacky/agent/session_serializer.rb +15 -11
- data/lib/clacky/agent.rb +58 -15
- data/lib/clacky/agent_config.rb +3 -1
- data/lib/clacky/agent_profile.rb +33 -6
- data/lib/clacky/billing/platform_billing.rb +9 -0
- data/lib/clacky/default_extensions/advisor/README.md +25 -0
- data/lib/clacky/default_extensions/advisor/README.zh.md +25 -0
- data/lib/clacky/default_extensions/advisor/ext.yml +1 -1
- data/lib/clacky/default_extensions/advisor/icon.svg +14 -0
- data/lib/clacky/default_extensions/coding/ext.yml +0 -1
- data/lib/clacky/default_extensions/computer-use/README.md +48 -0
- data/lib/clacky/default_extensions/computer-use/README.zh.md +48 -0
- data/lib/clacky/default_extensions/computer-use/ext.yml +1 -1
- data/lib/clacky/default_extensions/computer-use/icon.svg +16 -0
- data/lib/clacky/default_extensions/ext-studio/ext.yml +0 -1
- data/lib/clacky/default_extensions/general/ext.yml +0 -1
- data/lib/clacky/default_extensions/git/README.md +41 -0
- data/lib/clacky/default_extensions/git/README.zh.md +41 -0
- data/lib/clacky/default_extensions/git/ext.yml +1 -1
- data/lib/clacky/default_extensions/git/icon.svg +15 -0
- data/lib/clacky/default_extensions/git/panels/git/view.js +1960 -399
- data/lib/clacky/default_extensions/meeting/README.md +46 -0
- data/lib/clacky/default_extensions/meeting/README.zh.md +47 -0
- data/lib/clacky/default_extensions/meeting/ext.yml +1 -1
- data/lib/clacky/default_extensions/meeting/icon.svg +13 -0
- data/lib/clacky/default_extensions/preview/README.md +29 -0
- data/lib/clacky/default_extensions/preview/README.zh.md +29 -0
- data/lib/clacky/default_extensions/preview/ext.yml +1 -1
- data/lib/clacky/default_extensions/preview/icon.svg +13 -0
- data/lib/clacky/default_extensions/preview/panels/preview/view.js +199 -34
- data/lib/clacky/default_extensions/secretary/agents/secretary.md +41 -0
- data/lib/clacky/default_extensions/secretary/agents/worker.md +35 -0
- data/lib/clacky/default_extensions/secretary/api/handler.rb +8 -0
- data/lib/clacky/default_extensions/secretary/ext.yml +39 -0
- data/lib/clacky/default_extensions/secretary/panels/work/view.js +344 -0
- data/lib/clacky/default_extensions/secretary/tools/delegate_work.rb +37 -0
- data/lib/clacky/default_extensions/secretary/tools/manage_work.rb +22 -0
- data/lib/clacky/default_extensions/secretary/tools/yield_work.rb +35 -0
- data/lib/clacky/default_extensions/time_machine/README.md +32 -0
- data/lib/clacky/default_extensions/time_machine/README.zh.md +32 -0
- data/lib/clacky/default_extensions/time_machine/ext.yml +1 -1
- data/lib/clacky/default_extensions/time_machine/icon.svg +14 -0
- data/lib/clacky/default_skills/channel-manager/SKILL.md +79 -8
- data/lib/clacky/default_skills/channel-manager/discord_setup.rb +5 -1
- data/lib/clacky/default_skills/channel-manager/weixin_setup.rb +8 -1
- data/lib/clacky/default_skills/cron-task-creator/SKILL.md +183 -206
- data/lib/clacky/default_skills/cron-task-creator/evals/evals.json +45 -0
- data/lib/clacky/default_skills/media-gen/SKILL.md +17 -8
- data/lib/clacky/extension/api_extension.rb +10 -2
- data/lib/clacky/extension/loader.rb +2 -0
- data/lib/clacky/extension/verifier.rb +2 -2
- data/lib/clacky/locales/en.rb +14 -0
- data/lib/clacky/locales/zh.rb +14 -0
- data/lib/clacky/prompts/base.md +1 -1
- data/lib/clacky/providers.rb +68 -31
- data/lib/clacky/search_config.rb +33 -11
- data/lib/clacky/server/channel/adapters/base.rb +18 -0
- data/lib/clacky/server/channel/adapters/feishu/message_parser.rb +1 -0
- data/lib/clacky/server/channel/adapters/telegram/adapter.rb +1 -0
- data/lib/clacky/server/channel/channel_config.rb +185 -48
- data/lib/clacky/server/channel/channel_manager.rb +179 -66
- data/lib/clacky/server/git_panel.rb +362 -35
- data/lib/clacky/server/http_server.rb +530 -181
- data/lib/clacky/server/preview.rb +118 -17
- data/lib/clacky/server/scheduler.rb +211 -51
- data/lib/clacky/server/web_ui_controller.rb +35 -27
- data/lib/clacky/session_manager.rb +56 -6
- data/lib/clacky/tools/base.rb +7 -1
- data/lib/clacky/utils/file_processor.rb +20 -10
- data/lib/clacky/utils/mac_app_detector.rb +8 -7
- data/lib/clacky/utils/model_pricing.rb +60 -2
- data/lib/clacky/utils/windows_app_detector.rb +3 -1
- data/lib/clacky/version.rb +1 -1
- data/lib/clacky/web/app.css +1114 -205
- data/lib/clacky/web/app.js +143 -8
- data/lib/clacky/web/auth.js +1 -1
- data/lib/clacky/web/components/code-editor.js +73 -4
- data/lib/clacky/web/components/composer.js +107 -8
- data/lib/clacky/web/components/image-zoom.js +165 -0
- data/lib/clacky/web/components/model-picker.js +7 -5
- data/lib/clacky/web/components/notify.js +39 -12
- data/lib/clacky/web/components/onboard.js +1 -1
- data/lib/clacky/web/core/aside.js +60 -3
- data/lib/clacky/web/features/billing/view.js +2 -2
- data/lib/clacky/web/features/channels/store.js +19 -4
- data/lib/clacky/web/features/channels/view.js +92 -28
- data/lib/clacky/web/features/extensions/view.js +17 -10
- data/lib/clacky/web/features/new-session/store.js +79 -2
- data/lib/clacky/web/features/new-session/view.js +516 -75
- data/lib/clacky/web/features/skills/store.js +1 -1
- data/lib/clacky/web/features/tasks/store.js +5 -3
- data/lib/clacky/web/features/tasks/view.js +249 -66
- data/lib/clacky/web/features/workspace/store.js +13 -6
- data/lib/clacky/web/features/workspace/view.js +340 -214
- data/lib/clacky/web/i18n.js +366 -68
- data/lib/clacky/web/index.html +196 -165
- data/lib/clacky/web/projects.js +37 -4
- data/lib/clacky/web/sessions.js +263 -146
- data/lib/clacky/web/settings.js +241 -53
- data/lib/clacky/web/skills.js +2 -2
- data/lib/clacky/web/theme.js +17 -2
- data/lib/clacky/web/utils.js +234 -2
- data/lib/clacky/web/weixin-qr.html +2 -1
- data/lib/clacky/web/ws-dispatcher.js +14 -31
- data/lib/clacky/work/service.rb +542 -0
- data/lib/clacky/work/store.rb +57 -0
- metadata +31 -1
data/lib/clacky/web/sessions.js
CHANGED
|
@@ -19,7 +19,8 @@ const Sessions = (() => {
|
|
|
19
19
|
const _sessions = []; // [{ id, name, status, total_tasks, total_cost }]
|
|
20
20
|
const _historyState = {}; // Per-session history window, cursors and in-flight request.
|
|
21
21
|
const _renderedCreatedAt = {}; // { [session_id]: Set<number> } — dedup by created_at
|
|
22
|
-
const
|
|
22
|
+
const _DRAFT_PREFIX = "clacky-composer-draft:";
|
|
23
|
+
const _drafts = new Map(); // { [session_id]: composer text }, mirrored to per-session localStorage keys
|
|
23
24
|
const _attachmentDrafts = new Map(); // { [session_id]: { images: [...], files: [...] } }
|
|
24
25
|
const _quoteDrafts = new Map(); // { [session_id]: staged quote cards (quote-select.js) }
|
|
25
26
|
let _activeId = null;
|
|
@@ -45,8 +46,10 @@ const Sessions = (() => {
|
|
|
45
46
|
// Sessions that finished while the user was looking elsewhere. Holds a
|
|
46
47
|
// transient "done" dot until the session is opened or DONE_DOT_TTL elapses,
|
|
47
48
|
// so a completed background task is noticeable without a permanent marker.
|
|
48
|
-
const _recentlyDone = new Map(); // { [session_id]:
|
|
49
|
+
const _recentlyDone = new Map(); // { [session_id]: { timer, summary } }
|
|
49
50
|
const DONE_DOT_TTL = 5 * 60 * 1000;
|
|
51
|
+
// Summary taken from _recentlyDone on open, appended once that history loads.
|
|
52
|
+
let _unseenSummary = null; // { id, ev } | null
|
|
50
53
|
// Active search result split when _filter.q is non-empty:
|
|
51
54
|
// { nameIds: Set<id>, contentIds: Set<id>, contentLoaded: bool }
|
|
52
55
|
let _searchSplit = null;
|
|
@@ -109,7 +112,7 @@ const Sessions = (() => {
|
|
|
109
112
|
let _pendingStdoutLines = null; // string[] | null
|
|
110
113
|
|
|
111
114
|
// ── Chat section collapse ──────────────────────────────────────────────────
|
|
112
|
-
const _CHAT_COLLAPSE_KEY = "
|
|
115
|
+
const _CHAT_COLLAPSE_KEY = "clacky-chat-section-collapsed";
|
|
113
116
|
let _chatCollapsed = localStorage.getItem(_CHAT_COLLAPSE_KEY) === "1";
|
|
114
117
|
|
|
115
118
|
// ── Markdown renderer ──────────────────────────────────────────────────
|
|
@@ -657,7 +660,8 @@ const Sessions = (() => {
|
|
|
657
660
|
//
|
|
658
661
|
// Scope: everything here is strictly session-scoped. The pending buffers
|
|
659
662
|
// are cleared on each send and saved/restored across session switches via
|
|
660
|
-
// _attachmentDrafts (mirroring the _drafts Map for text
|
|
663
|
+
// _attachmentDrafts (mirroring the _drafts Map for text, which alone also
|
|
664
|
+
// survives a reload).
|
|
661
665
|
//
|
|
662
666
|
// Bindings set up by _initComposer() — wired in Sessions.init() below.
|
|
663
667
|
|
|
@@ -675,89 +679,30 @@ const Sessions = (() => {
|
|
|
675
679
|
return ACCEPTED_IMAGE_TYPES.includes(file.type);
|
|
676
680
|
}
|
|
677
681
|
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
const DOC_ICON_PATHS = {
|
|
681
|
-
file: '<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/>',
|
|
682
|
-
doc: '<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M9 13h6"/><path d="M9 17h5"/>',
|
|
683
|
-
sheet: '<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M8 13h3"/><path d="M13 13h3"/><path d="M8 17h3"/><path d="M13 17h3"/>',
|
|
684
|
-
slide: '<path d="M2 3h20"/><path d="M20 3v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V3"/><path d="m7 21 5-5 5 5"/>',
|
|
685
|
-
code: '<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="m10 13-2 2 2 2"/><path d="m14 17 2-2-2-2"/>',
|
|
686
|
-
image: '<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="M21 15l-5-5L5 21"/>',
|
|
687
|
-
archive: '<rect x="2" y="3" width="20" height="5" rx="1"/><path d="M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"/><path d="M10 12h4"/>',
|
|
688
|
-
video: '<circle cx="12" cy="12" r="9"/><path d="m10 8.5 5.5 3.5L10 15.5z"/>',
|
|
689
|
-
audio: '<path d="M9 18V5l11-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="17" cy="16" r="3"/>',
|
|
690
|
-
};
|
|
691
|
-
|
|
692
|
-
function _docTypeIcon(mimeType, filename, size) {
|
|
693
|
-
const lower = (filename || "").toLowerCase();
|
|
694
|
-
const mime = mimeType || "";
|
|
695
|
-
const px = size || 20;
|
|
696
|
-
let key = "file";
|
|
697
|
-
if (mime.startsWith("image/") ||
|
|
698
|
-
lower.endsWith(".png") || lower.endsWith(".jpg") || lower.endsWith(".jpeg") ||
|
|
699
|
-
lower.endsWith(".gif") || lower.endsWith(".webp") || lower.endsWith(".bmp") ||
|
|
700
|
-
lower.endsWith(".svg") || lower.endsWith(".ico") || lower.endsWith(".avif") ||
|
|
701
|
-
lower.endsWith(".heic") || lower.endsWith(".tif") || lower.endsWith(".tiff")) key = "image";
|
|
702
|
-
else if (mime === "application/zip" || mime === "application/x-zip-compressed" ||
|
|
703
|
-
mime === "application/gzip" || mime === "application/x-gzip" ||
|
|
704
|
-
mime === "application/x-tar" || mime === "application/x-compressed-tar" ||
|
|
705
|
-
mime.includes("7z") || mime.includes("rar") ||
|
|
706
|
-
lower.endsWith(".zip") || lower.endsWith(".tar") || lower.endsWith(".gz") ||
|
|
707
|
-
lower.endsWith(".tgz") || lower.endsWith(".tar.gz") || lower.endsWith(".rar") ||
|
|
708
|
-
lower.endsWith(".7z")) key = "archive";
|
|
709
|
-
else if (mime.includes("spreadsheetml") || mime === "application/vnd.ms-excel" ||
|
|
710
|
-
mime === "text/csv" || mime === "application/csv" ||
|
|
711
|
-
lower.endsWith(".xls") || lower.endsWith(".xlsx") || lower.endsWith(".et") ||
|
|
712
|
-
lower.endsWith(".ods") || lower.endsWith(".csv")) key = "sheet";
|
|
713
|
-
else if (mime.includes("presentationml") || mime === "application/vnd.ms-powerpoint" ||
|
|
714
|
-
lower.endsWith(".ppt") || lower.endsWith(".pptx") || lower.endsWith(".dps") ||
|
|
715
|
-
lower.endsWith(".odp") || lower.endsWith(".key")) key = "slide";
|
|
716
|
-
else if (mime === "application/pdf" || lower.endsWith(".pdf") ||
|
|
717
|
-
mime.includes("wordprocessingml") || mime === "application/msword" ||
|
|
718
|
-
mime === "text/markdown" || mime === "text/x-markdown" || mime === "text/plain" ||
|
|
719
|
-
lower.endsWith(".doc") || lower.endsWith(".docx") || lower.endsWith(".wps") ||
|
|
720
|
-
lower.endsWith(".odt") || lower.endsWith(".rtf") || lower.endsWith(".md") ||
|
|
721
|
-
lower.endsWith(".markdown") || lower.endsWith(".txt") || lower.endsWith(".log")) key = "doc";
|
|
722
|
-
else if (mime.startsWith("video/") ||
|
|
723
|
-
lower.endsWith(".mp4") || lower.endsWith(".webm") || lower.endsWith(".mov") ||
|
|
724
|
-
lower.endsWith(".mkv") || lower.endsWith(".avi") || lower.endsWith(".m4v")) key = "video";
|
|
725
|
-
else if (mime.startsWith("audio/") ||
|
|
726
|
-
lower.endsWith(".mp3") || lower.endsWith(".wav") || lower.endsWith(".m4a") ||
|
|
727
|
-
lower.endsWith(".ogg") || lower.endsWith(".flac") || lower.endsWith(".aac")) key = "audio";
|
|
728
|
-
else if (lower.endsWith(".js") || lower.endsWith(".jsx") || lower.endsWith(".ts") ||
|
|
729
|
-
lower.endsWith(".tsx") || lower.endsWith(".py") || lower.endsWith(".rb") ||
|
|
730
|
-
lower.endsWith(".go") || lower.endsWith(".rs") || lower.endsWith(".java") ||
|
|
731
|
-
lower.endsWith(".c") || lower.endsWith(".h") || lower.endsWith(".cpp") ||
|
|
732
|
-
lower.endsWith(".hpp") || lower.endsWith(".cs") || lower.endsWith(".php") ||
|
|
733
|
-
lower.endsWith(".swift") || lower.endsWith(".kt") || lower.endsWith(".sh") ||
|
|
734
|
-
lower.endsWith(".bash") || lower.endsWith(".zsh") || lower.endsWith(".sql") ||
|
|
735
|
-
lower.endsWith(".json") || lower.endsWith(".yml") || lower.endsWith(".yaml") ||
|
|
736
|
-
lower.endsWith(".toml") || lower.endsWith(".xml") || lower.endsWith(".html") ||
|
|
737
|
-
lower.endsWith(".css") || lower.endsWith(".scss") || lower.endsWith(".vue") ||
|
|
738
|
-
lower.endsWith(".svelte") || lower.endsWith(".lua") || lower.endsWith(".pl") ||
|
|
739
|
-
lower.endsWith(".r") || lower.endsWith(".dart")) key = "code";
|
|
740
|
-
return `<svg xmlns="http://www.w3.org/2000/svg" width="${px}" height="${px}" viewBox="0 0 24 24" ` +
|
|
741
|
-
`fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" ` +
|
|
742
|
-
`stroke-linejoin="round" aria-hidden="true">${DOC_ICON_PATHS[key]}</svg>`;
|
|
682
|
+
function _fileIcon(name) {
|
|
683
|
+
return Clacky.WorkspaceView.fileIcon(name || "");
|
|
743
684
|
}
|
|
744
685
|
|
|
745
686
|
// Single source of truth for the file-attachment chip in a user bubble.
|
|
746
687
|
// Both the optimistic send path and the history/live replay paths render
|
|
747
688
|
// through here, so a badge never renders two different ways for one file.
|
|
748
|
-
function _attachmentBadge(name, mimeType) {
|
|
689
|
+
function _attachmentBadge(name, mimeType, filePath) {
|
|
749
690
|
const fname = name || "file";
|
|
750
691
|
const lower = fname.toLowerCase();
|
|
751
692
|
const ext = (fname.split(".").pop() || "file").toUpperCase();
|
|
752
693
|
// ".tar.gz" would otherwise show as just GZ
|
|
753
694
|
const displayExt = lower.endsWith(".tar.gz") ? "TAR.GZ" : ext;
|
|
754
|
-
|
|
755
|
-
|
|
695
|
+
const tag = filePath ? "button" : "span";
|
|
696
|
+
const attrs = filePath
|
|
697
|
+
? ` type="button" class="msg-pdf-badge msg-file-open" data-file-path="${encodeURIComponent(filePath)}"`
|
|
698
|
+
: ` class="msg-pdf-badge"`;
|
|
699
|
+
return `<${tag}${attrs}>` +
|
|
700
|
+
`<span class="msg-pdf-badge-icon">${_fileIcon(fname)}</span>` +
|
|
756
701
|
`<span class="msg-pdf-badge-info">` +
|
|
757
702
|
`<span class="msg-pdf-badge-name">${escapeHtml(fname)}</span>` +
|
|
758
703
|
`<span class="msg-pdf-badge-type">${escapeHtml(displayExt)}</span>` +
|
|
759
704
|
`</span>` +
|
|
760
|
-
|
|
705
|
+
`</${tag}>`;
|
|
761
706
|
}
|
|
762
707
|
|
|
763
708
|
// Compress an image File/Blob to a data URL within MAX_IMAGE_BYTES_SEND.
|
|
@@ -884,6 +829,28 @@ const Sessions = (() => {
|
|
|
884
829
|
return IMAGE_MIME_BY_EXT[ext] || "";
|
|
885
830
|
}
|
|
886
831
|
|
|
832
|
+
const IMAGE_FILE_EXTENSIONS = new Set([
|
|
833
|
+
"png", "jpg", "jpeg", "gif", "webp", "bmp", "svg", "ico", "avif", "heic", "tif", "tiff"
|
|
834
|
+
]);
|
|
835
|
+
|
|
836
|
+
function _isImageAttachment(file) {
|
|
837
|
+
const mime = String(file?.mime_type || file?.type || "").toLowerCase();
|
|
838
|
+
const ext = String(file?.name || "").split(".").pop().toLowerCase();
|
|
839
|
+
return mime.startsWith("image/") || IMAGE_FILE_EXTENSIONS.has(ext);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
function _attachmentImageUrl(filePath) {
|
|
843
|
+
if (!filePath) return "";
|
|
844
|
+
const path = window.Clacky?.Workspace?.absPath
|
|
845
|
+
? Clacky.Workspace.absPath(filePath)
|
|
846
|
+
: filePath;
|
|
847
|
+
return `/api/local-image?path=${encodeURIComponent(path)}`;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
function _openAttachment(filePath) {
|
|
851
|
+
return !!(filePath && window.Clacky?.WorkspaceView?.openFile(filePath));
|
|
852
|
+
}
|
|
853
|
+
|
|
887
854
|
// Stage a file the caller only knows by path — the Files tab hands over the
|
|
888
855
|
// entries listed by /api/sessions/:id/files. The path itself travels with the
|
|
889
856
|
// message (no /api/upload copy), so the agent parses the file where it lives.
|
|
@@ -904,6 +871,27 @@ const Sessions = (() => {
|
|
|
904
871
|
return true;
|
|
905
872
|
}
|
|
906
873
|
|
|
874
|
+
function _readDraft(id) {
|
|
875
|
+
if (!id) return "";
|
|
876
|
+
try {
|
|
877
|
+
const stored = localStorage.getItem(_DRAFT_PREFIX + id);
|
|
878
|
+
if (stored != null) return stored;
|
|
879
|
+
} catch (_e) {}
|
|
880
|
+
return _drafts.get(id) || "";
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
// Only trailing whitespace is dropped: restored quote chips re-add the space after each.
|
|
884
|
+
function _storeDraft(id, text) {
|
|
885
|
+
if (!id) return;
|
|
886
|
+
const value = (text || "").trimEnd();
|
|
887
|
+
if (value) _drafts.set(id, value);
|
|
888
|
+
else _drafts.delete(id);
|
|
889
|
+
try {
|
|
890
|
+
if (value) localStorage.setItem(_DRAFT_PREFIX + id, value);
|
|
891
|
+
else localStorage.removeItem(_DRAFT_PREFIX + id);
|
|
892
|
+
} catch (_e) {}
|
|
893
|
+
}
|
|
894
|
+
|
|
907
895
|
function _renderAttachmentPreviews() {
|
|
908
896
|
const strip = $("image-preview-strip");
|
|
909
897
|
strip.innerHTML = "";
|
|
@@ -926,7 +914,7 @@ const Sessions = (() => {
|
|
|
926
914
|
const removeBtn = document.createElement("button");
|
|
927
915
|
removeBtn.className = "img-preview-remove";
|
|
928
916
|
removeBtn.textContent = "✕";
|
|
929
|
-
removeBtn.title = "
|
|
917
|
+
removeBtn.title = I18n.t("tooltip.remove");
|
|
930
918
|
removeBtn.addEventListener("click", () => {
|
|
931
919
|
_pendingImages.splice(idx, 1);
|
|
932
920
|
_renderAttachmentPreviews();
|
|
@@ -936,15 +924,44 @@ const Sessions = (() => {
|
|
|
936
924
|
strip.appendChild(item);
|
|
937
925
|
});
|
|
938
926
|
|
|
939
|
-
// Render
|
|
927
|
+
// Render path-backed images as thumbnails, matching uploaded images while
|
|
928
|
+
// preserving their original attachment path in the outgoing payload.
|
|
940
929
|
_pendingFiles.forEach((f, idx) => {
|
|
930
|
+
if (_isImageAttachment(f)) {
|
|
931
|
+
const item = document.createElement("div");
|
|
932
|
+
item.className = "img-preview-item";
|
|
933
|
+
item.title = f.name;
|
|
934
|
+
const thumbnail = document.createElement("img");
|
|
935
|
+
thumbnail.className = "img-preview-thumb";
|
|
936
|
+
thumbnail.src = _attachmentImageUrl(f.path);
|
|
937
|
+
thumbnail.alt = f.name;
|
|
938
|
+
const removeBtn = document.createElement("button");
|
|
939
|
+
removeBtn.className = "img-preview-remove";
|
|
940
|
+
removeBtn.textContent = "✕";
|
|
941
|
+
removeBtn.title = I18n.t("tooltip.remove");
|
|
942
|
+
removeBtn.addEventListener("click", () => {
|
|
943
|
+
_pendingFiles.splice(idx, 1);
|
|
944
|
+
_renderAttachmentPreviews();
|
|
945
|
+
});
|
|
946
|
+
item.appendChild(thumbnail);
|
|
947
|
+
item.appendChild(removeBtn);
|
|
948
|
+
strip.appendChild(item);
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
// PDF, ZIP, DOC, XLS, PPT, etc. open through the existing Files viewer.
|
|
941
953
|
const item = document.createElement("div");
|
|
942
|
-
item.className = "pdf-preview-item";
|
|
954
|
+
item.className = "pdf-preview-item pdf-preview-item--clickable";
|
|
943
955
|
item.title = f.name;
|
|
944
956
|
|
|
957
|
+
const openBtn = document.createElement("button");
|
|
958
|
+
openBtn.type = "button";
|
|
959
|
+
openBtn.className = "pdf-preview-open";
|
|
960
|
+
openBtn.addEventListener("click", () => _openAttachment(f.path));
|
|
961
|
+
|
|
945
962
|
const icon = document.createElement("div");
|
|
946
963
|
icon.className = "pdf-preview-icon";
|
|
947
|
-
icon.innerHTML =
|
|
964
|
+
icon.innerHTML = _fileIcon(f.name);
|
|
948
965
|
|
|
949
966
|
const info = document.createElement("div");
|
|
950
967
|
info.className = "pdf-preview-info";
|
|
@@ -966,14 +983,15 @@ const Sessions = (() => {
|
|
|
966
983
|
const removeBtn = document.createElement("button");
|
|
967
984
|
removeBtn.className = "pdf-preview-remove";
|
|
968
985
|
removeBtn.textContent = "✕";
|
|
969
|
-
removeBtn.title = "
|
|
986
|
+
removeBtn.title = I18n.t("tooltip.remove");
|
|
970
987
|
removeBtn.addEventListener("click", () => {
|
|
971
988
|
_pendingFiles.splice(idx, 1);
|
|
972
989
|
_renderAttachmentPreviews();
|
|
973
990
|
});
|
|
974
991
|
|
|
975
|
-
|
|
976
|
-
|
|
992
|
+
openBtn.appendChild(icon);
|
|
993
|
+
openBtn.appendChild(info);
|
|
994
|
+
item.appendChild(openBtn);
|
|
977
995
|
item.appendChild(removeBtn);
|
|
978
996
|
strip.appendChild(item);
|
|
979
997
|
});
|
|
@@ -1049,6 +1067,7 @@ const Sessions = (() => {
|
|
|
1049
1067
|
}];
|
|
1050
1068
|
}
|
|
1051
1069
|
|
|
1070
|
+
// answered: i18n status key of a closed card, or falsy while it awaits input.
|
|
1052
1071
|
function _buildFeedbackCard(list, context, answered) {
|
|
1053
1072
|
// Multiple open questions are walked one at a time. A submitted card is a
|
|
1054
1073
|
// read-only record, so it stacks instead — hiding past questions there
|
|
@@ -1098,7 +1117,7 @@ const Sessions = (() => {
|
|
|
1098
1117
|
html += `</div>`;
|
|
1099
1118
|
});
|
|
1100
1119
|
|
|
1101
|
-
html += `<div class="feedback-actions"><span class="feedback-status">${escapeHtml(I18n.t(answered
|
|
1120
|
+
html += `<div class="feedback-actions"><span class="feedback-status">${escapeHtml(I18n.t(answered || "chat.feedback_waiting"))}</span>`;
|
|
1102
1121
|
if (stepped) {
|
|
1103
1122
|
html += `<button class="feedback-nav-btn feedback-back-btn" disabled>` +
|
|
1104
1123
|
`${escapeHtml(I18n.t("chat.feedback_back"))}</button>` +
|
|
@@ -1246,10 +1265,14 @@ const Sessions = (() => {
|
|
|
1246
1265
|
const path = chip.type === "session"
|
|
1247
1266
|
? MentionAC.icons.message
|
|
1248
1267
|
: (chip.type === "directory" ? MentionAC.icons.folder : MentionAC.icons.file);
|
|
1249
|
-
|
|
1268
|
+
const linked = chip.type === "session" && chip.session_id;
|
|
1269
|
+
const open = linked
|
|
1270
|
+
? `<a class="msg-mention-badge" href="#session/${encodeURIComponent(chip.session_id)}">`
|
|
1271
|
+
: `<span class="msg-mention-badge">`;
|
|
1272
|
+
return open +
|
|
1250
1273
|
`<span class="msg-mention-badge-icon">${MentionAC.svgHtml(path, 13)}</span>` +
|
|
1251
|
-
`<span class="msg-mention-badge-name">${escapeHtml(chip.name)}</span>` +
|
|
1252
|
-
`</span
|
|
1274
|
+
`<span class="msg-mention-badge-name">${escapeHtml(chip.name || chip.session_id || "")}</span>` +
|
|
1275
|
+
(linked ? `</a>` : `</span>`);
|
|
1253
1276
|
}
|
|
1254
1277
|
|
|
1255
1278
|
// Assemble the inner HTML of a user bubble from a history_user_message event.
|
|
@@ -1258,9 +1281,10 @@ const Sessions = (() => {
|
|
|
1258
1281
|
function _buildUserBubbleHtml(ev) {
|
|
1259
1282
|
let html = "";
|
|
1260
1283
|
const images = Array.isArray(ev.images) ? ev.images : [];
|
|
1284
|
+
const attachments = Array.isArray(ev.attachments) ? ev.attachments : [];
|
|
1261
1285
|
if (Array.isArray(ev.references) && ev.references.length > 0) {
|
|
1262
1286
|
html += ev.references.map(_renderMentionBadge).join(" ");
|
|
1263
|
-
if (ev.content || images.length > 0) html += "<br>";
|
|
1287
|
+
if (ev.content || images.length > 0 || attachments.length > 0) html += "<br>";
|
|
1264
1288
|
}
|
|
1265
1289
|
if (images.length > 0) {
|
|
1266
1290
|
html += images.map(src => {
|
|
@@ -1277,6 +1301,11 @@ const Sessions = (() => {
|
|
|
1277
1301
|
}
|
|
1278
1302
|
return `<img src="${escapeHtml(src)}" alt="image" class="msg-image-thumb">`;
|
|
1279
1303
|
}).join("");
|
|
1304
|
+
if (attachments.length > 0) html += " ";
|
|
1305
|
+
else if (ev.content) html += "<br>";
|
|
1306
|
+
}
|
|
1307
|
+
if (attachments.length > 0) {
|
|
1308
|
+
html += attachments.map(file => _attachmentBadge(file.name, file.type, file.path)).join(" ");
|
|
1280
1309
|
if (ev.content) html += "<br>";
|
|
1281
1310
|
}
|
|
1282
1311
|
return html + SkillAC.renderUserMessageHtml(ev.content || "", ev.skill_command, ev.skill_command_display);
|
|
@@ -1350,8 +1379,11 @@ const Sessions = (() => {
|
|
|
1350
1379
|
bubbleHtml = thumbs + (bubbleHtml ? "<br>" + bubbleHtml : "");
|
|
1351
1380
|
}
|
|
1352
1381
|
if (_pendingFiles.length > 0) {
|
|
1353
|
-
const
|
|
1354
|
-
|
|
1382
|
+
const attachments = _pendingFiles.map(f => _isImageAttachment(f)
|
|
1383
|
+
? `<img src="${_attachmentImageUrl(f.path)}" alt="${escapeHtml(f.name)}" class="msg-image-thumb">`
|
|
1384
|
+
: _attachmentBadge(f.name, f.mime_type, f.path)
|
|
1385
|
+
).join(" ");
|
|
1386
|
+
bubbleHtml = attachments + (bubbleHtml ? "<br>" + bubbleHtml : "");
|
|
1355
1387
|
}
|
|
1356
1388
|
Sessions.appendMsg("user", bubbleHtml, { time: new Date() });
|
|
1357
1389
|
|
|
@@ -1400,7 +1432,7 @@ const Sessions = (() => {
|
|
|
1400
1432
|
|
|
1401
1433
|
Composer.clear(input);
|
|
1402
1434
|
if (typeof QuoteSelect !== "undefined") QuoteSelect.clear();
|
|
1403
|
-
|
|
1435
|
+
_storeDraft(Sessions.activeId, "");
|
|
1404
1436
|
_attachmentDrafts.delete(Sessions.activeId);
|
|
1405
1437
|
_quoteDrafts.delete(Sessions.activeId);
|
|
1406
1438
|
setTimeout(() => { _sending = false; }, 300);
|
|
@@ -1423,11 +1455,18 @@ const Sessions = (() => {
|
|
|
1423
1455
|
},
|
|
1424
1456
|
});
|
|
1425
1457
|
}
|
|
1426
|
-
// contenteditable composer: chip deletion, plain-text paste, Shift+Enter
|
|
1427
|
-
|
|
1458
|
+
// contenteditable composer: chip deletion, plain-text paste, Shift+Enter,
|
|
1459
|
+
// and ArrowUp/Down recall of this session's sent messages.
|
|
1460
|
+
Composer.init($("user-input"), {
|
|
1461
|
+
getHistory: () => Array.from(
|
|
1462
|
+
RenderTarget.outer().querySelectorAll(".msg-user-wrap .msg-user"),
|
|
1463
|
+
el => _extractUserBubbleText(el)
|
|
1464
|
+
).filter(Boolean),
|
|
1465
|
+
});
|
|
1428
1466
|
setInterval(_renderFeedbackCountdown, 250);
|
|
1429
1467
|
document.addEventListener("input", (e) => {
|
|
1430
1468
|
if (e.target.closest?.("#user-input, .feedback-free-text")) _interveneFeedbackCountdown();
|
|
1469
|
+
if (e.target.id === "user-input") _storeDraft(_activeId, Composer.text(e.target));
|
|
1431
1470
|
});
|
|
1432
1471
|
document.addEventListener("click", (e) => {
|
|
1433
1472
|
if (e.target.closest?.(".feedback-option-btn, .feedback-nav-btn, .feedback-dot")) {
|
|
@@ -1529,11 +1568,14 @@ const Sessions = (() => {
|
|
|
1529
1568
|
e.target.value = "";
|
|
1530
1569
|
});
|
|
1531
1570
|
|
|
1532
|
-
// The
|
|
1571
|
+
// The chat column accepts session references and file attachments. The
|
|
1572
|
+
// session aside is deliberately excluded so workspace drops keep their
|
|
1573
|
+
// own behaviour.
|
|
1533
1574
|
Composer.bindDropZone({
|
|
1534
|
-
zone: document.getElementById("chat-
|
|
1575
|
+
zone: document.getElementById("chat-main"),
|
|
1535
1576
|
input: $("user-input"),
|
|
1536
1577
|
onFiles: files => files.forEach(_addAttachmentFile),
|
|
1578
|
+
onWorkspaceFile: attachWorkspaceFile,
|
|
1537
1579
|
});
|
|
1538
1580
|
|
|
1539
1581
|
document.getElementById("user-input").addEventListener("paste", (e) => {
|
|
@@ -1933,10 +1975,29 @@ const Sessions = (() => {
|
|
|
1933
1975
|
return card;
|
|
1934
1976
|
}
|
|
1935
1977
|
|
|
1936
|
-
|
|
1937
|
-
|
|
1978
|
+
function _fillMarkdownMessage(el, content) {
|
|
1979
|
+
el.dataset.raw = content || "";
|
|
1980
|
+
el.innerHTML = _renderMarkdown(content || "");
|
|
1981
|
+
_appendCopyButton(el);
|
|
1982
|
+
_enhanceTaskItems(el, content || "");
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
// Tools opt in through the existing structured UI result. Keep documents
|
|
1986
|
+
// outside collapsed execution groups in both live and replay paths.
|
|
1987
|
+
function _isPromotedToolResult(ui) {
|
|
1988
|
+
return ui && (ui.type === "web_search" || (ui.type === "markdown" && typeof ui.content === "string" && ui.content.trim()));
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
function _promoteToolResult(container, ui) {
|
|
1938
1992
|
if (!container || !ui) return;
|
|
1939
|
-
|
|
1993
|
+
if (ui.type === "web_search") {
|
|
1994
|
+
container.appendChild(_buildSearchCard(ui));
|
|
1995
|
+
} else if (ui.type === "markdown") {
|
|
1996
|
+
const doc = document.createElement("div");
|
|
1997
|
+
doc.className = "msg msg-assistant tool-result-document";
|
|
1998
|
+
_fillMarkdownMessage(doc, ui.content);
|
|
1999
|
+
container.appendChild(doc);
|
|
2000
|
+
}
|
|
1940
2001
|
}
|
|
1941
2002
|
|
|
1942
2003
|
// Produce a short one-line summary of tool arguments for the compact view.
|
|
@@ -2018,7 +2079,7 @@ const Sessions = (() => {
|
|
|
2018
2079
|
if (stdout) {
|
|
2019
2080
|
const existing = stdout.textContent.trim();
|
|
2020
2081
|
// Search results render as their own card, so the raw JSON stays out of stdout.
|
|
2021
|
-
const promoted = ui
|
|
2082
|
+
const promoted = _isPromotedToolResult(ui);
|
|
2022
2083
|
const resultStr = (result == null) ? "" : String(result).trim();
|
|
2023
2084
|
if (!existing && !promoted && resultStr) {
|
|
2024
2085
|
stdout.innerHTML = _ansiToHtml(resultStr);
|
|
@@ -2114,10 +2175,7 @@ const Sessions = (() => {
|
|
|
2114
2175
|
if (historyCtx.group) { _collapseToolGroup(historyCtx.group); historyCtx.group = null; historyCtx.lastItem = null; }
|
|
2115
2176
|
const el = document.createElement("div");
|
|
2116
2177
|
el.className = "msg msg-assistant";
|
|
2117
|
-
el
|
|
2118
|
-
el.innerHTML = _renderMarkdown(ev.content || "");
|
|
2119
|
-
_appendCopyButton(el);
|
|
2120
|
-
_enhanceTaskItems(el, ev.content || "");
|
|
2178
|
+
_fillMarkdownMessage(el, ev.content);
|
|
2121
2179
|
container.appendChild(el);
|
|
2122
2180
|
break;
|
|
2123
2181
|
}
|
|
@@ -2148,7 +2206,7 @@ const Sessions = (() => {
|
|
|
2148
2206
|
const stdout = item.querySelector(".tool-item-stdout");
|
|
2149
2207
|
if (stdout) {
|
|
2150
2208
|
const ui = ev.ui;
|
|
2151
|
-
const promoted = ui
|
|
2209
|
+
const promoted = _isPromotedToolResult(ui);
|
|
2152
2210
|
const resultStr = (ev.result == null) ? "" : String(ev.result).trim();
|
|
2153
2211
|
if (promoted) {
|
|
2154
2212
|
stdout.style.display = "none";
|
|
@@ -2160,11 +2218,11 @@ const Sessions = (() => {
|
|
|
2160
2218
|
stdout.style.display = "none";
|
|
2161
2219
|
}
|
|
2162
2220
|
}
|
|
2163
|
-
if (ev.ui
|
|
2221
|
+
if (_isPromotedToolResult(ev.ui)) {
|
|
2164
2222
|
_collapseToolGroup(historyCtx.group);
|
|
2165
2223
|
historyCtx.group = null;
|
|
2166
2224
|
historyCtx.lastItem = null;
|
|
2167
|
-
|
|
2225
|
+
_promoteToolResult(container, ev.ui);
|
|
2168
2226
|
}
|
|
2169
2227
|
}
|
|
2170
2228
|
break;
|
|
@@ -2235,7 +2293,7 @@ const Sessions = (() => {
|
|
|
2235
2293
|
const rfList = _normalizeFeedbackQuestions(ev.questions, ev.question, ev.options);
|
|
2236
2294
|
if (rfList.length === 0) break;
|
|
2237
2295
|
|
|
2238
|
-
container.appendChild(_buildFeedbackCard(rfList, rfContext, ev._answered
|
|
2296
|
+
container.appendChild(_buildFeedbackCard(rfList, rfContext, ev._answered || null));
|
|
2239
2297
|
break;
|
|
2240
2298
|
}
|
|
2241
2299
|
|
|
@@ -2330,19 +2388,20 @@ const Sessions = (() => {
|
|
|
2330
2388
|
const events = data.events || [];
|
|
2331
2389
|
let lastRoundError = null;
|
|
2332
2390
|
|
|
2333
|
-
// Pre-scan:
|
|
2334
|
-
// A
|
|
2335
|
-
//
|
|
2391
|
+
// Pre-scan: a feedback card stays open only while nothing follows it.
|
|
2392
|
+
// A user message means it was answered; any later agent activity means
|
|
2393
|
+
// the agent decided on its own (auto-approve timeout, interrupt, error).
|
|
2336
2394
|
{
|
|
2395
|
+
const agentActs = ["assistant_message", "tool_call", "request_feedback", "subagent_start", "error"];
|
|
2337
2396
|
let lastFeedbackIdx = -1;
|
|
2338
2397
|
events.forEach((ev, i) => {
|
|
2339
2398
|
if (ev.type === "history_user_message") lastRoundError = null;
|
|
2340
2399
|
if (ev.type === "error") lastRoundError = ev;
|
|
2341
|
-
if (ev.type === "
|
|
2342
|
-
|
|
2343
|
-
events[lastFeedbackIdx]._answered = true;
|
|
2400
|
+
if (lastFeedbackIdx >= 0 && (ev.type === "history_user_message" || agentActs.includes(ev.type))) {
|
|
2401
|
+
events[lastFeedbackIdx]._answered = ev.type === "history_user_message" ? "chat.feedback_answered" : "chat.feedback_timeout";
|
|
2344
2402
|
lastFeedbackIdx = -1;
|
|
2345
2403
|
}
|
|
2404
|
+
if (ev.type === "request_feedback") { ev._answered = data.has_after ? "chat.feedback_answered" : null; lastFeedbackIdx = i; }
|
|
2346
2405
|
});
|
|
2347
2406
|
}
|
|
2348
2407
|
|
|
@@ -2415,6 +2474,10 @@ const Sessions = (() => {
|
|
|
2415
2474
|
// Restore transient UI state based on session status after initial load
|
|
2416
2475
|
// (not prepend, which is scroll-up pagination — no need to re-restore then)
|
|
2417
2476
|
if (!prepend && !state.hasAfter) {
|
|
2477
|
+
if (_unseenSummary?.id === id) {
|
|
2478
|
+
Sessions.appendCompleteSummary(_unseenSummary.ev);
|
|
2479
|
+
_unseenSummary = null;
|
|
2480
|
+
}
|
|
2418
2481
|
const session = _sessions.find(s => s.id === id);
|
|
2419
2482
|
if (session) {
|
|
2420
2483
|
if (session.status === "running") {
|
|
@@ -3007,6 +3070,8 @@ const Sessions = (() => {
|
|
|
3007
3070
|
activeClass,
|
|
3008
3071
|
distanceProperty,
|
|
3009
3072
|
durationProperty,
|
|
3073
|
+
fadeClass = null,
|
|
3074
|
+
fadeDelay = 300,
|
|
3010
3075
|
revealPadding = 16,
|
|
3011
3076
|
measureDelay = 170,
|
|
3012
3077
|
}) {
|
|
@@ -3015,8 +3080,10 @@ const Sessions = (() => {
|
|
|
3015
3080
|
if (!viewport || !content) return;
|
|
3016
3081
|
|
|
3017
3082
|
let measureTimer = null;
|
|
3083
|
+
let fadeTimer = null;
|
|
3018
3084
|
item.addEventListener("pointerenter", () => {
|
|
3019
3085
|
clearTimeout(measureTimer);
|
|
3086
|
+
clearTimeout(fadeTimer);
|
|
3020
3087
|
measureTimer = setTimeout(() => {
|
|
3021
3088
|
const overflow = content.scrollWidth - viewport.clientWidth;
|
|
3022
3089
|
if (overflow <= 1) return;
|
|
@@ -3028,12 +3095,17 @@ const Sessions = (() => {
|
|
|
3028
3095
|
item.style.setProperty(distanceProperty, `${distance}px`);
|
|
3029
3096
|
item.style.setProperty(durationProperty, `${duration}s`);
|
|
3030
3097
|
item.classList.add(activeClass);
|
|
3098
|
+
// Mirrors the CSS transition delay: a leading fade that shows up first
|
|
3099
|
+
// would dim the opening glyphs before they start moving.
|
|
3100
|
+
if (fadeClass) fadeTimer = setTimeout(() => item.classList.add(fadeClass), fadeDelay);
|
|
3031
3101
|
}, measureDelay);
|
|
3032
3102
|
});
|
|
3033
3103
|
item.addEventListener("pointerleave", () => {
|
|
3034
3104
|
clearTimeout(measureTimer);
|
|
3105
|
+
clearTimeout(fadeTimer);
|
|
3035
3106
|
measureTimer = null;
|
|
3036
3107
|
item.classList.remove(activeClass);
|
|
3108
|
+
if (fadeClass) item.classList.remove(fadeClass);
|
|
3037
3109
|
item.style.removeProperty(distanceProperty);
|
|
3038
3110
|
item.style.removeProperty(durationProperty);
|
|
3039
3111
|
});
|
|
@@ -3047,6 +3119,7 @@ const Sessions = (() => {
|
|
|
3047
3119
|
viewportSelector: ".session-name__text",
|
|
3048
3120
|
contentSelector: ".session-name__content",
|
|
3049
3121
|
activeClass: "session-name-scrolling",
|
|
3122
|
+
fadeClass: "session-name-leading-fade",
|
|
3050
3123
|
distanceProperty: "--session-name-scroll-distance",
|
|
3051
3124
|
durationProperty: "--session-name-scroll-duration",
|
|
3052
3125
|
});
|
|
@@ -3406,6 +3479,15 @@ const Sessions = (() => {
|
|
|
3406
3479
|
// Local deployments (localhost / 127.0.0.1 / ::1): open the file with the
|
|
3407
3480
|
// OS default handler. Remote deployments: download the file.
|
|
3408
3481
|
document.addEventListener("click", async (e) => {
|
|
3482
|
+
const attachment = e.target.closest?.(".msg-file-open[data-file-path]");
|
|
3483
|
+
if (attachment) {
|
|
3484
|
+
e.preventDefault();
|
|
3485
|
+
let filePath = attachment.dataset.filePath || "";
|
|
3486
|
+
try { filePath = decodeURIComponent(filePath); } catch (_) { /* use raw path */ }
|
|
3487
|
+
_openAttachment(filePath);
|
|
3488
|
+
return;
|
|
3489
|
+
}
|
|
3490
|
+
|
|
3409
3491
|
// Localhost dev-server URLs open in the preview panel instead of a new
|
|
3410
3492
|
// tab (local deployments only — the proxy can't reach a remote user's
|
|
3411
3493
|
// localhost). Links that belong to the platform (not a dev server) opt
|
|
@@ -3607,18 +3689,26 @@ const Sessions = (() => {
|
|
|
3607
3689
|
* No-op for the session the user is already looking at. */
|
|
3608
3690
|
markDone(id) {
|
|
3609
3691
|
if (!id || id === _activeId) return;
|
|
3610
|
-
clearTimeout(_recentlyDone.get(id));
|
|
3611
|
-
_recentlyDone.set(id, setTimeout(() => {
|
|
3692
|
+
clearTimeout(_recentlyDone.get(id)?.timer);
|
|
3693
|
+
_recentlyDone.set(id, { summary: null, timer: setTimeout(() => {
|
|
3612
3694
|
_recentlyDone.delete(id);
|
|
3613
3695
|
Sessions.renderList();
|
|
3614
|
-
}, DONE_DOT_TTL));
|
|
3696
|
+
}, DONE_DOT_TTL) });
|
|
3615
3697
|
},
|
|
3616
3698
|
|
|
3699
|
+
/** Keep the turn's "complete" payload with its done dot until the session is opened. */
|
|
3700
|
+
markDoneSummary(id, ev) {
|
|
3701
|
+
const done = _recentlyDone.get(id);
|
|
3702
|
+
if (done) done.summary = ev;
|
|
3703
|
+
},
|
|
3704
|
+
|
|
3705
|
+
/** Drop the done dot; returns its unseen summary (or null). */
|
|
3617
3706
|
clearDone(id) {
|
|
3618
|
-
|
|
3619
|
-
|
|
3707
|
+
const done = _recentlyDone.get(id);
|
|
3708
|
+
if (!done) return null;
|
|
3709
|
+
clearTimeout(done.timer);
|
|
3620
3710
|
_recentlyDone.delete(id);
|
|
3621
|
-
return
|
|
3711
|
+
return done.summary;
|
|
3622
3712
|
},
|
|
3623
3713
|
|
|
3624
3714
|
/** Remove a session from the list (from session_deleted event). */
|
|
@@ -3631,7 +3721,7 @@ const Sessions = (() => {
|
|
|
3631
3721
|
}
|
|
3632
3722
|
// Clean up per-session progress state (timer + DOM + logical state)
|
|
3633
3723
|
Sessions._deleteProgressState(id);
|
|
3634
|
-
|
|
3724
|
+
_storeDraft(id, "");
|
|
3635
3725
|
_quoteDrafts.delete(id);
|
|
3636
3726
|
window.ChatNavigator?.clearBookmarks(id);
|
|
3637
3727
|
},
|
|
@@ -4003,9 +4093,7 @@ const Sessions = (() => {
|
|
|
4003
4093
|
* links, so the text rides the same restore path as a draft the user typed
|
|
4004
4094
|
* and is never submitted on its own. */
|
|
4005
4095
|
setDraft(id, text) {
|
|
4006
|
-
|
|
4007
|
-
if (text) _drafts.set(id, text);
|
|
4008
|
-
else _drafts.delete(id);
|
|
4096
|
+
_storeDraft(id, text);
|
|
4009
4097
|
},
|
|
4010
4098
|
|
|
4011
4099
|
/** Deselect active session and go to welcome screen. */
|
|
@@ -4025,7 +4113,8 @@ const Sessions = (() => {
|
|
|
4025
4113
|
_setActiveId(id) {
|
|
4026
4114
|
const oldId = _activeId;
|
|
4027
4115
|
_activeId = id;
|
|
4028
|
-
Sessions.clearDone(id);
|
|
4116
|
+
const summary = Sessions.clearDone(id);
|
|
4117
|
+
_unseenSummary = summary ? { id, ev: summary } : null;
|
|
4029
4118
|
// Cancel any pending "all done" hide timer from the previous session —
|
|
4030
4119
|
// it shouldn't fire on the new one.
|
|
4031
4120
|
if (Sessions._todoClearTimer) {
|
|
@@ -4037,7 +4126,7 @@ const Sessions = (() => {
|
|
|
4037
4126
|
}
|
|
4038
4127
|
const input = $("user-input");
|
|
4039
4128
|
if (input) {
|
|
4040
|
-
Composer.setText(input,
|
|
4129
|
+
Composer.setText(input, _readDraft(id));
|
|
4041
4130
|
}
|
|
4042
4131
|
const draft = _attachmentDrafts.get(id);
|
|
4043
4132
|
if (draft) {
|
|
@@ -4071,7 +4160,7 @@ const Sessions = (() => {
|
|
|
4071
4160
|
if (typeof QuoteSelect !== "undefined") QuoteSelect.dismiss();
|
|
4072
4161
|
if (_activeId) {
|
|
4073
4162
|
const input = $("user-input");
|
|
4074
|
-
if (input)
|
|
4163
|
+
if (input) _storeDraft(_activeId, Composer.text(input));
|
|
4075
4164
|
_attachmentDrafts.set(_activeId, { images: _pendingImages.splice(0), files: _pendingFiles.splice(0) });
|
|
4076
4165
|
if (typeof QuoteSelect !== "undefined") _quoteDrafts.set(_activeId, QuoteSelect.list());
|
|
4077
4166
|
_renderAttachmentPreviews();
|
|
@@ -4682,7 +4771,7 @@ const Sessions = (() => {
|
|
|
4682
4771
|
const label = I18n.t(labelKey);
|
|
4683
4772
|
sibStatus.innerHTML = `<span class="sib-dot"></span>${escapeHtml(label === labelKey ? st : label)}`;
|
|
4684
4773
|
sibStatus.className = `sib-status-${st}`;
|
|
4685
|
-
sibStatus.
|
|
4774
|
+
sibStatus.setAttribute("data-tooltip", I18n.t("sib.status.tooltip"));
|
|
4686
4775
|
}
|
|
4687
4776
|
|
|
4688
4777
|
// Session ID label — shows localised "Session file" label with short hash suffix.
|
|
@@ -4695,7 +4784,6 @@ const Sessions = (() => {
|
|
|
4695
4784
|
sibId.textContent = shortHash
|
|
4696
4785
|
? `${I18n.t("sib.id.label")}${lp}${shortHash}${rp}`
|
|
4697
4786
|
: I18n.t("sib.id.label");
|
|
4698
|
-
sibId.title = s.id || "";
|
|
4699
4787
|
if (s.id) {
|
|
4700
4788
|
sibId.dataset.sessionId = s.id;
|
|
4701
4789
|
} else {
|
|
@@ -4709,7 +4797,6 @@ const Sessions = (() => {
|
|
|
4709
4797
|
const sibDirText = $("sib-dir-text");
|
|
4710
4798
|
if (sibDir && sibDirText) {
|
|
4711
4799
|
sibDirText.textContent = s.working_dir ? _compactWorkingDir(s.working_dir) : "";
|
|
4712
|
-
sibDir.title = `${s.working_dir} (${I18n.t("sib.dir.tooltip")})`;
|
|
4713
4800
|
sibDir.hidden = !s.working_dir;
|
|
4714
4801
|
if (s.working_dir) {
|
|
4715
4802
|
sibDir.dataset.workingDir = s.working_dir;
|
|
@@ -4736,7 +4823,7 @@ const Sessions = (() => {
|
|
|
4736
4823
|
}
|
|
4737
4824
|
sibMode.dataset.sessionId = s.id;
|
|
4738
4825
|
sibMode.disabled = false;
|
|
4739
|
-
sibMode.
|
|
4826
|
+
sibMode.setAttribute("data-tooltip", I18n.t("sib.mode.tooltip"));
|
|
4740
4827
|
sibMode.style.display = "";
|
|
4741
4828
|
}
|
|
4742
4829
|
if (sibSepAfterMode) {
|
|
@@ -4772,9 +4859,9 @@ const Sessions = (() => {
|
|
|
4772
4859
|
sibModel.classList.toggle("sib-model-no-subs", (s.sub_model_options || []).length <= 1);
|
|
4773
4860
|
const busy = s.status === "running";
|
|
4774
4861
|
sibModel.classList.toggle("sib-model-disabled", busy);
|
|
4775
|
-
sibModel.
|
|
4862
|
+
sibModel.setAttribute("data-tooltip", busy
|
|
4776
4863
|
? I18n.t("sib.model.tooltip.busy")
|
|
4777
|
-
: I18n.t("sib.model.tooltip");
|
|
4864
|
+
: I18n.t("sib.model.tooltip"));
|
|
4778
4865
|
}
|
|
4779
4866
|
if (sibModelWrap) sibModelWrap.style.display = s.model ? "" : "none";
|
|
4780
4867
|
|
|
@@ -4806,7 +4893,7 @@ const Sessions = (() => {
|
|
|
4806
4893
|
} else {
|
|
4807
4894
|
sibCost.textContent = "N/A";
|
|
4808
4895
|
}
|
|
4809
|
-
sibCost.
|
|
4896
|
+
sibCost.setAttribute("data-tooltip", I18n.t("sib.cost.tooltip"));
|
|
4810
4897
|
}
|
|
4811
4898
|
|
|
4812
4899
|
const bar = $("session-info-bar");
|
|
@@ -4878,7 +4965,7 @@ const Sessions = (() => {
|
|
|
4878
4965
|
if (lat.tps) parts.push(`${lat.tps} tok/s`);
|
|
4879
4966
|
if (lat.output_tokens) parts.push(`${lat.output_tokens} tokens`);
|
|
4880
4967
|
if (lat.model) parts.push(`@ ${lat.model}`);
|
|
4881
|
-
el.
|
|
4968
|
+
el.setAttribute("data-tooltip", "Last LLM call — " + parts.join(" · "));
|
|
4882
4969
|
|
|
4883
4970
|
wrap.style.display = "";
|
|
4884
4971
|
if (sep) sep.style.display = "";
|
|
@@ -4978,14 +5065,14 @@ const Sessions = (() => {
|
|
|
4978
5065
|
appendToolResult(result, ui = null) {
|
|
4979
5066
|
const messages = RenderTarget.current();
|
|
4980
5067
|
const ctx = Sessions._toolGroupCtx(messages);
|
|
4981
|
-
const promoted = ui
|
|
5068
|
+
const promoted = _isPromotedToolResult(ui);
|
|
4982
5069
|
if (ctx.group && ctx.item) {
|
|
4983
5070
|
_completeLastToolItem(ctx.group, result, { ui });
|
|
4984
5071
|
if (promoted) {
|
|
4985
5072
|
_collapseToolGroup(ctx.group);
|
|
4986
5073
|
ctx.group = null;
|
|
4987
5074
|
ctx.item = null;
|
|
4988
|
-
|
|
5075
|
+
_promoteToolResult(messages, ui);
|
|
4989
5076
|
_scrollToBottomIfNeeded(messages);
|
|
4990
5077
|
}
|
|
4991
5078
|
return;
|
|
@@ -4997,7 +5084,7 @@ const Sessions = (() => {
|
|
|
4997
5084
|
if (item) {
|
|
4998
5085
|
_completeToolItem(item, result, { ui });
|
|
4999
5086
|
if (promoted) {
|
|
5000
|
-
|
|
5087
|
+
_promoteToolResult(messages, ui);
|
|
5001
5088
|
_scrollToBottomIfNeeded(messages);
|
|
5002
5089
|
}
|
|
5003
5090
|
return;
|
|
@@ -5175,10 +5262,7 @@ const Sessions = (() => {
|
|
|
5175
5262
|
// Stash the raw markdown for the copy button. If the caller passed
|
|
5176
5263
|
// pre-rendered HTML (e.g. feedback card), dataset.raw will still hold it;
|
|
5177
5264
|
// the copy handler falls back to textContent in that case.
|
|
5178
|
-
el
|
|
5179
|
-
el.innerHTML = _renderMarkdown(html);
|
|
5180
|
-
_appendCopyButton(el);
|
|
5181
|
-
_enhanceTaskItems(el, html || "");
|
|
5265
|
+
_fillMarkdownMessage(el, html);
|
|
5182
5266
|
} else {
|
|
5183
5267
|
el.innerHTML = html;
|
|
5184
5268
|
}
|
|
@@ -5226,6 +5310,36 @@ const Sessions = (() => {
|
|
|
5226
5310
|
}
|
|
5227
5311
|
},
|
|
5228
5312
|
|
|
5313
|
+
/** Render the end-of-turn "✓ Done" summary from a `complete` payload. */
|
|
5314
|
+
appendCompleteSummary(ev) {
|
|
5315
|
+
const costSource = ev.cost_source;
|
|
5316
|
+
const symbol = typeof Billing !== "undefined" ? Billing.getCurrencySymbol() : "$";
|
|
5317
|
+
const rawCost = ev.cost || 0;
|
|
5318
|
+
const cost = typeof Billing !== "undefined" ? Billing.convertCost(rawCost) : rawCost;
|
|
5319
|
+
const costDisplay = (!costSource || costSource === "estimated")
|
|
5320
|
+
? "N/A"
|
|
5321
|
+
: `${symbol}${cost.toFixed(4)}`;
|
|
5322
|
+
let mainLine = I18n.t("chat.done", { n: ev.iterations, cost: costDisplay });
|
|
5323
|
+
if (typeof ev.duration === "number" && ev.duration > 0) {
|
|
5324
|
+
mainLine += I18n.t("chat.done.duration", { duration: ev.duration.toFixed(1) });
|
|
5325
|
+
}
|
|
5326
|
+
let cacheLine = null;
|
|
5327
|
+
const cs = ev.cache_stats;
|
|
5328
|
+
const total = cs && (cs.total_requests || cs["total_requests"]);
|
|
5329
|
+
const hits = cs && (cs.cache_hit_requests || cs["cache_hit_requests"]);
|
|
5330
|
+
const cachedTokens = cs && (cs.cache_read_input_tokens || cs["cache_read_input_tokens"]);
|
|
5331
|
+
if (total && total > 0 && cachedTokens && cachedTokens > 0) {
|
|
5332
|
+
const rate = ((hits / total) * 100).toFixed(1);
|
|
5333
|
+
const tokensFmt = cachedTokens >= 1000
|
|
5334
|
+
? `${(cachedTokens / 1000).toFixed(1)}k`
|
|
5335
|
+
: `${cachedTokens}`;
|
|
5336
|
+
cacheLine = I18n.t("chat.done.cache", {
|
|
5337
|
+
rate, hits, total: total, tokens: tokensFmt
|
|
5338
|
+
});
|
|
5339
|
+
}
|
|
5340
|
+
Sessions.appendInfo(`✓ ${mainLine}`, cacheLine);
|
|
5341
|
+
},
|
|
5342
|
+
|
|
5229
5343
|
appendInfo(text, subline) {
|
|
5230
5344
|
Sessions.collapseToolGroup();
|
|
5231
5345
|
const messages = RenderTarget.current();
|
|
@@ -5602,7 +5716,7 @@ const Sessions = (() => {
|
|
|
5602
5716
|
listEl.textContent = "";
|
|
5603
5717
|
trigger.style.width = "";
|
|
5604
5718
|
const emptyLabel = I18n.t("chat.todo.empty");
|
|
5605
|
-
trigger.
|
|
5719
|
+
trigger.setAttribute("data-tooltip", emptyLabel);
|
|
5606
5720
|
trigger.setAttribute("aria-label", emptyLabel);
|
|
5607
5721
|
Sessions._setTodoPopoverOpen(false);
|
|
5608
5722
|
return;
|
|
@@ -5612,8 +5726,8 @@ const Sessions = (() => {
|
|
|
5612
5726
|
const progress = I18n.t("chat.todo.progress", { completed, total });
|
|
5613
5727
|
countEl.textContent = count;
|
|
5614
5728
|
summaryEl.textContent = progress;
|
|
5615
|
-
trigger.
|
|
5616
|
-
trigger.setAttribute("aria-label", trigger.
|
|
5729
|
+
trigger.setAttribute("data-tooltip", `${I18n.t("chat.todo.open")} · ${progress}`);
|
|
5730
|
+
trigger.setAttribute("aria-label", trigger.getAttribute("data-tooltip"));
|
|
5617
5731
|
// Keep the empty slot genuinely compact, then animate to the exact
|
|
5618
5732
|
// width needed by the current count instead of reserving a wide box.
|
|
5619
5733
|
trigger.style.width = `${Math.min(84, 40 + count.length * 7)}px`;
|
|
@@ -5632,6 +5746,7 @@ const Sessions = (() => {
|
|
|
5632
5746
|
viewportSelector: ".todo-text",
|
|
5633
5747
|
contentSelector: ".todo-text__content",
|
|
5634
5748
|
activeClass: "todo-text-scrolling",
|
|
5749
|
+
fadeClass: "todo-text-leading-fade",
|
|
5635
5750
|
distanceProperty: "--todo-text-scroll-distance",
|
|
5636
5751
|
durationProperty: "--todo-text-scroll-duration",
|
|
5637
5752
|
revealPadding: 12,
|
|
@@ -6654,11 +6769,14 @@ const Sessions = (() => {
|
|
|
6654
6769
|
submitting = true;
|
|
6655
6770
|
input.disabled = true;
|
|
6656
6771
|
const navigated = await navigateTo(path, true, true, true);
|
|
6657
|
-
if (
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6772
|
+
if (navigated) {
|
|
6773
|
+
// Same-path navigation returns early without rebuilding the breadcrumb.
|
|
6774
|
+
if (breadcrumb.contains(input)) refreshBreadcrumb(currentPath);
|
|
6775
|
+
return;
|
|
6661
6776
|
}
|
|
6777
|
+
enterAddressMode(path);
|
|
6778
|
+
const retryInput = breadcrumb.querySelector(".dp-address-input");
|
|
6779
|
+
retryInput?.classList.add("invalid");
|
|
6662
6780
|
});
|
|
6663
6781
|
input.addEventListener("keydown", (e) => {
|
|
6664
6782
|
e.stopPropagation();
|
|
@@ -7112,7 +7230,6 @@ const Sessions = (() => {
|
|
|
7112
7230
|
const sibDirText = $("sib-dir-text");
|
|
7113
7231
|
if (sibDir && sibDirText) {
|
|
7114
7232
|
sibDirText.textContent = newDir;
|
|
7115
|
-
sibDir.title = `${newDir} (${I18n.t("sib.dir.tooltip")})`;
|
|
7116
7233
|
sibDir.dataset.workingDir = newDir;
|
|
7117
7234
|
}
|
|
7118
7235
|
|