Repository navigation
Studio: fix PDF previews after a PDF attachment is extracted - #12346
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
unpdf sets globalThis.pdfjsWorker to its own PDF.js build, which the viewer's PDF.js then adopts and fails on (API 5.4.296 vs worker 5.6.205). Give each document its own worker so that lookup never happens. Same change as #12346.
NilayYadav
left a comment
There was a problem hiding this comment.
Review + reproduction evidence
Pinned review: 0c18522e. One finding in the new worker hook, fixed in 0c18522e. One sibling viewer with the same bug, suggested below.
I reproduced the bug on fresh upstream main in a real Studio install (install.sh --local, Linux on Modal, logged in through the login form, Chromium 1400x900). The steps: attach sample-a.pdf from the composer, attach sample-b.pdf, then open sample-b.pdf.
- main
e477badf: card B shows "This file can't be previewed here. Download it to open it." Opening it shows the same message, and the console showsWarning: Setting up fake worker.Same result in Firefox and WebKit. - PR
0c18522e: both cards render page 1, and the dialog renders "Document B" with its text layer. Same result in Chromium, Firefox (3 of 3 runs) and WebKit.
Fixed in 0c18522e: fonts were never released. The hook's setTimeout(0) teardown terminated the worker before PDF.js got the answer to its Terminate message. WorkerTransport.destroy only calls fontLoader.clear() after that answer (pdfjs-dist 5.4.296 pdf.mjs:15167-15179), so every closed preview left its fonts in document.fonts.
- Measured in Studio with a PDF that embeds 3 fonts, opening and closing the preview 6 times. On
fe3d2f5c,document.fonts.sizewent 39, 42, 45, 48, 51, 54, 57 (2 runs, identical). - With the fix it stays at 39 for all 6 cycles.
- The hook now waits for each loaded document's
destroy()before it terminates the worker. Typecheck is clean and eslint is unchanged.
Suggestion: the RAG citation preview has the same bug. features/rag/components/document-preview-sheet.tsx renders <Document> without a worker, so it still adopts unpdf's worker. I reproduced it on Modal L4 with Qwen3-4B-Instruct-2507 Q4_K_M: Chat with files, add a handbook PDF, attach a PDF to the message, ask, then click the citation. On main and on this PR the sheet shows Could not render this PDF (The API version "5.4.296" does not match the Worker version "5.6.205".). Moving usePdfWorker into components/file-viewer/use-pdf-worker.ts and using it in PdfPreview fixes it. I checked that in the same flow, and the sheet then renders the page with the cited lines highlighted:
// in PdfPreview
const pdfWorker = usePdfWorker(true);
const options = useMemo(() => (pdfWorker ? { worker: pdfWorker.worker } : null), [pdfWorker]);
const onLoad = useCallback(
(document: { numPages: number; destroy(): Promise<void> }) => {
pdfWorker?.loaded.add(document);
setNumPages(document.numPages);
setPage((p) => Math.min(Math.max(p, 1), document.numPages));
},
[pdfWorker],
);
// ...
{options && <Document file={fileUrl} options={options} onLoadSuccess={onLoad} ...>...</Document>}Other checks:
- Worker count is unchanged. Without
options.worker,getDocumentalready creates one worker per Document and destroys it with the loading task. The parse queue still caps concurrent thumbnail parses at 2. - Minor, not fixed: a worker passed with a port skips PDF.js's own error fallback. If
pdf.worker.min.mjsfailed to load (for example a tab left open across an upgrade), the preview would spin instead of saying it can't preview. I could not trigger this in a normal flow. - Already on
main, not from this PR: aReadableStreamDefaultControllerclose error in the console after PDF extraction. Also, rarely, a full-page "Loading..." flash that drops a composer attachment. - A/B on GitHub Actions: I added a focused Studio workflow (attach two PDFs, then open the second; Ubuntu Chromium/Firefox/WebKit, Windows Chromium, macOS WebKit), running on PR head and fix reverted. Both were still queued when I posted this. Locally, the same probe fails on
mainat the card assertion ({"canvases": 0, "cant_preview": 1}) and passes on the PR.
Conclusion: the bug is real and the PR fixes it for chat cards and the attachment dialog (the Library preview uses the same component). With 0c18522e it no longer leaks fonts. The RAG citation preview needs the small follow-up above, either here or in its own PR.
|
@codex review |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 864fc1dd00
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const port = new Worker(pdfjs.GlobalWorkerOptions.workerSrc, { | ||
| type: "module", | ||
| }); | ||
| const next: PdfWorker = { | ||
| worker: pdfjs.PDFWorker.create({ port }), |
There was a problem hiding this comment.
Handle dedicated-worker startup failures
When worker creation is blocked by CSP/browser policy, the synchronous new Worker(...) exception escapes this effect and crashes the preview; if the worker script instead fails to load, PDFWorker.create({ port }) treats the external port as ready and the document can remain on its loading state indefinitely. The previous PDF.js-owned worker path catches startup failures and falls back to its fake worker, so the new dedicated-worker path should likewise catch constructor errors and handle the port's error event by falling back or showing a load error.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not reachable here: Studio serves worker-src 'self' and the desktop CSP is default-src 'self', so this same-origin module worker is allowed; the constructor call and URL are identical to what PDF.js itself ran before, and its fake-worker fallback imports that same URL, so a script that fails to load fails there too.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 864fc1dd00
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| void Promise.allSettled( | ||
| [...next.loaded].map((doc) => doc.destroy()), | ||
| ).then(() => { | ||
| next.worker.destroy(); | ||
| port.terminate(); |
There was a problem hiding this comment.
Let failed loading tasks finish before terminating the worker
When a corrupt or unsupported PDF fails after its transport is created, it is never added to next.loaded, so this empty Promise.allSettled chain terminates the port on the next microtask. React-PDF concurrently calls PDFDocumentLoadingTask.destroy() while unmounting <Document>, but that cleanup waits for the worker's Terminate response before canceling the network stream and destroying the per-document handler; terminating the external worker first can leave that cleanup pending and allow a large failed download to continue. Track and await failed loading tasks as well, or otherwise coordinate their teardown before terminating the port.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Below the bar: this only leaves a failed load's teardown promise pending. File viewer PDFs are passed as in-memory data, so there is no stream to keep running, and the URL case needs a PDF the backend indexed but PDF.js cannot open. The error state renders correctly and no worker stays alive (checked in Chromium).
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Conflicts: tauri ~2.12.0 from main keeps the unstable feature for child webviews; pdf-view takes main's shared PDF worker (#12346 landed); the attachment refactor on main drops AttachmentUI, so the annotations chip uses AttachmentCardRemove.
* Studio: in-app browser panel for chat * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: harden browser panel and cut chat lag - Run page fetches in their own pool, off the event loop, and cancel them when the panel aborts the load, so browsing can't stall chat streaming. - Only honor tab opens, external links and shortcuts from a page when its frame has focus and the user just interacted, rate limited to one per second. - Drop http: and ws: from the shell's connect-src and add treat-as-public-address, so pages can't reach local services. - Refuse favicons that point at Studio. - Cache loaded pages per history entry for instant back and forward, cap history at 50, and keep only the 4 most recent tabs mounted. - Memoize the panel and tabs, skip no-op tab updates, and watch only <head> for title changes. - Set the side panel width on the header, fade and notice instead of the content root, so resizing doesn't restyle the whole thread. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: keep browser pages and HTML files off local services - Open local HTML files in the same frame as the attachment preview, so network access stays off until the user allows it. - Allow only https in the shell's fetch directives and add upgrade-insecure-requests. WebKit has no local network protection, so http images, scripts, styles, media and frames could reach local services directly. * Studio: lock browser page navigation, validate frame messages, bound cache - Load pages into a srcdoc child of the shell, then set frame-src 'none' on the shell. The child keeps its own policy, so embeds still load, but can no longer navigate itself. This does not depend on the Navigation API, which WebKit and Chrome don't fire here, and closes the gap where the desktop app's frame-src allows every loopback port. - Parse frame messages field by field and bound titles, URLs and bodies, so a malformed message can't crash the chat. - Give the page cache a 32 MB total and 8 MB per-page byte budget, and drop a tab's pages when it closes. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: browser file toolbar, find, zoom, history and downloads - Opened files get a file menu (full name, Open in new chat or tab), Request edits, a zoom menu and download. - Page menu: find in page, copy link, zoom, device toolbar, downloads, history, clear browsing data and browser settings. - History and Downloads pages with search and per-row removal. - Settings: show full URL, manage history and downloads, clear data. - Browser button uses the internet icon, hides in a new chat and while the panel is open. - Code, text and plain file icons use the foreground color; only docs stay blue. - Washes follow the contrast setting and the tab height follows the UI scale. * Studio: proxy browser favicons, open provider sign-in externally - Favicons from pages load through the guarded fetch and show as blob URLs, so a page cannot point Studio at a local or LAN address. - Provider sign-in URLs always open in the system browser, since the browser panel keeps no cookies. * Studio: move browser settings to their own Settings section - New Browser section under Shortcuts, with the browser icon: links and files, address bar, and browsing data. - Browser rows leave the Chat section; the panel's Browser settings item, settings search, the command palette and the desktop Settings menu point at the new section. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: redesign the browser history page - Breadcrumb back to Settings and Browser settings, large title, and a search pill with a time range filter (all time, today, 7 or 30 days). - Days are collapsible cards; rows show the site favicon (loaded through the guarded fetch once on screen), title, host, time and a menu to open the page or remove it. - Rows can be selected and removed together; Clear browsing data sits above the list. * Studio: fix PDF previews after a PDF attachment is extracted unpdf sets globalThis.pdfjsWorker to its own PDF.js build, which the viewer's PDF.js then adopts and fails on (API 5.4.296 vs worker 5.6.205). Give each document its own worker so that lookup never happens. Same change as #12346. * Studio: ChatGPT-style browser: full view, annotations, image viewer, link menus, canvas tools - Full view: floating chat over the browser, minimize, move chat to the left/right pane (Shift+Cmd+F) - File toolbar floats over the document; new tab page, menus and icons restyled - Request edits: annotate mode with a comment-bubble cursor, click or drag an area to mark it, comment, and send all marks to the chat as one annotations attachment - Image viewer for chat images (gallery, zoom, download, open source page) - Right-click menus for web links, sandbox file links, created-file rows and attachments; sandbox files can be opened in the default app or revealed in the file manager - Canvas parity for file tabs: Preview/Source, Run again, Console with error badge, Fix with the model, Copy, Wrap lines, Open in Canvas * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio browser: native webviews in the desktop app, plus perf and security fixes Desktop app: web pages now load in a native child webview per tab instead of the proxy and sandboxed iframe, so Cloudflare challenges, logins and web apps work. Navigation is limited to public http(s) hosts (plus a WebKit content rule list on macOS for subresources), the views get no IPC, use their own data store, turn popups into tabs and quarantine downloads. Also fixes the tab strip being covered by the macOS titlebar drag region. Web UI: bot-check refusals are detected and explained, HTML responses are capped, favicons use a smaller cap, pushState reports are coalesced, and history writes are batched and capped. Chat performance: link context menus mount lazily, web links skip file-scope subscriptions, a descendant :has() on the thread is replaced, PDF.js shares one worker, and the image viewer drops its backdrop blur. Security: SVG and HTML never open from blob URLs on Studio's origin, redirect unwrapping only follows web targets, bidi controls are stripped from the address, and "Open in default app" opens a staged copy so a swapped symlink can't redirect it. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio browser: send pending annotation, keep base URL in saved pages, annotate HTML source - Send includes the annotation still being typed instead of dropping it. - Save Link As puts the page's base URL back, so relative links resolve. - Request edits on an HTML preview switches to its source; the framed preview can't be selected from the parent. * Studio browser: route native pages through a DNS-checking proxy Pages in the desktop app's native webviews now connect through a loopback proxy (browser_proxy.rs) that resolves each host itself, refuses private or loopback answers and connects to the address it checked. That covers every request (images, fetch, sockets), not just navigations, on every platform, and stops hostnames and DNS rebinding from reaching local services. - macOS 14+: set on the pages' data store, with the Network calls looked up at run time so older macOS still launches. macOS 13 and earlier keep the content rule list. - Windows: WebView2 --proxy-server with <-loopback> so loopback isn't bypassed. Linux: WebKitGTK proxy settings on the pages' own context. Also fixes a crash: polling the page address called wry's url(), which panics on macOS while WebKit has no URL (a failed load). * Studio browser: native pages only where they're proxied; report failed clears - macOS 13 and earlier can't proxy a webview, so a hostname resolving to a local address would reach it directly. Native views now need macOS 14+ (browser_view_supported); older macOS keeps the proxied frame, and a view whose proxy can't be set never loads. - Clear browsing data waits for the native clear and shows an error if it fails, instead of always reporting success. * Studio browser: proxy only to global addresses; retry failed native navigations - The address check now refuses everything that isn't globally routable, as the backend's is_global does: benchmarking, IETF, documentation, multicast and reserved IPv4 ranges, and IPv6 outside 2000::/3 or in its special-purpose blocks (6to4, Teredo, documentation). - A native view records its new address only once browser_view_navigate succeeds, so Retry after a failed navigation tries it again. * Studio browser: fix ReDoS, resize lag, sandbox opener escape; trim comments - Tag regexes on fetched pages (<base>, <meta>, <head>, <html>, <!doctype>) were quadratic on unclosed tags. A hostile page held the GIL for minutes (backend frozen, chat included) or froze the UI in the shell and Save link as. Stop each match at the next "<". - Native views: a drag queued every frame's bounds behind the previous call, so the page trailed the handle and replayed stale sizes. Keep one call in flight and only the newest state. In Rust read the window bounds once, use one set_bounds, and only show/hide views when the shown tab changes. - While the split is dragged, pin the panel's page at its start width, so pages, PDFs and native views lay out once on release, not every frame. - Close native views when the panel unmounts (hidden ones kept running scripts and media), reopen at the page they had reached, and limit page-opened tabs to one a second like the frame path. - Open in default app: O_NOFOLLOW only covers the last component, so a sandbox directory swapped for a link could stage a file from outside. Check where the opened file really is against the sandbox root. - Bot checks: a Cloudflare/Akamai Server header only counts on a 403, so rate limits and outages are not reported as bot checks; on a bot check "Open in browser" is the primary action. - Shorten comments. * Studio browser: shorten and merge tests, add regressions Fold duplicate shell/CSP, refresh, fetch-argument and 502 tests; move the sandbox opener tests above the __main__ guard and parametrize them. Add regressions for linear tag stripping (backend and withBaseUrl), bot-check classification of Cloudflare 429/503, and a sandbox parent swapped for a link. * Studio browser: review fixes for native views, resize pin and tag stripping - Native views: one in-flight call across panel remounts, so a late close from the old mount can't kill the new mount's view; recheck after every await before touching state; resume keyed by the entry the view holds; new-tab throttle per tab. Rust records the shown tab only once show() succeeded, and skips set_bounds right after creating a view. - Native view rect is clipped to the page area, so a pinned (overflowing) page can't put the native layer over the chat while shrinking. - Pin is idempotent, primary button only, and keeps the page's place (device mode no longer jumps). - Tag stripping keeps quoted '<' and '>' inside a tag, still linear. - Opener: the realpath fallback (no /proc, Windows) must also be the inode that was opened. - Bot-check buttons keep their order; only the emphasis changes. * Studio browser: keep desktop commands working with browser views open From the reviewer panel: - A child webview makes Tauri's WebviewWindow extractor and get_webview_window("main") fail ("current webview is not a WebviewWindow"), so once a page was open in the panel, file dialogs, clipboard, native intents, layout, open-logs and microphone reset failed, and tray Open could not restore the window. Commands take the calling Webview (main-label check unchanged); window lookups use get_window. - browser_view_show is async: creating a webview from a sync command deadlocks on Windows (Tauri known issue). - Back/Forward on macOS and Linux come from WebKit's own canGoBack and canGoForward; the Navigation API is missing before Safari 26.2 and in WebKitGTK, so Forward never enabled there. - Reopening a file that was rewritten since it opened shows the new bytes (unchanged bytes keep the viewer and its scroll). * Studio browser: drop comments that restate the code * Studio browser: owner-only sandbox open; quarantine every download of a URL - Opening a sandbox file launches an app on the host's desktop, so it now requires the installation owner, like the library and model reveals. - Download paths are queued per URL: two downloads of the same URL each get the quarantine mark on macOS, where WebKit doesn't report the path. * Studio browser: proxied frame on Linux desktop Tauri packs Linux child webviews into the window's GtkBox, which ignores their bounds (wry only positions webviews in a GtkFixed or X11 child), so a native page could not sit over the panel. Linux uses the proxied frame, as the web build does. * Studio browser: last reopen of a file wins; keep a newly typed draft out of an annotation send * Studio browser: load the panel on use to fit the startup budget; cover it in the CI contracts * Studio browser: clear the desktop browser's site data when the Studio account changes * Studio browser: history persists per account; a queued file refresh keeps its blob * Studio browser: native view code loads with the panel; only the support probe stays at startup * Studio browser: link and file menu items load with the first right-click * Studio browser: re-measure the startup budget with the panel's first-screen pieces * Studio browser: hand off only what the opener allows; name a viewed image's download by its type * Studio browser: tell a scheme-less site from a chat file by shape, not a list of TLDs * Studio browser: a closed native view leaves the page it reached as a tab entry * Studio browser: reserve in-flight download names; take IPv6 and IDN hosts in the address bar * Studio browser: a refresh after a POST is a GET; one proxy connect deadline; mail links from new windows hand off * Studio browser: ask before sending a form again; keep a download's own file name * Studio browser: an account switch closes the pages and waits out the clear; one macOS download per URL at a time * Studio browser: refuse file uploads the proxy would drop; clearing data closes the native pages * Studio browser: say when a page's script navigation can't be followed in the proxied view * Studio browser: cap native downloads a page can start without asking * Studio browser: wait for the engine to finish clearing browsing data * Studio browser: bound native page titles * Studio browser: a global budget for tabs pages open, then ask * Studio browser: a linked image opens its link, not also the viewer * Studio browser: in-page jumps update the address; Send shows for a first comment being typed * Studio browser: re-check a sandbox file just before revealing it * Studio browser: drop comments that restate the code * Studio browser: history date filter, ChatGPT-style image viewer, polish Browser panel - Address bar: placeholder on the left; typing changes the fill instead of adding a focus ring. - Content area's top-left corner is square. - File toolbar shadow in dark mode is much fainter. - Browser settings use the app-window icon. - Bot-check page tells web users the Unsloth desktop app can open the site. Browsing history - Search bar has no focus effect (Downloads too). - Filter uses the Library's filter icon and menu style. - New "Choose dates…" option picks a day or range on a calendar; the heading shows the chosen dates, and "Clear filter" resets it. Chat images - Chat image attachments open in a full-window lightbox, as ChatGPT has it: the picture over the blurred page, with floating name, zoom, Chat about this, download, more and close controls. - Sent images get the Library's Add to Favorites and Delete (removes it from the chat too, after confirming). * Studio browser: annotate web pages, ChatGPT-style toolbar and image gallery Browser panel - Web toolbar sized like ChatGPT's: 36px pills, 32px buttons, dark icons that fade when unavailable; larger address text. - Annotate any web page: mark a block or drag an area, comment on each, and send them to the chat as one message with the page's title and URL. The page's own script finds what is under the pointer (the page is another origin) and the panel draws the marks over the frame. Hidden for native views in the desktop app. - Suggested sites: hover to remove, right-click for Open, Open in new tab, Open in system browser, Copy link and Remove. Clearing browsing data brings removed ones back. - Dark mode: lighter tabs and controls with brighter text. - The file toolbar's file icon is always grey; only its tab is coloured. - The bot-check page sets "Unsloth desktop app" in bold. Chat images - Arrows and the arrow keys move between the images in a message or the composer. - More menu: Copy image, Add to Favorites, Project and Delete for sent images; composer images save a Library copy to star or add to a project, and Remove from message. - Lighter backdrop, no borders on the controls, square images with no shadow, and more room between the image and the controls. Backend - A chat attachment's image or clip can be copied into a project. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio image viewer: full-window stage, lighter backdrop; composer-style annotate send - Images fit with room clear of the controls but may use the whole window once zoomed, so a zoomed picture is no longer cut off top and bottom. - Backdrop outside the image is more see-through with a 1px blur; images get a very faint shadow and no rounding. - Gallery arrows only show toward another image; the zoom menu's chevron sits closer to its edge; controls lose their ring border. - The annotate comment's send button matches the chat composer's. * Studio browser annotate: light mode, dictation, numbered marks - The page draws its own outlines and pins in a closed shadow root, so marks stay put while the page scrolls. - The comment box and bottom bar follow the theme: light in light mode, dark in dark mode. - The comment's send arrow becomes a microphone that dictates into it; Enter still saves. - The bottom bar appears once the first annotation is saved, with more room left of its drag handle. - Pins are numbered in the order the chat will read them, on web pages and files alike. * Studio browser annotate: tick to save, pinned blank areas, toolbar polish - The comment's microphone turns into a tick once there is text to save, unless it is still listening, so dictation can always be stopped. - A dragged area with nothing in it marks that part of the page, pinned to whatever scrolls under it (or a fixed bar it sits on). It used to fall back to the element under its centre, which on pages with sticky panels stayed put while the page scrolled. The chat reads it as "Area of the page". - The annotate toolbar icon is a touch smaller and nudged so it reads as centred. - Less padding right of the file toolbar's dropdown arrows. * Studio chat header: chat menu, new browser tab button, temporary chat menu - A saved chat's header has a "…" menu with what the Library and the sidebar offer for it: rename, pin, favorite, mark unread, fork, move to, copy, export, open folder, archive, delete. The sidebar publishes its handlers for the open chat, so dialogs and confirmations match. - A new chat keeps its temporary chat toggle. A temporary chat keeps the toggle and gets its own "…" menu: save to history first, then the same rows, with copy as Markdown and delete working from the messages on screen and the rest greyed until it is saved. - The globe becomes a new tab button, shown in new chats too: a click opens a tab, hovering offers a tab in full view. New browser tab gets a shortcut (Shift+Mod+B); Shift+Mod+F with the browser closed opens a tab in full view. - A line before the right panel's button on saved chats. - The annotate toolbar icon sits a touch lower and to the right. * Studio chat: temporary menu offers only what works, date opens details - A temporary chat's "…" menu holds only what can be done now: save to history once the reply is done, copy as Markdown, delete. It hides until the chat has a message. - In a message's More menu, the date and the details button are one item, so clicking the date opens the response details too. - The annotation hover card takes the menus' soft shadow and radius, not a hover card's lift. * Studio chat header: drop the line before the right panel's button * Studio chat header: keep the "…" buttons highlighted while their menu is open The tooltip around each trigger writes its own data-state over the menu's, so the open style now reads aria-expanded, which only the menu sets. * Studio browser: harden web annotations, scope reload cache, cap browser bodies - A page's title or address cannot close the annotation block the model reads, and a long address no longer drops the chip's title and link. - Marking a password field never copies its value into the chat. - Annotations stay open when the composer refuses them. - Reload drops only the current page from the cache, so Back keeps earlier pages (and a form result) without refetching. - /api/browser is under the request body cap like the other JSON routes. - Page-forwarded shortcuts share the one-action-per-second limit. - A toast with an action hides the native page so the action can be clicked. - History ranges use calendar days, so a daylight saving change keeps whole days. * Studio browser: let pages handle their own links and forms - Links and forms go through the proxy only after the page's handlers ran and left them alone, so router links and forms sent with fetch stay in the page. - form.requestSubmit() keeps its native validation: an invalid form no longer submits. - Annotation marks start over on a reload, a replaced page or refreshed file bytes instead of carrying the previous document's comments. - Revealing a single sandbox file needs the installation owner, like opening one. - A failed page fetch logs its host, not an address that may carry a token. * Studio browser: keep SmartScreen on for Windows pages The pages' WebView2 environment replaced wry's default arguments and with them turned SmartScreen off. These are open-web pages, so they keep it on, as in Edge; the app's own webview is unchanged. * Studio chat header: keep the scale contract on the buttons that moved The temporary-chat and chat-menu buttons moved into chat-header-menu.tsx and the browser's new-tab button into browser-toggle.tsx; the contract now follows them so they still scale with the UI. * Studio browser: survive unparseable addresses, keep staged files unsent - A page whose <base> or refresh address urljoin cannot parse loads as if it had none, and a failed fetch of such an address still answers 502. - Annotations join files or text already staged in the composer instead of sending them along. - A sent document opened from its extracted text downloads as .txt text. - A page posting marks itself stops adding them past the 500 mark cap. * Studio browser: leave full view with the last tab, cap marks on both counts Closing the last tab closes the panel the way closePanel does, so the browser reopens beside the chat; closing an annotated tab ends its annotation. A page's own marks stop at the cap on either the panel's marks or the page's rects, so emptying the rects report no longer lets them grow. * Studio: keep the sign-in on Studio's own URLs, clear the image viewer on sign-out - Saving, copying or opening an image attachment linked from another site fetches it without Studio's bearer token; only the backend's own URLs get it. - Signing out closes the image viewer and drops its images. - Download records bound their name and type, and drop an address past the visit cap instead of storing it. - A text file tab decodes only what its preview can show. * Studio browser: bound native addresses and prompts, fence account-switch clears - Native page addresses past the frame path's 8192-character cap are not sent to the panel (polled, loaded, new-tab or mail links). - Prompts a native page triggers show one at a time, at most once a second. - The new-tab and full-view shortcuts only act while the chat is shown. - Fetched HTML with a byte order mark decodes by it, as in browsers. - An account switch clears the desktop browser through the same guarded clear as Clear data, so no page reopens and writes the old account's data back. * Studio browser: honor inline cancels, keep native tabs honest about their page - An inline onclick/onsubmit that returns false keeps the link or form in the page, as browsers do (Chromium, Firefox and WebKit checked). - A native tab resumes only a web address, forgets the address it was opened for once it moves on, and names the page it shows in a mail or tab prompt. - The attachment menu's Open does what clicking the chip does, so the open-in-browser setting applies; a new browser tab opens before the bytes load. - Closing the image viewer releases its images. - The shell test now pins the password and inline-cancel guards. * Studio browser: show Send for a first comment, one send at a time, transcode raw text, message-scoped attachment tabs * Studio: enlarge remote chat images without CORS, fail a clear when the native probe fails * Studio browser: trim comments * Studio browser: right-click menus, remembered favicons - Recents, History rows, Downloads rows and tabs get right-click menus, sharing one menu with the Suggested tiles: open here, in a new tab or the system browser, copy the link, then a way off the list. Tabs add reload, duplicate, close and close others. - The icon a page declares is remembered per site, so Recents, History and Suggested show it (then /favicon.ico, then a globe). Recents had no favicons before. Clearing history clears them. * Studio browser: Firefox-style toolbar and site panel Bare back/forward/reload, a filled address bar with a site identity button (connection security, clear browsing data, browser settings) and a zoom badge; annotate next to download; open in system browser moves into the panel menu. * Studio: resolve image URLs against the backend base before the origin check * Studio browser: native reload from the tab menu, IP and IDN link hosts, case-insensitive download names * Studio: record os.startfile in the sandbox open tests, so Windows runs never launch an app * Studio browser: decode legacy labels and unlabelled pages as windows-1252, follow unquoted meta refreshes * Studio browser: refuse unreportable native addresses, clear native data before the account purge, compare reopened files in slices * Studio browser: type the large reopen test's bytes as an ArrayBuffer view * Studio browser: Firefox-style tabs and bookmarks, page zoom apart from the interface Tabs are rounded rectangles that keep their title down to 88px, show a close button only when open or hovered, scroll without a bar, and drag to reorder: the dragged tab follows the pointer, the others slide aside, and the order changes once on release. Bookmarks as in Firefox: the address bar's star (and Cmd/Ctrl+D, from pages too) saves the page and opens an editor for its name and folder; a bookmarks toolbar under the address bar (new tab only, always or never) with an overflow menu and Other bookmarks; a Bookmarks page beside History and Downloads; and a Bookmarks section in Settings. Bookmarks are kept per account and carry a small copy of the page's icon. Zoom keys, Ctrl+wheel and pinch zoom the page while focus or the pointer is in the browser, including from inside a framed page, and the interface everywhere else. Tabs with nothing to zoom ignore them. The site panel uses the composer's shields, a padlock for the connection and a Security view: whether the connection is secure, and that the certificate was valid once the page has loaded. Back, forward and reload are one matched icon set. * Studio browser: Studio's find bar for pages, Print, Take a screenshot, site info icons - Find in page uses Studio's own find bar: the page is matched in its frame (case-insensitive, visible text, same highlights as the chat's) and counted back. The bar gets chat / browser page buttons while a page is open; Cmd+F searches whichever has focus. The browser's own find bar and window.find are gone. - Print: a copy of the page as it is now goes to a separate print frame (/api/browser/print) whose sandbox allows the dialog and whose CSP runs only its own script. - Take a screenshot (Chromium): this tab's capture cropped to the page, added to the chat's composer or saved. - Site info: a slimmer padlock sized and aligned with the other rows, no dividers around it, and a certificate icon. The chat header's new tab button shows the globe again. * Studio: refit a fitted image when the viewer resizes * Studio browser: trim comments * Studio browser: find bar laid out like ChatGPT's, globe for the Browser settings tab - The find bar leads with a search icon; the chat / browser page scope buttons are plain icons, the one being searched lit and the other dimmed, with a divider before close. The chat one is the plain bubble Settings uses for Chat. The bar widens by their room while they show. - The Browser settings tab shows the globe instead of a window. * Studio browser: native Print and screenshots in the desktop app, steadier web screenshots Desktop app (src-tauri/src/browser_capture.rs): - Take a screenshot needs no screen-share prompt. A page in a native view is captured by its engine (WebKit's snapshot on macOS, Chromium's Page.captureScreenshot on Windows); files, internal pages and proxied frames are captured from the app's webview, cropped to the page area (macOS, Windows, and WebKitGTK on Linux). The menu item always shows in the desktop app. - Print works for native pages: WebKit's print sheet on macOS, titled after the page, from a copy of the shared print info (wry's print() zeroes the shared margins, so pages print to the edge and so does everything after); Edge's print preview on Windows via ShowPrintUI, which a page can't replace the way it can window.print(). - Print stays off for framed pages in the macOS app, whose webview drops print() from frames, rather than reporting success. - Native capture and print wait for the view to come back after the menu that asked hides it. Web build: - The region capture waits for frames and the page to keep one size (the sharing bar settled) instead of a fixed 350 ms, waits for closing menus to leave the page, and stops quietly when sharing ends. Toasts, tooltips and the file toolbar are hidden for the shot. - With the device toolbar on, the shot is the device's width only. * Studio browser: full tab menu, pin pages to the sidebar, rename and mute tabs Tab right-click menu: Pin to sidebar, New tab to the right, Reload (the two-arrow refresh icon), Duplicate (a copy with its history, beside it), Fork (into a new or temporary chat), Copy URL, Open in external browser, Rename, Mute tab, Close, Close other tabs, Close tabs to the right. - Pinned pages (pinned-pages-store, per account like bookmarks) show in the sidebar's Pinned section after its chats and folders: the site's icon and title, a one-click unpin, and the same menu as the tab (3-dot and right-click). Clicking one shows its tab, or opens one at the pinned address; from outside a chat it goes to one first. - Rename edits the name in place, in the tab or the sidebar row; it is kept as the tab navigates, and empty gives back the page's title. A pinned tab and its row share the name. - Mute: a muted tab shows a speaker to unmute it. Framed pages mute their media (on the page or not) and suspend Web Audio, and a muted tab's next page loads muted. In the desktop app, Windows mutes the WebView2 view; macOS mutes each page's media as it commits and loads. - The tab menu (tab-menu.tsx) is shared by the tab strip and the sidebar row. - Strings in every locale. * Studio browser: a duplicated form result asks before posting again; a pruned muted view reopens muted Duplicate tab copied each history entry into a new object, so the resubmit guard (keyed by entry) no longer knew a copied POST had been sent: the copy posted the form again unasked. Copied POST entries are now marked sent, so the copy asks first. browser_view_close also forgot a tab's mute, and it is how the panel prunes views past four, so a muted tab came back with sound while showing muted; the mute now stays until the tab is unmuted. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Unsloth <[email protected]> Co-authored-by: Daniel Han <[email protected]>



Summary
Once a PDF attachment has been extracted in chat, every PDF preview after it fails to render (thumbnails, the preview dialog, and the Library). This fixes it by giving each document its own PDF.js worker.
Cause
unpdfsetsglobalThis.pdfjsWorkerto its own PDF.js build when it extracts text. PDF.js checks that global before creating a worker, soreact-pdfends up on a fake worker from a different PDF.js version and the load fails with a version mismatch.Changes
usePdfWorkerhook inpdf-view.tsxcreates aPDFWorkerfrom our ownworkerSrcand passes it toDocumentthroughoptions.worker, which skips the global lookup.Documentcan cancel its loading task before the worker is destroyed.Testing
npm run typecheckis clean.Before / after
Two isolated Studio installs (merge base
74e53b0vs headd057cfe): attachfirst.pdf, wait until its text has been read, then attachsecond.pdf.Before,
second.pdffalls back to "This file can't be previewed here" (first.pdfonly rendered because it painted before the read finished). After, both cards show their first page.The RAG citation preview (
document-preview-sheet.tsx) failed the same way after an attachment was read ("Could not render this PDF (The API version "5.4.296" does not match the Worker version "5.6.205")").usePdfWorkernow lives infile-viewer/use-pdf-worker.tsand that sheet uses it too. Checked in Chromium, Firefox and WebKit: the file viewer, thumbnails and citation sheet all fail on the merge base after an extraction and render on head. Workers drop back to 0 after every unmount.