feat: fetch for the assistant with Поиск on - a page's main text for the model, the server's own network out of reach; shorter words in Настройки and the chat; the + menu's roots a step left. Also files from panes into the chat, docview and drag fixes (by the user)

This commit is contained in:
redtea committed 2026-10-16 17:32:52 +03:00
1 parent 84b42c5369
commit ae8fffe7d8
17 files changed
+712 -102

No files matched your search

@@ -0,0 +1,32 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const vm = require('node:vm');
const zlib = require('node:zlib');
const runtime = {window: {}, Blob, Response, DecompressionStream, TextDecoder, Uint8Array};
vm.createContext(runtime);
vm.runInContext(fs.readFileSync(path.join(__dirname, 'docview.js'), 'utf8'), runtime);
function pdfWithStream(content, compressed = false) {
const stream = compressed ? zlib.deflateSync(Buffer.from(content, 'latin1')) : Buffer.from(content, 'latin1');
const filter = compressed ? ' /Filter /FlateDecode' : '';
const prefix = `%PDF-1.4\n1 0 obj\n<< /Length ${stream.length}${filter} >>\nstream\n`;
return Buffer.concat([Buffer.from(prefix, 'latin1'), stream, Buffer.from('\nendstream\nendobj\n%%EOF', 'latin1')]);
}
test('PDF text extraction handles literal strings and escaped parentheses', async () => {
const pdf = pdfWithStream('BT /F1 12 Tf 72 700 Td (Hello \\(PDF\\)) Tj ET');
assert.equal(await runtime.window.DocView.pdf(pdf), 'Hello (PDF)');
});
test('PDF text extraction inflates streams and keeps TJ word spacing', async () => {
const pdf = pdfWithStream('BT /F1 12 Tf [(lightweight) -250 ( parser)] TJ ET', true);
assert.equal(await runtime.window.DocView.pdf(pdf), 'lightweight parser');
});
test('PDF text extraction reports scanned or non-text PDFs without OCR', async () => {
const pdf = pdfWithStream('q 0 0 100 100 re f Q');
await assert.rejects(runtime.window.DocView.pdf(pdf), /без OCR/);
});