bunnyquery 1.21.7 → 1.21.13

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.
@@ -97,6 +97,7 @@ export type ProjectSettingsData = {
97
97
  chat_greeting?: unknown;
98
98
  web_access?: unknown;
99
99
  skip_duplicate_files?: unknown;
100
+ share_identical_files?: unknown;
100
101
  answer_mode?: unknown;
101
102
  [key: string]: unknown;
102
103
  };
@@ -161,6 +162,34 @@ export function skipDuplicateFilesFrom(data: ProjectSettingsData | null | undefi
161
162
  return data ? normalizeSkipDuplicateFiles(data.skip_duplicate_files) : DEFAULT_SKIP_DUPLICATE_FILES;
162
163
  }
163
164
 
165
+ /**
166
+ * Whether files with the same CONTENT share one index (owner, 2026-11-26). Same record,
167
+ * its own `share_identical_files` key. Not the skip above, which is about one uploader's
168
+ * same-named file: this compares stored bytes, whoever uploaded them and whatever they are
169
+ * called. The first such file is indexed as usual (the original); every later one is
170
+ * LINKED to it on the server with no AI call (the MCP's content-dedup.js), and search,
171
+ * outlines and totals count the content once.
172
+ *
173
+ * ON BY DEFAULT, for the same reason as skip_duplicate_files: a second index of the same
174
+ * bytes costs a second AI run and doubles every row. Only the literal `false` turns it
175
+ * off. The clients send `share_identical: true` on a run's FIRST pass while it is on
176
+ * (requests.ts notifyAgentSaveAttachment), and the MCP reads this key again before it
177
+ * links anything, so a client holding an old copy of the settings cannot link against
178
+ * the owner's choice.
179
+ */
180
+ export const SHARE_IDENTICAL_FILES_KEY = 'share_identical_files';
181
+ export const DEFAULT_SHARE_IDENTICAL_FILES = true;
182
+
183
+ /** Narrow a stored value to the switch: only the literal `false` is off. */
184
+ export function normalizeShareIdenticalFiles(value: any): boolean {
185
+ return value !== false;
186
+ }
187
+
188
+ /** The switch held in a settings-record `data`, true when unset. */
189
+ export function shareIdenticalFilesFrom(data: ProjectSettingsData | null | undefined): boolean {
190
+ return data ? normalizeShareIdenticalFiles(data.share_identical_files) : DEFAULT_SHARE_IDENTICAL_FILES;
191
+ }
192
+
164
193
  /**
165
194
  * How much the model thinks before a CHAT answer. Same record, its own
166
195
  * `answer_mode` key. Optional, and absent on almost every project.
@@ -456,6 +485,14 @@ export function projectSkipDuplicateFiles(service: string): boolean {
456
485
  return skipDuplicateFilesFrom(cachedProjectSettings(service));
457
486
  }
458
487
 
488
+ /**
489
+ * Sync convenience: the project's share-identical-files setting, true until the fetch
490
+ * settles or when the project never set it (the MCP checks the stored value again).
491
+ */
492
+ export function projectShareIdenticalFiles(service: string): boolean {
493
+ return shareIdenticalFilesFrom(cachedProjectSettings(service));
494
+ }
495
+
459
496
  /**
460
497
  * Sync convenience: the project's answer mode, 'standard' until the fetch
461
498
  * settles or when the project never set it. The request builders use the
@@ -109,10 +109,11 @@ export function buildChatSystemPrompt(params: ChatSystemPromptParams): string {
109
109
  : `re-indexing that file (attach the same file again and choose to reindex it)`;
110
110
  const groundingRules =
111
111
  `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.
112
- 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
112
+ FILES IN ANOTHER LANGUAGE. The files may be written in another language than the question (a Russian or English manual asked about in Korean). When searches in the question's language find nothing, or searchText reports query_language_mismatch, search again with the question's key terms translated into the language the files are written in (their names, titles and earlier hits show it): one or two short queries of the main terms (e.g. "oil leak", "gearbox"), before concluding anything.
113
+ WHEN THE DATA DOES NOT HAVE IT, SAY SO. Once you have searched the way these rules require (in the files' language too) 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
113
114
  ? `another name or file to look under, or asking the project's owner to add it`
114
115
  : `the document to upload, or another name or file to look under`}.
115
- 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.
116
+ A CODE, NUMBER OR EXACT QUOTE THAT searchText DID NOT FIND (an identifier or a quote, not a topic or how-to question, which follows FILES IN ANOTHER LANGUAGE first): 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 ONLY when the value could be a spreadsheet cell or a row, and then with ONE filtered getRecords on that value, never by paging through a whole table), keep the answer short. The text read from photos, scans and other images IS in the page text searchText covered, so a code, serial or phrase asked about a photo needs no records read: 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.
116
117
  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.
117
118
  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.`;
118
119
 
@@ -197,6 +198,7 @@ NUMBERS FROM A SPREADSHEET are computed from the ROWS, never from one page and n
197
198
  ${documentRules}
198
199
  ${accessGroupRule}
199
200
  COMPLETE ANSWERS: ONE file is routinely SPLIT ACROSS SEVERAL TABLES (a summary row in one, its page or row content in another, its extracted pictures in "__MEDIA__"), so for anything not scoped to a single file run the query in EVERY table that could hold the answer and combine the results. For any request that counts, sums, totals, lists every match, compares across records, finds which one, or asks whether something is present or ABSENT (for example "how many", "total spent", "which card", "is there any", "없어?", "하나도 없나?"), read the COMPLETE matching set across every such table and file before answering. Never assert absence ("there is no X", "none", "not found", "아니요, 없습니다") until a complete scan has come back empty: a confident "no" that later turns out wrong is worse than telling the user you are still checking. If you answered from one table and then find another holds more, re-run the sweep and give the complete answer instead of only apologising.
201
+ LINKED COPIES: files with the same content are indexed once. A file a tool reports as a linked copy (linked_copy, or listed in a hit's also_at) has no rows or pages of its own: its content is the original's, stored and tagged under the original's name. Cite the original file and say that the copy is the same file; never count the two as two documents.
200
202
  Embedded values: a search term is often stored inside a larger string (a merchant "BAKSA" as "DNH*BAKSA#4070277042", a card as "5860****5173"), which no index or tag filter matches. When the value may be embedded, fetch the full set with fetch_all and match the substring yourself.
201
203
  File attachments: an "Attached files:" section with markdown links in a user message points at short-lived signed URLs in this project's storage. Image files (.jpg, .jpeg, .png, .gif, .webp) are ALREADY in the message as image blocks: look at them directly. Every other attached file (office documents such as .docx/.xlsx/.pptx/.hwp/.hwpx/.ods, PDFs, email (.eml), text/data/code files such as .csv/.tsv/.json/.xml/.txt/.md) is ALREADY INDEXED: it was read end to end when it was uploaded, before this message reached you, so answer from its records (reference "src::<the storage path from the attachment link>"), and for its exact wording use searchText or readFileContent on that same path (see DOCUMENTS). Some turns instead carry the file text between "BEGIN FILE CONTENT" / "END FILE CONTENT" markers: read that block directly; a "[skapi: ...]" note inside it means that file could not be extracted. ${webAccess
202
204
  ? `Never web_fetch an attachment link (the picture is already in the message, everything else is in the database); a file the user gives as an outside web address may be fetched under the web rule above.`
@@ -15,7 +15,7 @@
15
15
  import { buildIndexingSystemPrompt, buildIndexingUserMessage, buildIndexingContinueMessage, buildIndexingRenderMessage, buildIndexingRenderContinueTemplate, buildIndexingWindowMessage } from './prompts';
16
16
  import { isServerExtractable, isPagedReadFile, isImageVisionFile, isWindowedReadFile, makeExtractPlaceholder, makeRenderPlaceholder, makeWindowPlaceholder, RENDER_PAGES_PER_WINDOW, type ExtractDirective, type FileUrlDirective } from './office';
17
17
  import { chatEngineConfig, resolveForwardRequest, resolveForwardRequestHistory, pollOpt, windowedIndexingEnabled, liveStreamingEnabled, liveStreamingSocketEnabled, resolveWebAccess, resolveAnswerMode, statusPushEnabled } from './config';
18
- import { type AnswerMode } from './project_settings';
18
+ import { type AnswerMode, projectShareIdenticalFiles } from './project_settings';
19
19
  import { csrEnvelopeError } from './errors';
20
20
  import type { ChatIdentity } from './host';
21
21
  // Output sizing lives in budget.ts so the request cap and the reserve the input
@@ -100,7 +100,7 @@ const mcpUrl = () => chatEngineConfig().mcpBaseUrl;
100
100
  * Append query parameters to an MCP endpoint, preserving any the base already carries.
101
101
  *
102
102
  * An explicit path before the query. The configured base has no trailing slash
103
- * ("https://mcp-dev.broadwayinc.computer"), and appending "?profile=index" straight onto an
103
+ * ("https://mcp.broadwayinc.computer"), and appending "?profile=index" straight onto an
104
104
  * authority with no path yields a URL that is legal but that intermediaries and clients
105
105
  * normalise inconsistently. "/?profile=index" is unambiguous everywhere.
106
106
  *
@@ -1246,6 +1246,13 @@ export type AttachmentSaveInfo = {
1246
1246
  * as image blocks; the resume loop advances this by a window each pass.
1247
1247
  */
1248
1248
  renderFrom?: number;
1249
+ /**
1250
+ * One shared index for identical files: whether this FIRST pass may be linked to an
1251
+ * already indexed file with the same bytes (the worker then runs no AI for it).
1252
+ * Omitted: the project's `share_identical_files` setting decides (on unless the owner
1253
+ * turned it off). `false` never asks. Never sent on a continue pass.
1254
+ */
1255
+ shareIdentical?: boolean;
1249
1256
  };
1250
1257
 
1251
1258
  // RESUME pass: continue indexing a large file a previous pass could not finish. Same
@@ -1426,12 +1433,20 @@ export async function notifyAgentSaveAttachment(info: AttachmentSaveInfo) {
1426
1433
  const fileUrlDetail = imageFile && platform === 'openai'
1427
1434
  ? getOpenAIImageDetail(info.model || DEFAULT_OPENAI_MODEL)
1428
1435
  : undefined;
1436
+ // ONE SHARED INDEX FOR IDENTICAL FILES (owner, 2026-11-26): on a run's FIRST pass only,
1437
+ // and only while the project's switch is on, the entry asks the worker to link this file
1438
+ // to an already indexed file with the same stored bytes instead of reading it (no AI
1439
+ // call; the MCP's content-dedup.js decides and writes the markers). A continue pass never
1440
+ // carries it, and the worker ignores it there anyway. An older worker ignores the key.
1441
+ const shareIdentical = !continuing && info.shareIdentical !== false
1442
+ && (info.shareIdentical === true || projectShareIdenticalFiles(service));
1429
1443
  const skapiFileUrls = attachment.url && attachment.storagePath
1430
1444
  ? {
1431
1445
  _skapi_file_urls: [{
1432
1446
  path: attachment.storagePath, url: attachment.url,
1433
1447
  ...(singlePass ? { index_end: true } : {}),
1434
1448
  ...(fileUrlDetail ? { detail: fileUrlDetail } : {}),
1449
+ ...(shareIdentical ? { share_identical: true } : {}),
1435
1450
  }],
1436
1451
  }
1437
1452
  : {};
@@ -1594,7 +1609,27 @@ export async function notifyAgentSaveAttachment(info: AttachmentSaveInfo) {
1594
1609
  }));
1595
1610
  }
1596
1611
 
1612
+ /**
1613
+ * A provider answer that arrives as its JSON TEXT, read as the document it is. The worker
1614
+ * stores the answer it writes itself (a linked copy's "Same content as ...", identical.ts
1615
+ * parseLinkedReply) as a JSON string, and a status read hands that body back unparsed, so
1616
+ * the live row read no text from it until a reload brought the server's response_text.
1617
+ * Anything else is handed back as it came.
1618
+ */
1619
+ export function providerDocument(response: any): any {
1620
+ if (typeof response !== 'string') return response;
1621
+ var t = response.trim();
1622
+ if (t.charAt(0) !== '{' || t.charAt(t.length - 1) !== '}') return response;
1623
+ try {
1624
+ var doc = JSON.parse(t);
1625
+ return doc && typeof doc === 'object' && !Array.isArray(doc) ? doc : response;
1626
+ } catch (e) {
1627
+ return response;
1628
+ }
1629
+ }
1630
+
1597
1631
  export function extractClaudeText(response: any) {
1632
+ response = providerDocument(response);
1598
1633
  if (!Array.isArray(response?.content)) {
1599
1634
  return '';
1600
1635
  }
@@ -1606,6 +1641,7 @@ export function extractClaudeText(response: any) {
1606
1641
  }
1607
1642
 
1608
1643
  export function extractOpenAIText(response: any) {
1644
+ response = providerDocument(response);
1609
1645
  if (
1610
1646
  typeof response?.output_text === 'string' &&
1611
1647
  response.output_text.length
@@ -61,6 +61,7 @@ import { markImagePreviewStale } from './image_preview';
61
61
  import { chatCacheKey, indexScopeKey, mapHistoryListToMessages, extractLastUserTextFromRequest, listedRequestText, isIndexingRequestText, parseIndexingRequestText, probeBgQueue, BG_PROBE_TTL_MS, fetchLiveIndexingKeys, getSplitChatHistory, shouldRescueInFlightMessage, adoptLocalAnswerIntoPage, adoptLiveTextIntoRunningRow } from './history';
62
62
  import { wallClockNow, requestIdTimeMs, messageTimeMs } from './time';
63
63
  import { parseAttachmentContent } from './attachment_parsers';
64
+ import { copiesToPromote } from './identical';
64
65
  import type { ChatHost, ChatState, ChatMessage, ChatIdentity, PinnedDispatchContext, IndexQueueSnapshot } from './host';
65
66
  import type { IndexingGroup } from './indexing_groups';
66
67
 
@@ -1232,6 +1233,42 @@ export class ChatSession {
1232
1233
  return chain.then(function () { self.drainBgTaskQueue(); return queued; });
1233
1234
  }
1234
1235
 
1236
+ /**
1237
+ * ONE SHARED INDEX FOR IDENTICAL FILES: the linked copies that lose their original when
1238
+ * `removed` files (or every file under `folders`) go away, per original, oldest first
1239
+ * (identical.ts copiesToPromote). Read through host.findLinkedCopies, fresh, and it has
1240
+ * to be read BEFORE the delete or reset: those remove nothing from the copies' markers,
1241
+ * but a later sweep could no longer tell whose copies they were once a new original
1242
+ * exists. Never rejects; [] without the hook or on any failure.
1243
+ */
1244
+ collectLinkedCopies(removed: string[], folders?: string[]): Promise<{ original: string; copies: string[] }[]> {
1245
+ if (typeof this.host.findLinkedCopies !== 'function') return Promise.resolve([]);
1246
+ // only copies this user may re-index: their own, or every copy for the project owner
1247
+ var id = this.host.getIdentity();
1248
+ var actor = { userId: id && !id.anonymous ? id.userId : null, isProjectOwner: !!(id && !id.anonymous && id.owner && id.userId === id.owner) };
1249
+ return Promise.resolve(this.host.findLinkedCopies())
1250
+ .then(function (map) { return map ? copiesToPromote(map, removed || [], folders, actor) : []; })
1251
+ .catch(function () { return []; });
1252
+ }
1253
+
1254
+ /**
1255
+ * Send the copies of a removed or overwritten original again (owner decision
1256
+ * 2026-11-26): each list's oldest copy first, so its first pass claims the content and
1257
+ * is indexed for real (one AI run), then the others, which link to it with no AI call.
1258
+ * The share flag rides on every first pass while the project's switch is on (requests.ts
1259
+ * notifyAgentSaveAttachment). Through reindexStoredFiles, so each copy keeps its access
1260
+ * group and shows as a "Reindexing" row. Resolves to the number of files queued.
1261
+ */
1262
+ promoteLinkedCopies(plan: { original: string; copies: string[] }[]): Promise<number> {
1263
+ var list: Array<{ storagePath: string }> = [];
1264
+ (plan || []).forEach(function (g) {
1265
+ (g && g.copies || []).forEach(function (c) { if (c) list.push({ storagePath: c }); });
1266
+ });
1267
+ if (!list.length) return Promise.resolve(0);
1268
+ console.log('[chat-engine] identical files: sending ' + list.length + ' linked cop' + (list.length === 1 ? 'y' : 'ies') + ' again, their original is gone:', plan);
1269
+ return this.reindexStoredFiles(list);
1270
+ }
1271
+
1235
1272
  /**
1236
1273
  * The same question, asked of the SERVER when this page cannot answer it.
1237
1274
  *
@@ -9309,6 +9346,12 @@ export class ChatSession {
9309
9346
  // clean. `_cancelled` is NOT reset: a cancelled chip leaves the list and is
9310
9347
  // never retried, and a cancel that raced the start must still stop it.
9311
9348
  att._storedCount = 0; att._indexQueuedCount = 0; att._indexQueued = false;
9349
+ // The storage paths of NEW files (uploaded with the existence check, so no file was
9350
+ // there before) whose bytes reached storage, or may have (the abort came after the
9351
+ // whole body was sent), and whose indexing request has not gone out. A cancel hands
9352
+ // them to the host (att._onCancelSettled) so it can take the stored bytes back. A
9353
+ // replaced file (Overwrite) is never listed: removing it would lose the user's file.
9354
+ att._landedNew = [];
9312
9355
  var cancelError = function (): Error {
9313
9356
  var e: any = new Error(UPLOAD_CANCELLED_MESSAGE);
9314
9357
  e.code = 'CANCELLED';
@@ -9343,6 +9386,9 @@ export class ChatSession {
9343
9386
  checkCancel();
9344
9387
  var hadExists = false;
9345
9388
  var skipped = false;
9389
+ // Overwrite of an original: its linked copies, read before the reset and
9390
+ // sent again once this member is queued (collectLinkedCopies).
9391
+ var promotion: Promise<{ original: string; copies: string[] }[]> | null = null;
9346
9392
  // The storage path of the file this member DUPLICATES, when the user
9347
9393
  // already has it here: nothing is uploaded or indexed for it, and the
9348
9394
  // turn takes the stored copy's url instead.
@@ -9357,7 +9403,11 @@ export class ChatSession {
9357
9403
  // mint, or the step before the indexing request): a cancel that lands
9358
9404
  // after it drops that record again.
9359
9405
  var madeRecord = false;
9406
+ // Every byte of this member's body was handed to the network: an abort after
9407
+ // this point may come too late to keep the object out of storage.
9408
+ var sentAll = false;
9360
9409
  var onProg = function (p: any) {
9410
+ if (p && p.total && p.loaded >= p.total) sentAll = true;
9361
9411
  if (p && p.total) {
9362
9412
  att.progress = Math.floor(((idx + p.loaded / p.total) / total) * 100);
9363
9413
  self.host.renderAttachmentChips();
@@ -9366,6 +9416,7 @@ export class ChatSession {
9366
9416
  var doMemberUpload = function (checkExistence: boolean) {
9367
9417
  // Cancelled during the EXISTS prompt or between members: no bytes.
9368
9418
  checkCancel();
9419
+ sentAll = false;
9369
9420
  return self.host.uploadFile({
9370
9421
  file: member.file, storagePath: member.storagePath, checkExistence: checkExistence,
9371
9422
  onProgress: onProg,
@@ -9380,12 +9431,16 @@ export class ChatSession {
9380
9431
  }).then(function (r: any) {
9381
9432
  att._abort = null;
9382
9433
  att._storedCount = (att._storedCount || 0) + 1;
9434
+ if (checkExistence) att._landedNew.push(member.storagePath);
9383
9435
  return r;
9384
9436
  }, function (err: any) {
9385
9437
  att._abort = null;
9386
9438
  // An abort the user asked for reads as the cancel it is, not as
9387
9439
  // a failed upload.
9388
- if (att._cancelled) throw cancelError();
9440
+ if (att._cancelled) {
9441
+ if (checkExistence && sentAll) att._landedNew.push(member.storagePath);
9442
+ throw cancelError();
9443
+ }
9389
9444
  throw err;
9390
9445
  });
9391
9446
  };
@@ -9406,6 +9461,10 @@ export class ChatSession {
9406
9461
  return self.host.promptOverwrite(member.file.name).then(function (choice) {
9407
9462
  if (choice === 'overwrite') {
9408
9463
  existedBefore = true;
9464
+ // One shared index for identical files: if this file is an ORIGINAL,
9465
+ // its linked copies lose their index with its old bytes. Read now,
9466
+ // before the reset; sent again once this file is queued.
9467
+ promotion = self.collectLinkedCopies([member.storagePath]);
9409
9468
  // The bytes at this path are about to change while the
9410
9469
  // path itself does not, so the browser-cached mint for
9411
9470
  // it would keep handing back the old signed url and the
@@ -9581,6 +9640,8 @@ export class ChatSession {
9581
9640
  // the view so it stops offering a cancel it cannot honour.
9582
9641
  att._indexQueuedCount = (att._indexQueuedCount || 0) + 1;
9583
9642
  if (att.kind !== 'folder') att._indexQueued = true;
9643
+ // Queued for indexing: no longer a cancelled upload to take back.
9644
+ att._landedNew = (att._landedNew || []).filter(function (p: string) { return p !== member.storagePath; });
9584
9645
  self.host.renderAttachmentChips();
9585
9646
  // Tracked so a chat waiting on awaitIndexingDrained cannot be sent
9586
9647
  // in the window between this call and the queue accepting it.
@@ -9619,6 +9680,12 @@ export class ChatSession {
9619
9680
  // Followed with or without a chat view (the drain needs one).
9620
9681
  self.noteBgQueueChanged();
9621
9682
  self.drainBgTaskQueue(); // surface "Indexing: <file>" as soon as THIS file uploads
9683
+ // an overwritten original's copies, after the file itself
9684
+ if (promotion) {
9685
+ var plan = promotion;
9686
+ promotion = null;
9687
+ plan.then(function (pl) { return self.promoteLinkedCopies(pl); }).catch(function () { });
9688
+ }
9622
9689
  }
9623
9690
  }, function (e: any) {
9624
9691
  console.error('[chat-engine] indexing request failed', e);
@@ -9699,6 +9766,12 @@ export class ChatSession {
9699
9766
  att.status = 'cancelled';
9700
9767
  att._abort = null;
9701
9768
  self.host.renderAttachmentChips();
9769
+ // The chip's upload has fully stopped: tell the host which new
9770
+ // files' bytes reached storage (or may have) so it can take them
9771
+ // back. Set by the host when it cancelled; optional.
9772
+ if (typeof att._onCancelSettled === 'function') {
9773
+ try { att._onCancelSettled((att._landedNew || []).slice()); } catch (e) { }
9774
+ }
9702
9775
  return;
9703
9776
  }
9704
9777
  if (removed || aborted) return;