Commit Graph
3 Commits
Author SHA1 Message Date
yetone f1421352d2 chat: the epub reader test retries a slow browser start instead of one 15s race (#684)
Cause: the test raced one cold browser launch against a fixed 15s timer.
A passing CI run takes 1.3-1.5s (runs 41710048801, 41709930999, 41689486507);
run 41718344236 took 16.6s, so a cold runner start, not the reader, failed the
test and blocked every package's publish.

Now each try gets its own profile and 10s (7x a normal run); a try that posts
nothing is killed and replaced, up to 3 tries, with the test timeout at 60s. A
browser that exits by itself still fails at once. The test only; no package
file changes, so no version bump (chat's "files" omit tests).

Run on mote (bun 1.4.2, Playwright's Chromium 1234):
- Injected a wrapper browser that sleeps 25s on its first launch: the old test
  fails "browser timed out" at 15.06s, the new one passes in 11.7s.
- Normal launch: new test passes in 2.0s.
- Whole suite: 5349 pass, 19 skip, 0 fail (the browser test skips without a
  browser in PATH; it was run separately as above). bun scripts/check.mjs ok.
Not tried: GitHub's runner itself; CI's run is the check.
2026-11-04 07:23:16 +08:00
ninon 85a6fd5485 chat 0.1.11: attachments reach the model, saves serialized, tool history by round (#645)
By ninondev (#645). Squashed at the reviewed head 764fbfc.

Changes in packages/chat, 0.1.10 -> 0.1.11:
- Attachments reach the model:
  - A .md, .markdown or .txt file, or any text/* file, is sent as UTF-8 text in a 【文档:name】 block. Bad bytes are an error, not mojibake.
  - An image's data URL gets its real MIME type, even when the browser said application/octet-stream or gave no type.
  - Send waits for every upload still in progress, not only the books.
  - A failed upload is dropped with a toast. It no longer goes in as a local copy that skipped the size caps.
- Conversation saves:
  - Writes are serialized per conversation id. Once a delete has gone through, any write still queued is skipped.
  - A new conversation gets its id on the client up front. A save that finishes after the user has switched conversations no longer takes over the open one.
  - Opening one conversation and then another quickly no longer shows the first.
- Tool history:
  - The server sends a "round" event each turn of the tool loop, and the history is replayed round by round.
  - Tool-call ids are unique across rounds (call_<round>_<i>).
  - Each tool result is capped at 60000 chars, the same in the stream and in the history.
  - A stop is checked before each tool call and after the MCP read.
  - A connection-error card is not replayed to the model.
- epub-reader.test.mjs launches Chromium with --use-mock-keychain.

Run at 764fbfc on mote (macOS), each with HOME=$(mktemp -d):
- `bun test` (whole repo): 4857 pass, 14 skip, 0 fail, across 370 files.
- `bun test packages/chat`: 68 pass, 1 skip, 0 fail.
- `bun scripts/check.mjs`: exits 0.
- The epub browser test with EPUB_TEST_BROWSER set to Playwright's Chromium: 2 of 2 pass.
- A review-only end-to-end run (not committed) in Playwright Chromium and WebKit 1.62, at a 1100px width, with the real chat server and a fake gateway:
  - It attaches scene.md (no MIME type) and photo.png (application/octet-stream), types a question and sends.
  - It checks that the gateway got the markdown text, an image/png data URL and the typed text.
  - It reloads, reopens the conversation from the sidebar and asks a follow-up. The history still has the markdown and the image, and there is exactly one saved conversation.
  - All checks pass in both engines. With origin/main's packages/chat the same run fails 8 checks: the markdown and the image never reach the gateway.

Broken by hand:
- Without the per-round tool-call id dedupe, "tool history preserves round order ... repeated IDs" goes red.
- With only the first throwIfAborted removed, the stop tests stay green, because the second check covers it.

Read for harm: no new hosts, no credential or keychain access, no dependencies.
Not tried: a real model or real MCP servers behind magpie's gateway.
2026-11-03 02:45:17 +08:00
ninon 63cd0e4bf9 chat: send an EPUB's text with chat messages (#621, ninondev)
Chat (page-chat 0.1.8 -> 0.1.9) can send an EPUB's text with a message. The book is read in the page (chat/epub-reader.js: its own ZIP reader with size, CRC and encryption checks, DecompressionStream inflate, chapters parsed inert in spine order, no external resource loaded, no script run), never uploaded. Each request to the gateway inlines the text once in the user message that carried it, between 【电子书:name】 and 【电子书结束】; the same book again is a note, a failed read is a note and a toast. Send waits while a book is read, and switching chats drops a book still being read. Image-only user messages now stay in history.

Run at 1cb1ecb400fe31bbc1f58463af09af757374d27e:
- CI (pr.yml, ubuntu): HOME=$(mktemp -d) bun test and bun scripts/check.mjs green; the spawned-Chrome reader test ran and passed there (10.5s).
- mote: packages/chat bun test 34 pass; the reader test's own Chrome spawn gets no page load over ssh on macOS (and in WSL), so its fixtures were run again through Playwright 1.62 Chromium and WebKit: 2 pass, 21 expects, each engine.
- End to end on mote, Chromium and WebKit, 420px: startServer with a sandbox config and HOME, a fake gateway, the real page; attached Project Gutenberg's Alice (132,120 chars) and 紅樓夢 (876,576 chars) EPUBs, sent, then followed up. Each gateway request carried the book once, before the question, with no base64 or EPUB data; the follow-up carried user,assistant,user with the book once. The page made no request outside its own service.

Not changed: the MCP tool pick still scores the last message, which on a book's first message is the whole book (filed as #623).
2026-11-02 16:01:29 +08:00