bunnyquery 1.21.4 → 1.21.7

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/bunnyquery.js CHANGED
@@ -996,10 +996,12 @@ Extracted content of attached office files (read inline below; do NOT fetch thei
996
996
  const webAccess = params.webAccess === true;
997
997
  const g = params.indexAccessGroup;
998
998
  const indexGroupLiteral = typeof g === "number" ? String(g) : g === "public" || g === "private" || g === "authorized" || g === "admin" ? `"${g}"` : '"authorized"';
999
+ const reindexHint = canUpload === false ? `asking the project's owner to re-index that file` : `re-indexing that file (attach the same file again and choose to reindex it)`;
999
1000
  const groundingRules = `ANSWER ONLY FROM THE DATA. Every fact you state about this project's data - a name, a number, a date, a status, what a document says, whether something exists - must come from one of four places: a tool result returned in THIS conversation, a file or image attached to it (including one you read through its attachment link), the project description at the end of this prompt, or what the user told you themselves in this chat. Your general knowledge, the open internet and a plausible guess are NOT sources. Never use them to answer a question about the user's data, to fill a gap in it, or to complete a record that came back partial. A value that is not in what you retrieved is unknown: say it is not in the data instead of supplying a likely one.
1000
1001
  WHEN THE DATA DOES NOT HAVE IT, SAY SO. Once you have searched the way these rules require and nothing answers the question, tell the user plainly, in their language, that this project's data does not contain it, and say what you searched (the tables, files or terms) so they can tell missing data from a missed search. Do not answer from memory instead, and do not turn a missing answer into a general explanation of the topic. Offer what would let you answer it: ${canUpload === false ? `another name or file to look under, or asking the project's owner to add it` : `the document to upload, or another name or file to look under`}.
1002
+ A CODE, NUMBER OR PHRASE THAT searchText DID NOT FIND: when it answers search_complete with no hit, and what its message says was NOT searched has been checked as it says (the skipped_without_page_text files, the records when the value could be in a table), keep the answer short: say plainly that it was not found, name what was searched (the file, and its pages when you searched only some of them, or files_searched files and total_pages_searched pages), and when a recently uploaded file or a photo should hold it, suggest ${reindexHint}, since small or handwritten characters can be misread at indexing. Never present a different file as the match, and never guess the value.
1001
1003
  KEEP WHAT THE DATA SAYS APART FROM WHAT YOU WORKED OUT. A total you computed, a comparison, a trend, an interpretation or a recommendation is yours, not the data's: label it as such ("calculated from...", "this suggests...") and name the rows or files it was made from. Never present an estimate, an assumption or an inference as something the data states.
1002
- These three rules govern every claim about the project's data. They do not limit the About BunnyQuery section (answer product questions from it), a greeting, or text the user explicitly asks you to write.`;
1004
+ These rules govern every claim about the project's data. They do not limit the About BunnyQuery section (answer product questions from it), a greeting, or text the user explicitly asks you to write.`;
1003
1005
  const webRule = webAccess ? `WEB ACCESS IS ON for this project: when the user asks for something that is not in the project's data, you may search the web for it, but every such fact must be marked as coming from the web (name the site), kept apart from what the project's data says, and never used to fill in or complete a document's content or a record. This is the one exception to the four sources named above.` : `This chat has no web tool: the web is never a source here.`;
1004
1006
  const documentRules = `DOCUMENTS (a contract, a report, a manual, a letter, any uploaded file the user asks about the content of): when the user NAMED a file (its file name; a document title, a quote or a code they mention is NOT a file name: searchText finds those inside the files), first find its storage path by its "src::" record (see WHERE INDEXED CONTENT LIVES) using the name the user used, then find the page with searchText and that path. A spreadsheet's sheets are page text too: a hit names its sheet and rows, and the row itself is a record (its unique_id is the hit's row_id_prefix plus the row number); a spreadsheet indexed before 2026-11-25 has no page text, so read its rows instead (readFileContent, or its records). When they did not name a file, your FIRST call is searchText without a path: no table list, no file lookup before it. Never list or look up files (getUniqueId on "src::") to find out whether a document, quote or title exists before searching: searchText's hits name the file, and a search that finds nothing says what it could not cover. Either way follow searchText's description to the end, including asking the user once, after quick results, before it searches all files. QUOTE THE EXACT TEXT it returned and CITE THE FILE AND THE PAGE ("report.pdf, page 7"), or for a hit with "sheet" THE FILE AND THE SHEET ("quote.xlsx, sheet \uCD1D\uAD04"), never a sheet page's number; never present a paraphrase as a quote. A file with no page text is read with readFileContent instead and cited by its file name. In a long file (a manual, a book), when a search of the whole file gives too many hits or none that fit, call getFileOutline and search the chapter that fits with searchText page_from and page_to. When the user asks about the content of the documents, pass searchText "question": that question in the user's own words, without names or personal details that are not about the documents. Leave "question" out for anything else.
1005
1007
  WRONG ANSWER: when the user says an answer is wrong (or sends "This answer seems wrong. Please check it again against the documents."), re-read the pages you cited (for a sheet hit, the rows: by its row_id_prefix, never readFileContent on a sheet page) and search again, passing searchText "question" = the user's ORIGINAL question that the disputed answer answered, never the complaint message itself. Then do exactly one of: correct the answer only; correct the answer and call correctSearchLink (when it is among your tools); or keep the answer and quote the text that supports it. Call correctSearchLink only with the page and an exact quote that prove it, and never change data on the user's word alone.`;
@@ -1067,7 +1069,7 @@ Project description: """${serviceDescription}"""`;
1067
1069
  - PDFs (scanned or not): you do NOT read a PDF with a tool or a URL. Its pages are RENDERED and embedded directly in the user message as IMAGE blocks, a WINDOW of pages at a time. LOOK at the embedded page images and datafy every one. The note beside them tells you whether MORE pages remain: if so, save this window's records and stop (a follow-up pass shows the next window automatically); only when the note says it was the LAST window is the PDF fully seen. Do NOT call readFileContent or web_fetch for a PDF.
1068
1070
  - VISION: when the message (a readFileContent window, an embedded PDF page, or an inline attachment) includes IMAGES - scanned/rendered PDF pages, or photos embedded in a spreadsheet next to a row/block - LOOK at them and capture what they show as record data (the reading/values in a scanned table, the part/defect/condition visible in a photo). The image IS part of the data; correlate each photo with its labelled block ("PHOTO A3" markers tie a photo to that grid row).
1069
1071
  - TRANSCRIBE, DO NOT DESCRIBE. When an image contains ANY text - a label, tag, stamp, form field, serial/part number, handwriting - your FIRST job is to read the characters out and store them VERBATIM, not to describe the scene. A record saying "a red inspection tag with handwritten markings" is worthless: it is unsearchable and every such photo produces the same sentence. Put the characters you can actually read into these EXACT fields, not variations of them: "printed_text" (the pre-printed wording), "handwritten_text" (what a person wrote by hand), and, when you can resolve one, "part_no", "serial_no", "tag_id" and "date". Every identifier you read (a serial number, a part number, a tag id, a model code) ALSO goes into "printed_text" or "handwritten_text", exactly as it appears, because those two fields are the image's searchable text. Text can appear at ANY angle (sideways, upside down, mirrored, along a curve): read it in its own orientation, and never call text unreadable only because it is turned. When it is upside down or sideways, watch the look-alikes (6 and 9, 0 and O, 1 and I, Latin and Cyrillic letters of the same shape). Same reason as the fixed table names: a field called photo_text in one pass and visible_text_notes in the next cannot be queried together. Read PARTIAL values rather than skipping: "500.7402.5[?][?]" beats nothing. Write [?] for each character that is genuinely unreadable and copy handwriting character for character - do NOT invent a character, and do NOT replace the whole transcription with a description of what the object looks like. A scene description is a nice extra AFTER the text, never instead of it.
1070
- - IMAGE FILES uploaded as the file itself: if ANY readable character appears ANYWHERE in the image (a label, a stamp, a sign in the background) it counts as an image WITH text - transcribe it per the rule above, and also capture the layout (what appears where) and every entity named. Only a truly text-free image gets description first: a one-line caption, then the objects present with their attributes (type, color, count, condition, position). Either way, save what you extract onto the file's "src::" record with updateRecords, TAG every entity and identifier visible, and INDEX the one number the image offers (a measured value, an amount, a count). On that same record ALSO set "text_rotation" and "text_legibility". "text_rotation" is the CLOCKWISE turn, 0, 90, 180 or 270, that would make the image's main text upright AS THE IMAGE IS SHOWN TO YOU: 0 when it already reads normally; 180 when it is upside down; 90 when its lines run from bottom to top (the tops of the letters face left); 270 when its lines run from top to bottom (the tops of the letters face right). "text_legibility" is "clear", "partial" or "unreadable" ("none" when there is no text).
1072
+ - IMAGE FILES uploaded as the file itself: if ANY readable character appears ANYWHERE in the image (a label, a stamp, a sign in the background) it counts as an image WITH text - transcribe it per the rule above, and also capture the layout (what appears where) and every entity named. Only a truly text-free image gets description first: a one-line caption, then the objects present with their attributes (type, color, count, condition, position). Either way, save what you extract onto the file's "src::" record with updateRecords, TAG every entity and identifier visible, and INDEX the one number the image offers (a measured value, an amount, a count). On that same record ALSO set "text_rotation" and "text_legibility". "text_rotation" is the CLOCKWISE turn, 0, 90, 180 or 270, that would make the image's main text upright AS THE IMAGE IS SHOWN TO YOU: 0 when it already reads normally; 180 when it is upside down; 90 when its lines run from bottom to top (the tops of the letters face left); 270 when its lines run from top to bottom (the tops of the letters face right). "text_legibility" is "clear", "partial" or "unreadable" ("none" when there is no text). ALSO set "text_regions" on that record: a list of up to 4 boxes [left, top, right, bottom], each a fraction from 0 to 1 of the image AS IT IS SHOWN TO YOU (not turned upright), drawn tightly around a label, plate or handwritten area whose characters matter (a serial number, a part number, a tag id); [] when there is none. Where a label names a value (a form field, a plate line), write the value right after its label in "printed_text" or "handwritten_text", as "<label>: <value>" (the label's own words, then the characters written beside it), so the label and its value are found together.
1071
1073
  - Whatever the file type, this file's identity is "src::" + its storage path (the "storage path" metadata line) - never the inline content or a temporary URL. That record ALREADY EXISTS: the upload pipeline creates it in table "file_summaries" (access group "${accessGroup}") before indexing starts, so posting it again is rejected as a duplicate unique_id. Reference it from every record you write, and add what you learn to it with updateRecords. If that update unexpectedly reports the record does not exist, post it yourself ONCE with that exact "src::" unique_id (table "file_summaries", access group "${accessGroup}") and carry on; this is the ONE exception to the do-NOT-post-the-file-record rules elsewhere in these instructions, because the source identity must never be dropped just because an update failed.
1072
1074
  - ACCESS GROUP (hard rule): every record you write for this file - the file record, per-row records, chapters, summaries, intermediates - MUST be posted with access group "${accessGroup}". Pass it explicitly on every postRecords call; do not leave it out and do not vary it between passes of the same file. An access group is part of a record's table key, so records saved under a different group than the file are in a different table and will not come back with the rest of it: a "public" file whose rows were saved as "authorized" is one an anonymous visitor can see the name of and none of the contents of, and a re-index cannot find the strays to clean them up. The one exception is the EXTRACTED MEDIA records in "__MEDIA__", which the pipeline creates for you - leave their group alone and only enrich them.
1073
1075
  - REACHABILITY (hard rule): every record you write while indexing this file MUST be reachable from the file's "src::<storage path>" record by following reference - either reference that record directly, or reference something that already reaches it. A record with no reference, or one pointing outside this file's chain, is an ORPHAN: deleting or re-indexing the file removes the reachable records and leaves the orphan behind forever, where it keeps turning up in later answers as stale data. If you create an intermediate record that OTHER records reference (a page record that rows hang off, a sheet or section record), set source.can_remove_referencing_records to true on it; the delete cascade passes a delete through a record only when that record carries the flag OR a unique_id starting "src::" (the file record cascades because its unique_id starts with "src::"; the intermediates you create carry no "src::" id, so they need the flag), and it cascades ONE LEVEL AT A TIME, so EVERY intermediate record in a chain needs its own marker - an unmarked link stops the cascade there and everything below it survives as orphans. When in doubt, reference the file record directly and keep the chain flat.
@@ -1144,7 +1146,7 @@ Read this file with the readFileContent tool, using the storage path above - do
1144
1146
  return head + `- temporary URL: ${attachment.url}
1145
1147
  ` + (options.imageFile === "attached" ? `
1146
1148
  This is an IMAGE file, attached to this message as an image: read it there, not from the URL. ` : `
1147
- This is an IMAGE file in a format the AI cannot take directly. When an image of it is attached to this message (the server converts it when it can), read it there; when none is attached, index the file from its metadata only and do not guess its contents. `) + `Transcribe every character FIRST, at whatever angle the text is: "printed_text", "handwritten_text", and "part_no" / "serial_no" / "tag_id", with every identifier also written inside "printed_text" or "handwritten_text". Then set "text_rotation" and "text_legibility" on the file's "src::" record, and only then describe what the image shows.`;
1149
+ This is an IMAGE file in a format the AI cannot take directly. When an image of it is attached to this message (the server converts it when it can), read it there; when none is attached, index the file from its metadata only and do not guess its contents. `) + `Transcribe every character FIRST, at whatever angle the text is: "printed_text", "handwritten_text", and "part_no" / "serial_no" / "tag_id", with every identifier also written inside "printed_text" or "handwritten_text". Write each label's value right after its label, as "<label>: <value>" (the label's own words, then the characters written beside it), reading small and handwritten characters closely; use [?] only for a character that is truly unreadable, and never put a guessed character in its place. Then set "text_rotation", "text_legibility" and "text_regions" on the file's "src::" record, and only then describe what the image shows. "text_regions" is a list of up to 4 boxes [left, top, right, bottom], each a fraction from 0 to 1 of the image exactly as it is shown to you here (not turned upright), drawn tightly around a label, plate or handwritten area whose characters matter (a serial number, a part number, a tag); [] when there is none.`;
1148
1150
  }
1149
1151
  return head + `- temporary URL (fetch this to read the file contents): ${attachment.url}`;
1150
1152
  }
@@ -3051,6 +3053,16 @@ Index the REMAINING windows - one record per row/item, looking at any page image
3051
3053
  out.push(s + "s");
3052
3054
  return out.join(" ");
3053
3055
  }
3056
+ function formatIndexDuration(ms) {
3057
+ if (typeof ms !== "number" || !isFinite(ms) || ms < 1e3) return "";
3058
+ var total = Math.floor(ms / 1e3);
3059
+ var h = Math.floor(total / 3600);
3060
+ var m = Math.floor(total % 3600 / 60);
3061
+ var s = total % 60;
3062
+ if (h) return h + " h" + (m ? " " + m + " min" : "");
3063
+ if (m) return m + " min" + (s ? " " + s + " s" : "");
3064
+ return s + " s";
3065
+ }
3054
3066
  function requestIdTimeMs(rid) {
3055
3067
  if (typeof rid !== "string") return 0;
3056
3068
  var stamp = rid.split(":")[0] || "";
@@ -3149,6 +3161,46 @@ Index the REMAINING windows - one record per row/item, looking at any page image
3149
3161
  grp.resolving = false;
3150
3162
  grp.resolvingReason = void 0;
3151
3163
  }
3164
+ function runRecordDurationMs(rec) {
3165
+ if (!rec || rec.status !== "done") return void 0;
3166
+ var a = rec.started;
3167
+ var b = rec.finished;
3168
+ if (typeof a !== "number" || typeof b !== "number" || !isFinite(a) || !isFinite(b) || b < a) return void 0;
3169
+ return b - a;
3170
+ }
3171
+ var RUN_DURATION_CLOCK_SLACK_MS = 6e4;
3172
+ var RUN_DURATION_SERVER_SLACK_MS = 5e3;
3173
+ function runRecordGroupDurationMs(grp, rec) {
3174
+ if (rec.status !== "done" || !grp.members.length) return void 0;
3175
+ var fin = rec.finished;
3176
+ if (typeof fin !== "number" || !isFinite(fin)) return void 0;
3177
+ var firstTs = messageTimeMs(grp.members[0].msg);
3178
+ var lastTs = messageTimeMs(grp.members[grp.members.length - 1].msg);
3179
+ if (!firstTs || !lastTs) return void 0;
3180
+ if (fin < firstTs || fin < lastTs - RUN_DURATION_SERVER_SLACK_MS) return void 0;
3181
+ var firstPassTs = 0;
3182
+ for (var i = 0; i < grp.members.length; i++) {
3183
+ var m = grp.members[i].msg;
3184
+ if (m.role !== "user") continue;
3185
+ var ref = readFileRef(m);
3186
+ if (ref && !ref.continued) firstPassTs = messageTimeMs(m);
3187
+ break;
3188
+ }
3189
+ var st = typeof rec.started === "number" && isFinite(rec.started) ? rec.started : void 0;
3190
+ var start;
3191
+ if (st !== void 0 && st > firstTs + RUN_DURATION_CLOCK_SLACK_MS) return void 0;
3192
+ if (firstPassTs) {
3193
+ start = st !== void 0 && st >= firstPassTs - RUN_DURATION_CLOCK_SLACK_MS ? st : firstPassTs;
3194
+ } else {
3195
+ if (st === void 0) return void 0;
3196
+ start = st;
3197
+ }
3198
+ return fin >= start ? fin - start : void 0;
3199
+ }
3200
+ function indexGroupDurationLabel(group) {
3201
+ if (!group || group.status !== "done" || !group.finished || group.resolving || group.queued) return "";
3202
+ return formatIndexDuration(group.durationMs);
3203
+ }
3152
3204
  function buildChatDisplayList(messages, opts) {
3153
3205
  var list = Array.isArray(messages) ? messages : [];
3154
3206
  var liveIndexKeys = opts && opts.liveIndexKeys || {};
@@ -3504,7 +3556,9 @@ Index the REMAINING windows - one record per row/item, looking at any page image
3504
3556
  resolvingReason: reason,
3505
3557
  stub: true,
3506
3558
  queued: waitingStub || live && !!runningKeys && !runningKeys[sp] && !runningKeys[canonIndexKey(sp)] && !runningKeys[fname] ? true : void 0,
3507
- stubError: rec.error || (st === "error" && !rec.error ? "Indexing did not finish." : void 0)
3559
+ stubError: rec.error || (st === "error" && !rec.error ? "Indexing did not finish." : void 0),
3560
+ // The stub IS the record, so a 'done' record's span is this run's.
3561
+ durationMs: st === "done" ? runRecordDurationMs(rec) : void 0
3508
3562
  };
3509
3563
  stubList.push({ started: typeof rec.started === "number" ? rec.started : Infinity, group: sg });
3510
3564
  }
@@ -3523,6 +3577,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
3523
3577
  tg.runKey = "run:" + (tg.path || tg.key) + "#" + trec.started;
3524
3578
  stubList.push({ started: trec.started, group: tg });
3525
3579
  overlayRunRecordVerdict(tg, trec, liveIndexKeys);
3580
+ tg.durationMs = runRecordGroupDurationMs(tg, trec);
3526
3581
  }
3527
3582
  }
3528
3583
  stubList.sort(function(a, b) {
@@ -3958,6 +4013,22 @@ Index the REMAINING windows - one record per row/item, looking at any page image
3958
4013
  var INLINE_LINK_GLYPH = "\u2197";
3959
4014
  var INLINE_LINK_UNAVAILABLE_GLYPH = "\u2715";
3960
4015
  var INLINE_LINK_UNAVAILABLE_SUFFIX = " (unavailable)";
4016
+ var FIT_LABEL_TAIL_CHARS = 8;
4017
+ function splitLabelForFit(name) {
4018
+ var chars = Array.from(String(name == null ? "" : name));
4019
+ var dot = -1;
4020
+ for (var i = chars.length - 1; i > 0; i--) {
4021
+ if (chars[i] === ".") {
4022
+ dot = i;
4023
+ break;
4024
+ }
4025
+ if (chars[i] === " " || chars[i] === "/" || chars.length - i > 10) break;
4026
+ }
4027
+ var extStart = dot > 0 && dot < chars.length - 1 ? dot : chars.length;
4028
+ var tailStart = Math.max(0, extStart - FIT_LABEL_TAIL_CHARS);
4029
+ if (tailStart < 4) return { stem: chars.join(""), tail: "" };
4030
+ return { stem: chars.slice(0, tailStart).join(""), tail: chars.slice(tailStart).join("") };
4031
+ }
3961
4032
  function renderInlineLinkHtml(link, opts) {
3962
4033
  var o = opts || {};
3963
4034
  var unavailable = !!o.unavailable;
@@ -3970,7 +4041,16 @@ Index the REMAINING windows - one record per row/item, looking at any page image
3970
4041
  if (unavailable) cls.push("is-unavailable");
3971
4042
  if (preview) cls.push("is-image-preview");
3972
4043
  var glyphHtml = '<span class="bq-link-glyph" translate="no">' + (unavailable ? INLINE_LINK_UNAVAILABLE_GLYPH : INLINE_LINK_GLYPH) + "</span>";
3973
- var labelHtml = glyphHtml + escapeInlineHtml(link.label + (unavailable ? INLINE_LINK_UNAVAILABLE_SUFFIX : refreshing ? " (fetching...)" : ""));
4044
+ var stateSuffix = unavailable ? INLINE_LINK_UNAVAILABLE_SUFFIX : refreshing ? " (fetching...)" : "";
4045
+ var fit = !!o.fitLabel && !preview;
4046
+ if (fit) cls.push("bq-link-fit");
4047
+ var labelHtml;
4048
+ if (fit) {
4049
+ var split = splitLabelForFit(full);
4050
+ labelHtml = glyphHtml + '<span class="bq-link-stem">' + escapeInlineHtml(split.stem) + "</span>" + (split.tail ? '<span class="bq-link-tail">' + escapeInlineHtml(split.tail) + "</span>" : "") + (stateSuffix ? '<span class="bq-link-tail">' + escapeInlineHtml(stateSuffix) + "</span>" : "");
4051
+ } else {
4052
+ labelHtml = glyphHtml + escapeInlineHtml(link.label + stateSuffix);
4053
+ }
3974
4054
  var attrs = ['class="' + cls.join(" ") + '"'];
3975
4055
  if (unavailable) attrs.push('aria-disabled="true"', 'data-bq-unavailable="1"');
3976
4056
  else attrs.push('href="' + escapeInlineHtml(link.href) + '"', 'target="_blank"', 'rel="noopener noreferrer"');
@@ -5674,6 +5754,10 @@ Index the REMAINING windows - one record per row/item, looking at any page image
5674
5754
  var note = retrievalNoteOfAnswer(msg);
5675
5755
  return !!note && !answerUsedNoDataTool(note) && !msg.isCancelled;
5676
5756
  }
5757
+ var UPLOAD_CANCELLED_MESSAGE = "Upload cancelled";
5758
+ function isUploadCancelledError(err) {
5759
+ return !!err && (err.code === "CANCELLED" || err.message === UPLOAD_CANCELLED_MESSAGE);
5760
+ }
5677
5761
  var _ChatSession = class _ChatSession {
5678
5762
  constructor(host) {
5679
5763
  // --- live streaming ----------------------------------------------------
@@ -12839,6 +12923,29 @@ Index the REMAINING windows - one record per row/item, looking at any page image
12839
12923
  });
12840
12924
  }
12841
12925
  // --- attachment upload orchestration ---------------------------------
12926
+ /**
12927
+ * The user cancelled this chip's upload (the widget's per-chip x or "Cancel all
12928
+ * uploads"). Stops the bytes now when they are moving (the host's abort), and
12929
+ * leaves a flag every later step of uploadSingleAttachment checks, so a cancel
12930
+ * that lands between steps (the get-signed-url round trip before the bytes, or
12931
+ * the src:: record and the indexing request after them) still stops the file
12932
+ * from being indexed and from being attached to the chat turn. A member whose
12933
+ * indexing request has already gone out is past cancelling: it shows as an
12934
+ * indexing row with its own Stop. Returns false for a chip that is not being
12935
+ * uploaded by this session any more.
12936
+ */
12937
+ cancelAttachmentUpload(att) {
12938
+ if (!att || att._cancelled) return false;
12939
+ if (att.status !== "uploading" && !att._batchId) return false;
12940
+ att._cancelled = true;
12941
+ if (typeof att._abort === "function") {
12942
+ try {
12943
+ att._abort();
12944
+ } catch (e) {
12945
+ }
12946
+ }
12947
+ return true;
12948
+ }
12842
12949
  // Upload one attachment (a file = 1 member, a folder = N) to db storage and
12843
12950
  // queue indexing per member. The bytes I/O + chip rendering go through host
12844
12951
  // hooks; the overwrite/reindex flow, status lifecycle, and indexing live here.
@@ -12861,6 +12968,17 @@ Index the REMAINING windows - one record per row/item, looking at any page image
12861
12968
  var anyIndexFailed = false;
12862
12969
  var reusedCount = 0;
12863
12970
  att.reused = false;
12971
+ att._storedCount = 0;
12972
+ att._indexQueuedCount = 0;
12973
+ att._indexQueued = false;
12974
+ var cancelError = function() {
12975
+ var e = new Error(UPLOAD_CANCELLED_MESSAGE);
12976
+ e.code = "CANCELLED";
12977
+ return e;
12978
+ };
12979
+ var checkCancel = function() {
12980
+ if (att._cancelled) throw cancelError();
12981
+ };
12864
12982
  delete att.duplicates;
12865
12983
  var chain = Promise.resolve();
12866
12984
  var findDuplicate = function(member) {
@@ -12877,10 +12995,12 @@ Index the REMAINING windows - one record per row/item, looking at any page image
12877
12995
  };
12878
12996
  members.forEach(function(member, idx) {
12879
12997
  chain = chain.then(function() {
12998
+ checkCancel();
12880
12999
  var hadExists = false;
12881
13000
  var skipped = false;
12882
13001
  var duplicateOf = null;
12883
13002
  var existedBefore = false;
13003
+ var madeRecord = false;
12884
13004
  var onProg = function(p) {
12885
13005
  if (p && p.total) {
12886
13006
  att.progress = Math.floor((idx + p.loaded / p.total) / total * 100);
@@ -12888,14 +13008,33 @@ Index the REMAINING windows - one record per row/item, looking at any page image
12888
13008
  }
12889
13009
  };
12890
13010
  var doMemberUpload = function(checkExistence) {
13011
+ checkCancel();
12891
13012
  return self.host.uploadFile({
12892
13013
  file: member.file,
12893
13014
  storagePath: member.storagePath,
12894
13015
  checkExistence,
12895
13016
  onProgress: onProg,
13017
+ // The host hands its abort over just before the bytes start. A
13018
+ // cancel made during the get-signed-url round trip had nothing to
13019
+ // abort yet, so it is applied here, before anything is sent: a
13020
+ // storage POST that never completes leaves no object behind.
12896
13021
  setAbort: function(abort) {
12897
13022
  att._abort = abort;
13023
+ if (att._cancelled) {
13024
+ try {
13025
+ abort();
13026
+ } catch (e) {
13027
+ }
13028
+ }
12898
13029
  }
13030
+ }).then(function(r) {
13031
+ att._abort = null;
13032
+ att._storedCount = (att._storedCount || 0) + 1;
13033
+ return r;
13034
+ }, function(err) {
13035
+ att._abort = null;
13036
+ if (att._cancelled) throw cancelError();
13037
+ throw err;
12899
13038
  });
12900
13039
  };
12901
13040
  if (isIndexRetry) {
@@ -12929,12 +13068,14 @@ Index the REMAINING windows - one record per row/item, looking at any page image
12929
13068
  existedBefore = true;
12930
13069
  });
12931
13070
  }).then(function() {
13071
+ checkCancel();
12932
13072
  if (skipped) return;
12933
13073
  return Promise.resolve(self.host.getTemporaryUrl(duplicateOf || member.storagePath)).catch(function(err) {
12934
13074
  var ecode = err && (err.code || err.body && err.body.code);
12935
13075
  var emsg = String(err && (err.message || err.body && err.body.message) || err || "");
12936
13076
  var refused = /no access to this file/i.test(emsg) || ecode === "INVALID_REQUEST" && /access/i.test(emsg);
12937
13077
  if (duplicateOf || !refused || typeof self.host.ensureFileIndexRecord !== "function") throw err;
13078
+ madeRecord = !existedBefore;
12938
13079
  return Promise.resolve(self.host.ensureFileIndexRecord(member.storagePath, {
12939
13080
  name: member.file.name,
12940
13081
  mime: member.file.type || self.host.getMimeType(member.file.name),
@@ -12944,6 +13085,13 @@ Index the REMAINING windows - one record per row/item, looking at any page image
12944
13085
  });
12945
13086
  });
12946
13087
  }).then(function(url) {
13088
+ if (att._cancelled) {
13089
+ var dropEarly = madeRecord && typeof self.host.deleteExistingFileRecord === "function" ? Promise.resolve(self.host.deleteExistingFileRecord(member.storagePath)).catch(function() {
13090
+ }) : Promise.resolve();
13091
+ return dropEarly.then(function() {
13092
+ throw cancelError();
13093
+ });
13094
+ }
12947
13095
  if (skipped) return;
12948
13096
  if (duplicateOf) {
12949
13097
  urls.push({ name: member.relPath, url, storagePath: duplicateOf });
@@ -12972,13 +13120,14 @@ Index the REMAINING windows - one record per row/item, looking at any page image
12972
13120
  var mime = member.file.type || self.host.getMimeType(member.file.name);
12973
13121
  var alreadyIndexing = false;
12974
13122
  var existingGroup = null;
13123
+ var clearedOld = false;
12975
13124
  var preIndex = self.claimIndexRun(member.storagePath).then(function(claimed) {
12976
13125
  alreadyIndexing = !claimed;
12977
13126
  if (alreadyIndexing) {
12978
13127
  console.log("[chat-engine] skipping a duplicate index request for", member.storagePath);
12979
13128
  return;
12980
13129
  }
12981
- if (!existedBefore) return;
13130
+ if (!existedBefore || att._cancelled) return;
12982
13131
  var readGroup = typeof self.host.readFileAccessGroup === "function" ? Promise.resolve(self.host.readFileAccessGroup(member.storagePath)).then(function(g) {
12983
13132
  existingGroup = g || null;
12984
13133
  }, function(err) {
@@ -12986,7 +13135,9 @@ Index the REMAINING windows - one record per row/item, looking at any page image
12986
13135
  throw err;
12987
13136
  }) : Promise.resolve();
12988
13137
  return readGroup.then(function() {
13138
+ if (att._cancelled) return;
12989
13139
  if (typeof self.host.deleteExistingFileRecord === "function") {
13140
+ clearedOld = true;
12990
13141
  return Promise.resolve(self.host.deleteExistingFileRecord(member.storagePath)).catch(function() {
12991
13142
  });
12992
13143
  }
@@ -12994,7 +13145,9 @@ Index the REMAINING windows - one record per row/item, looking at any page image
12994
13145
  });
12995
13146
  preIndex = preIndex.then(function() {
12996
13147
  if (alreadyIndexing) return;
13148
+ if (att._cancelled && !clearedOld) return;
12997
13149
  if (typeof self.host.ensureFileIndexRecord !== "function") return;
13150
+ if (!existedBefore) madeRecord = true;
12998
13151
  return Promise.resolve(self.host.ensureFileIndexRecord(member.storagePath, {
12999
13152
  name: member.file.name,
13000
13153
  mime: mime || void 0,
@@ -13015,10 +13168,28 @@ Index the REMAINING windows - one record per row/item, looking at any page image
13015
13168
  }).catch(function() {
13016
13169
  });
13017
13170
  });
13171
+ var abandonIfCancelled = function() {
13172
+ if (!att._cancelled) return;
13173
+ if (!alreadyIndexing) self.releaseIndexRun(member.storagePath);
13174
+ var drop = !existedBefore && !alreadyIndexing && madeRecord && typeof self.host.deleteExistingFileRecord === "function" ? Promise.resolve(self.host.deleteExistingFileRecord(member.storagePath)).catch(function() {
13175
+ }) : Promise.resolve();
13176
+ return drop.then(function() {
13177
+ throw cancelError();
13178
+ });
13179
+ };
13018
13180
  return preIndex.then(function() {
13181
+ return abandonIfCancelled();
13182
+ }).then(function() {
13019
13183
  return parseAttachmentContent(member.file, member.file.name, mime || void 0);
13184
+ }).then(function(parsedContent) {
13185
+ return Promise.resolve(abandonIfCancelled()).then(function() {
13186
+ return parsedContent;
13187
+ });
13020
13188
  }).then(function(parsedContent) {
13021
13189
  if (alreadyIndexing) return;
13190
+ att._indexQueuedCount = (att._indexQueuedCount || 0) + 1;
13191
+ if (att.kind !== "folder") att._indexQueued = true;
13192
+ self.host.renderAttachmentChips();
13022
13193
  return self.trackIndexDispatch(notifyAgentSaveAttachment({
13023
13194
  platform: id.platform,
13024
13195
  model: id.model,
@@ -13074,6 +13245,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
13074
13245
  });
13075
13246
  });
13076
13247
  return chain.then(function() {
13248
+ checkCancel();
13077
13249
  att._abort = null;
13078
13250
  att.progress = 100;
13079
13251
  if (att.kind === "folder") att.uploadedUrls = urls.map(function(u) {
@@ -13134,12 +13306,20 @@ Index the REMAINING windows - one record per row/item, looking at any page image
13134
13306
  return a.id === att.id;
13135
13307
  });
13136
13308
  var aborted = err && (err.message === "Aborted" || err === "Aborted");
13309
+ if (att._cancelled || isUploadCancelledError(err)) {
13310
+ att.status = "cancelled";
13311
+ att._abort = null;
13312
+ self.host.renderAttachmentChips();
13313
+ return;
13314
+ }
13137
13315
  if (removed || aborted) return;
13138
13316
  att.status = "error";
13139
13317
  att.errorMessage = "File upload has failed";
13140
13318
  att.errorCode = err && (err.code || err.body && err.body.code) || "";
13141
13319
  att.errorDetail = err && (err.message || err.body && err.body.message) || (typeof err === "string" ? err : "");
13142
13320
  self.host.renderAttachmentChips();
13321
+ }).then(function() {
13322
+ att._settledBatch = att._batchId || true;
13143
13323
  });
13144
13324
  });
13145
13325
  });
@@ -13170,7 +13350,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
13170
13350
  (function() {
13171
13351
  var MCP_PROD = "https://mcp.skapi.com";
13172
13352
  var MCP_DEV = "https://mcp-dev.broadwayinc.computer";
13173
- var BQ_VERSION = "1.21.4" ;
13353
+ var BQ_VERSION = "1.21.7" ;
13174
13354
  var ATTACHMENT_URL_EXPIRES_SECONDS = 600;
13175
13355
  var GOOGLE_AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
13176
13356
  var GOOGLE_TOKEN_URL = "https://oauth2.googleapis.com/token";
@@ -14961,6 +15141,8 @@ Index the REMAINING windows - one record per row/item, looking at any page image
14961
15141
  attachmentWarning: "",
14962
15142
  attachmentCapNotice: "",
14963
15143
  // informational "N files not added" when an add hit MAX_ATTACHMENT_FILE_COUNT
15144
+ attachmentCancelNotice: "",
15145
+ // "Upload cancelled: <file>." after the user cancelled uploads
14964
15146
  attachmentsRow: null,
14965
15147
  // .bq-attachments DOM node
14966
15148
  attachBtnEl: null,
@@ -15316,6 +15498,10 @@ Index the REMAINING windows - one record per row/item, looking at any page image
15316
15498
  updateComposerControls();
15317
15499
  return;
15318
15500
  }
15501
+ if (CS.attachmentCancelNotice) {
15502
+ CS.attachmentCancelNotice = "";
15503
+ renderAttachmentChips();
15504
+ }
15319
15505
  if (inputEl) {
15320
15506
  inputEl.value = "";
15321
15507
  autoGrowInput(inputEl);
@@ -15424,11 +15610,12 @@ Index the REMAINING windows - one record per row/item, looking at any page image
15424
15610
  function fileToAnchorHtml(filename, href) {
15425
15611
  return '<a class="bq-file-download" href="' + escapeHtml(href) + '" download="' + escapeHtml(filename) + '" target="_blank" rel="noopener noreferrer"><span class="bq-link-glyph" translate="no">\u2197</span>' + escapeHtml(filename) + "</a>";
15426
15612
  }
15427
- function linkToAnchorHtml(link, allowImagePreview) {
15613
+ function linkToAnchorHtml(link, allowImagePreview, fitLabel) {
15428
15614
  return renderInlineLinkHtml(link, {
15429
15615
  refreshing: !!refreshingLinkMap[link.expiredHref || link.href],
15430
15616
  allowImagePreview,
15431
- unavailable: isLinkUnavailable(link, unavailableLinkMap)
15617
+ unavailable: isLinkUnavailable(link, unavailableLinkMap),
15618
+ fitLabel: !!fitLabel
15432
15619
  });
15433
15620
  }
15434
15621
  function citationChipsHtml(note) {
@@ -15468,6 +15655,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
15468
15655
  }
15469
15656
  function parseMsgPartsHtml(content, opts) {
15470
15657
  var noPreviews = !!(opts && opts.imagePreviews === false);
15658
+ var fitLinks = !!(opts && opts.fitLinkLabels);
15471
15659
  var placeholderHtml = [];
15472
15660
  var PH = function(idx) {
15473
15661
  return "\uE000BQ" + idx + "\uE001";
@@ -15503,7 +15691,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
15503
15691
  var built = buildLinkPartFromGroups(full, args[0], args[1], args[2], args[3], args[4], args[5]);
15504
15692
  if (!built) return full;
15505
15693
  var allow = previewsLeft > 0;
15506
- var html2 = linkToAnchorHtml(built.part, allow);
15694
+ var html2 = linkToAnchorHtml(built.part, allow, fitLinks);
15507
15695
  if (allow && built.part.image) previewsLeft--;
15508
15696
  return pushPlaceholder(html2) + (built.tail || "");
15509
15697
  });
@@ -15622,14 +15810,15 @@ Index the REMAINING windows - one record per row/item, looking at any page image
15622
15810
  });
15623
15811
  }
15624
15812
  if (xhr.upload && typeof onProgress === "function") xhr.upload.onprogress = onProgress;
15813
+ touch();
15814
+ xhr.send(form);
15625
15815
  if (typeof setAbort === "function") setAbort(function() {
15816
+ clearIdle();
15626
15817
  try {
15627
15818
  xhr.abort();
15628
15819
  } catch (e) {
15629
15820
  }
15630
15821
  });
15631
- touch();
15632
- xhr.send(form);
15633
15822
  });
15634
15823
  }
15635
15824
  function uploadFileToDb(file, storagePath, onProgress, setAbort, checkExistence) {
@@ -16014,6 +16203,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
16014
16203
  remaining -= count;
16015
16204
  changed = true;
16016
16205
  });
16206
+ CS.attachmentCancelNotice = "";
16017
16207
  CS.attachmentCapNotice = dropped > 0 ? "You can attach up to " + MAX_ATTACHMENT_FILE_COUNT + " files per message. " + dropped + " file" + (dropped === 1 ? " was" : "s were") + " not added." : "";
16018
16208
  if (changed) {
16019
16209
  recomputeAttachmentWarning();
@@ -16111,7 +16301,17 @@ Index the REMAINING windows - one record per row/item, looking at any page image
16111
16301
  ids.forEach(function(id) {
16112
16302
  idset[id] = true;
16113
16303
  });
16304
+ var inFlight = inFlightUploadAttachments().filter(function(a) {
16305
+ return idset[a.id];
16306
+ });
16307
+ if (inFlight.length) {
16308
+ cancelAttachmentUploads(inFlight);
16309
+ inFlight.forEach(function(a) {
16310
+ delete idset[a.id];
16311
+ });
16312
+ }
16114
16313
  CS.attachments = CS.attachments.filter(function(a) {
16314
+ if (idset[a.id] && a._batchId && a.status === "uploading") return true;
16115
16315
  if (idset[a.id]) {
16116
16316
  if (a._abort) {
16117
16317
  try {
@@ -16136,6 +16336,10 @@ Index the REMAINING windows - one record per row/item, looking at any page image
16136
16336
  });
16137
16337
  if (i === -1) return;
16138
16338
  var att = CS.attachments[i];
16339
+ if (isInFlightUpload(att)) {
16340
+ cancelAttachmentUploads([att]);
16341
+ return;
16342
+ }
16139
16343
  if (att._abort) {
16140
16344
  try {
16141
16345
  att._abort();
@@ -16149,6 +16353,57 @@ Index the REMAINING windows - one record per row/item, looking at any page image
16149
16353
  updateComposerControls();
16150
16354
  scheduleAttachmentOverflowRecompute();
16151
16355
  }
16356
+ function isInFlightUpload(a) {
16357
+ if (!a || a._cancelled) return false;
16358
+ if (a.kind !== "folder" && a._indexQueued) return false;
16359
+ if (a.status === "uploading") return true;
16360
+ if (a._settledBatch && a._settledBatch === a._batchId) return false;
16361
+ return !!a._batchId && a.status !== "done" && a.status !== "cancelled";
16362
+ }
16363
+ function inFlightUploadAttachments() {
16364
+ return CS.attachments.filter(isInFlightUpload);
16365
+ }
16366
+ function cancelAttachmentUploads(atts) {
16367
+ var cancelled = (atts || []).filter(isInFlightUpload);
16368
+ if (!cancelled.length) return;
16369
+ var ids = {};
16370
+ cancelled.forEach(function(a) {
16371
+ if (!session.cancelAttachmentUpload(a)) a._cancelled = true;
16372
+ ids[a.id] = true;
16373
+ });
16374
+ CS.attachments = CS.attachments.filter(function(a) {
16375
+ return !ids[a.id];
16376
+ });
16377
+ CS.attachmentCancelNotice = uploadCancelNotice(cancelled);
16378
+ CS.attachmentCapNotice = "";
16379
+ CS.visibleAttachmentCount = Infinity;
16380
+ recomputeAttachmentWarning();
16381
+ renderAttachmentChips();
16382
+ updateComposerControls();
16383
+ scheduleAttachmentOverflowRecompute();
16384
+ }
16385
+ function uploadCancelNotice(list) {
16386
+ var names = list.map(function(a) {
16387
+ return a.kind === "folder" ? a.name + "/" : a.name;
16388
+ });
16389
+ var text = list.length === 1 ? "Upload cancelled: " + names[0] + "." : list.length + " uploads cancelled: " + names.slice(0, 3).join(", ") + (names.length > 3 ? " and " + (names.length - 3) + " more." : ".");
16390
+ var queued = 0, stored = 0;
16391
+ list.forEach(function(a) {
16392
+ var q = a._indexQueuedCount || 0;
16393
+ queued += q;
16394
+ var landed = Math.max(0, (a._storedCount || 0) - q);
16395
+ if (!landed && a.status === "uploading" && (a.progress || 0) >= 100) landed = 1;
16396
+ stored += landed;
16397
+ });
16398
+ if (queued) {
16399
+ text += " " + queued + (queued === 1 ? " file had" : " files had") + " already gone to indexing; stop " + (queued === 1 ? "it from its row" : "them from their rows") + " in the chat.";
16400
+ }
16401
+ if (stored) {
16402
+ var subject = list.length === 1 && stored === 1 && !queued ? "Its" : stored === 1 ? "One file's" : stored + " files'";
16403
+ text += " " + subject + " bytes had already been sent, so " + (stored === 1 ? "it" : "they") + " may stay in storage, but " + (stored === 1 ? "it was" : "they were") + " not indexed or added to the chat.";
16404
+ }
16405
+ return text;
16406
+ }
16152
16407
  function clearAttachments() {
16153
16408
  CS.attachments = CS.attachments.filter(function(a) {
16154
16409
  return !!a._batchId;
@@ -16165,6 +16420,8 @@ Index the REMAINING windows - one record per row/item, looking at any page image
16165
16420
  if (a.status !== "error" && a.status !== "indexError") return false;
16166
16421
  a._abort = null;
16167
16422
  delete a._batchId;
16423
+ delete a._indexQueued;
16424
+ delete a._settledBatch;
16168
16425
  return true;
16169
16426
  });
16170
16427
  CS.attachmentCapNotice = "";
@@ -16195,11 +16452,32 @@ Index the REMAINING windows - one record per row/item, looking at any page image
16195
16452
  var row = CS.attachmentsRow;
16196
16453
  if (!row) return;
16197
16454
  row.innerHTML = "";
16198
- if (!CS.attachments.length && !CS.attachmentWarning && !CS.attachmentCapNotice) {
16455
+ if (!CS.attachments.length && !CS.attachmentWarning && !CS.attachmentCapNotice && !CS.attachmentCancelNotice) {
16199
16456
  row.style.display = "none";
16200
16457
  return;
16201
16458
  }
16202
16459
  row.style.display = "";
16460
+ if (CS.attachmentCancelNotice) {
16461
+ var cancelNoticeClose = h("button", {
16462
+ class: "bq-attachment-remove",
16463
+ type: "button",
16464
+ title: "Dismiss",
16465
+ "aria-label": "Dismiss",
16466
+ text: "\xD7"
16467
+ });
16468
+ cancelNoticeClose.addEventListener("click", function(e) {
16469
+ e.stopPropagation();
16470
+ CS.attachmentCancelNotice = "";
16471
+ renderAttachmentChips();
16472
+ scheduleAttachmentOverflowRecompute();
16473
+ });
16474
+ row.appendChild(h(
16475
+ "div",
16476
+ { class: "bq-attachment-warning is-notice", role: "status" },
16477
+ h("span", { text: CS.attachmentCancelNotice }),
16478
+ cancelNoticeClose
16479
+ ));
16480
+ }
16203
16481
  if (CS.attachmentCapNotice) {
16204
16482
  row.appendChild(h("div", { class: "bq-attachment-warning" }, h("span", { text: CS.attachmentCapNotice })));
16205
16483
  }
@@ -16234,7 +16512,20 @@ Index the REMAINING windows - one record per row/item, looking at any page image
16234
16512
  var meta = att.status === "error" ? "(Failed)" : att.status === "indexError" ? "(Error)" : preparing ? "Preparing" : finalizing ? "Finalizing" : att.status === "uploading" ? att.progress + "%" : isFolder ? "(" + (att.files ? att.files.length : 0) + ")" : att.reused ? "already uploaded" : formatBytes(att.file ? att.file.size : att.size);
16235
16513
  chip.appendChild(h("span", { class: "bq-attachment-meta", text: meta }));
16236
16514
  if (clickable) chip.appendChild(h("span", { class: "bq-attachment-arrow", text: "\u2197" }));
16237
- if (att.status !== "uploading" && att.status !== "done") {
16515
+ if (isInFlightUpload(att)) {
16516
+ var cancelBtn = h("button", {
16517
+ class: "bq-attachment-remove",
16518
+ type: "button",
16519
+ title: "Cancel upload",
16520
+ "aria-label": "Cancel upload of " + att.name,
16521
+ text: "\xD7"
16522
+ });
16523
+ cancelBtn.addEventListener("click", function(e) {
16524
+ e.stopPropagation();
16525
+ cancelAttachmentUploads([att]);
16526
+ });
16527
+ chip.appendChild(cancelBtn);
16528
+ } else if (att.status !== "uploading" && att.status !== "done") {
16238
16529
  var rm = h("button", { class: "bq-attachment-remove", type: "button", title: "Remove", text: "\xD7" });
16239
16530
  rm.addEventListener("click", function(e) {
16240
16531
  e.stopPropagation();
@@ -16280,6 +16571,19 @@ Index the REMAINING windows - one record per row/item, looking at any page image
16280
16571
  });
16281
16572
  row.appendChild(removeAll);
16282
16573
  }
16574
+ var inFlight = inFlightUploadAttachments();
16575
+ if (inFlight.length >= 2) {
16576
+ var cancelAll = h("button", {
16577
+ class: "bq-attachment-remove-all",
16578
+ type: "button",
16579
+ title: "Cancel all " + inFlight.length + " uploads"
16580
+ }, "Cancel all uploads \xD7");
16581
+ cancelAll.addEventListener("click", function(e) {
16582
+ e.stopPropagation();
16583
+ cancelAttachmentUploads(inFlightUploadAttachments());
16584
+ });
16585
+ row.appendChild(cancelAll);
16586
+ }
16283
16587
  }
16284
16588
  function uploadsFrozenForUser() {
16285
16589
  if (!S.user) return true;
@@ -16547,7 +16851,9 @@ Index the REMAINING windows - one record per row/item, looking at any page image
16547
16851
  anchor.click();
16548
16852
  return;
16549
16853
  }
16550
- var busy = document.createTextNode(" (fetching...)");
16854
+ var busy = document.createElement("span");
16855
+ busy.className = "bq-link-tail";
16856
+ busy.textContent = " (fetching...)";
16551
16857
  anchor.classList.add("is-refreshing");
16552
16858
  anchor.appendChild(busy);
16553
16859
  var unbusy = function() {
@@ -16856,11 +17162,11 @@ Index the REMAINING windows - one record per row/item, looking at any page image
16856
17162
  return indexGroupVerb(group) + " " + nameLabel;
16857
17163
  }
16858
17164
  function indexGroupCount(group) {
16859
- if (group.stub) return "";
17165
+ if (group.stub) return indexGroupDurationLabel(group);
16860
17166
  var prog = group.status === "active" && session && session.pageProgressFor ? session.pageProgressFor(group.path || group.key, group.name) : null;
16861
17167
  var pages = prog ? prog.total ? prog.saved + " of " + prog.total + " pages" : prog.saved + " pages" : "";
16862
17168
  var passes = group.passCount <= 1 && !group.mayHaveOlder ? "" : group.passCount + (group.mayHaveOlder ? "+" : "") + " passes";
16863
- return [pages, passes].filter(Boolean).join(" \xB7 ");
17169
+ return [pages, passes, indexGroupDurationLabel(group)].filter(Boolean).join(" \xB7 ");
16864
17170
  }
16865
17171
  var markerSweep = { svc: "", at: 0, gen: 0, done: {}, runs: {}, partial: false, inflight: null };
16866
17172
  var MARKER_SWEEP_TTL_MS = 3e4;
@@ -17241,7 +17547,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
17241
17547
  var label = h(
17242
17548
  "span",
17243
17549
  { class: "bq-index-label" },
17244
- h("span", { class: "bq-md", html: parseMsgPartsHtml(indexGroupLabel(group), { imagePreviews: false }) })
17550
+ h("span", { class: "bq-md", html: parseMsgPartsHtml(indexGroupLabel(group), { imagePreviews: false, fitLinkLabels: true }) })
17245
17551
  );
17246
17552
  label.addEventListener("click", function(e) {
17247
17553
  if (e.target && e.target.closest && e.target.closest("a")) e.stopPropagation();
@@ -17606,6 +17912,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
17606
17912
  CS.uploadingAttachments = false;
17607
17913
  CS.attachmentWarning = "";
17608
17914
  CS.attachmentCapNotice = "";
17915
+ CS.attachmentCancelNotice = "";
17609
17916
  CS.attachmentsRow = null;
17610
17917
  CS.attachBtnEl = null;
17611
17918
  CS.sendBtnEl = null;