feat(ui): attach large text pastes as virtual files
Offer to turn sufficiently large plain-text clipboard pastes into pasted-context-N.txt attachments instead of inserting them into the composer, with ask/attach/inline composer settings. Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>
This commit is contained in:
co-authored by
Serhii Dziupin
parent
f47110c66f
commit
ef11ab5b14
@@ -144,6 +144,20 @@ export const assignImageAttachmentFilenames = (
|
||||
});
|
||||
};
|
||||
|
||||
/** Next unused `pasted-context-N.txt` name for a large text paste attachment. */
|
||||
export const nextPastedContextFilename = (existingFilenames: string[]): string => {
|
||||
const used = new Set(existingFilenames.map(normalizeFilenameKey));
|
||||
|
||||
for (let index = 1; index < Number.MAX_SAFE_INTEGER; index += 1) {
|
||||
const candidate = `pasted-context-${index}.txt`;
|
||||
if (!used.has(normalizeFilenameKey(candidate))) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
return `pasted-context-${Date.now()}.txt`;
|
||||
};
|
||||
|
||||
export const buildAttachmentCitationText = (filenames: string[]): string => (
|
||||
filenames.map((filename) => `[${filename}]`).join(' ')
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user