Files
DeepTutor/web/lib
Bingxi Zhao (Frank) 895d2cce25 fix(web): stop the copy button reporting a success that never happened
The button inferred success from its handler's promise *resolving*, and the
handler it was given could not fail: `copyAssistantMessage` awaited
`navigator.clipboard.writeText` inside a try/catch that logged and swallowed.
So the only failure signal was destroyed one frame before the only code that
could have used it — and every clipboard failure rendered 已复制 with a
checkmark. Because the label is also the `aria-label` on an `aria-live`
element, the false success was announced to screen readers.

The failure is not exotic. `launcher.py` binds the web app to 0.0.0.0 while
printing a localhost URL, so opening the same instance from another machine
on the LAN is an ordinary way to run DeepTutor — and on that plain-http
origin `navigator.clipboard` does not exist, so reading `.writeText` throws
synchronously. `FilePreviewDrawer` already carried a comment naming this
exact cause; the handling was local instead of shared.

So: one `copyText` helper that rejects when the text did not reach the
clipboard, with a selection-based fallback for insecure origins (probed
before any await, since `execCommand` needs the click's user activation);
`CopyActionButton` narrowed to a `Promise<void>` handler and given a real
failure state, so the contract cannot be reintroduced by the next consumer;
and the three consumers plus the two other optimistic sites moved onto it.

`Promise.resolve().then(() => onCopy(...))` replaces
`Promise.resolve(onCopy(...))` because the latter runs the handler outside
the chain, which is where the synchronous TypeError was escaping.

Also adds the `attachments` and `references` locale keys. Both call sites
pass a lowercase noun for inline reading, neither key existed, and i18next is
configured to return a missing key verbatim — which is why a Chinese UI
rendered "5 attachments" in English next to this very button.
2026-09-08 00:22:08 +08:00
..
2026-09-02 04:09:11 +08:00
2026-09-06 13:46:29 +08:00
2026-09-03 01:38:54 +08:00
2026-09-02 04:09:11 +08:00
2026-09-03 01:38:54 +08:00
2026-09-03 01:38:54 +08:00
2026-09-03 01:38:54 +08:00
2026-09-03 01:38:54 +08:00
2026-05-02 20:16:07 +08:00
2026-09-03 01:38:54 +08:00
2026-09-02 04:09:11 +08:00
2026-08-02 13:23:45 +08:00
2026-08-02 13:23:45 +08:00
2026-08-02 13:23:45 +08:00
2026-06-13 21:10:57 +08:00
2026-09-03 01:38:54 +08:00
2026-09-03 01:38:54 +08:00
2026-05-01 01:39:08 +08:00
2026-08-17 11:22:26 +08:00
2026-09-03 01:38:54 +08:00
2026-09-06 13:46:29 +08:00
2026-08-17 11:22:26 +08:00
2026-09-06 13:46:29 +08:00
2026-09-06 13:46:29 +08:00
2026-09-06 13:46:29 +08:00
2026-09-06 13:46:29 +08:00
2026-09-03 01:38:54 +08:00
2026-09-02 04:09:11 +08:00
2026-08-02 13:23:45 +08:00
2026-07-31 00:25:48 +08:00
2026-04-30 23:41:58 +08:00
2026-09-02 04:09:11 +08:00
2026-09-06 13:46:29 +08:00
2026-09-02 04:09:11 +08:00
2026-09-02 04:09:11 +08:00
2026-08-20 14:15:53 +08:00
2026-09-06 13:46:29 +08:00
2026-09-02 04:09:11 +08:00
2026-09-02 04:09:11 +08:00
2026-09-06 13:46:29 +08:00
2026-09-06 13:46:29 +08:00
2026-09-06 13:46:29 +08:00
2026-09-03 01:38:54 +08:00
2026-08-20 14:15:53 +08:00
2026-09-06 13:46:29 +08:00
2026-08-20 14:15:53 +08:00
2026-09-06 13:46:29 +08:00
2026-08-17 11:22:26 +08:00
2026-09-03 01:38:54 +08:00
2026-04-23 19:29:16 +08:00
2026-09-06 13:46:29 +08:00
2026-09-06 13:46:29 +08:00
2026-09-03 01:38:54 +08:00
2026-09-03 01:38:54 +08:00
2026-09-03 01:38:54 +08:00
2026-09-03 01:38:54 +08:00
2026-09-06 13:46:29 +08:00
2026-09-06 13:46:29 +08:00
2026-09-03 01:38:54 +08:00
fix
2026-08-09 22:18:22 +08:00
2026-05-03 16:35:52 +08:00
2026-09-06 13:46:29 +08:00
2026-09-02 04:09:11 +08:00
2026-09-06 13:46:29 +08:00
2026-09-06 13:46:29 +08:00
2026-07-31 00:25:48 +08:00
2026-09-06 13:46:29 +08:00
2026-07-24 18:16:04 +08:00
2026-09-02 04:09:11 +08:00
2026-05-12 02:20:30 +08:00
2026-09-06 13:46:29 +08:00
2026-08-20 14:15:53 +08:00
2026-09-03 01:38:54 +08:00