Skip to content

fix(editor): localize remote file_too_large errors in preview loader card - #21869

Closed
bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/21689-editor-file-too-large-message
Closed

bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/21689-editor-file-too-large-message

Conversation

@bbingz

@bbingz bbingz commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

ELI5

When opening a file on a remote server that exceeds the transport preview limit, the editor error card now shows a friendly explanation ("This document is too large for the server to send in full.") instead of exposing the internal raw error string file_too_large.

What Changed

  • Before: Opening a remote image or document larger than the RPC transport preview limit (~3.1 MB) caused the editor error card to display the raw internal machine token file_too_large under "Unable to load file".
  • After: EditorFileLoadErrorView translates file_too_large (keyed by error code or message) to the localized user-facing message This document is too large for the server to send in full., aligning with the existing preview protocol copy.
  • Mechanism: Added FILE_TOO_LARGE_CODE and FILE_TOO_LARGE_ERROR sentinels to editor-panel-content-types.ts, localized under editor.fileLoad.fileTooLarge in en.json, and mapped in EditorFileLoadErrorView.tsx.

Why

Raw internal machine error codes (file_too_large) degrade user experience when files exceed remote preview constraints. Orca already uses this readable explanation in doc-preview-file-reader.ts for HTTP 413 responses; bringing it to the editor error card provides clear, localized guidance.

Linked Issue

Fixes #21689

Visual Proof

N/A — localized error text rendering update in existing EditorFileLoadErrorView.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Ran vitest suite and typechecks:

  • src/renderer/src/components/editor/EditorFileLoadErrorView.test.tsx
  • src/renderer/src/components/editor/EditorContent.test.tsx
  • src/renderer/src/components/editor/useEditorPanelFileLoadRetry.test.tsx
  • node config/scripts/verify-localization-catalog.mjs
  • pnpm run check:code-quality:changed
  • pnpm tc:web

AI Disclosure

Antigravity (Google DeepMind)

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: ed5abfc5-3908-4dd2-8e62-19fca87ddea4

📥 Commits

Reviewing files that changed from the base of the PR and between 79a2ad7125f8835ed192b11e50dfab1c79600da2 and 2555857.

📒 Files selected for processing (2)
  • src/renderer/src/components/editor/useEditorPanelFileLoadRetry.test.tsx
  • src/renderer/src/components/editor/useEditorPanelFileLoadRetry.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The editor now defines shared constants for the file_too_large error and its fallback message. File-load error localization matches the code or message and returns the localized fileTooLarge string. File-load retries stop for this terminal error. Tests cover both input forms and confirm that the raw error text is not rendered.

Priority: ➖ Normal

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: localizing remote file_too_large errors in the editor preview error card.
Description check ✅ Passed The description covers the user impact, implementation, rationale, linked issue, testing, AI disclosure, and checklist. It is complete enough for review, although the visual-proof section uses N/A for…
Linked Issues check ✅ Passed Issue #21689 requires a readable message instead of the raw file_too_large token. EditorFileLoadErrorView maps the error code and message to the localized editor.fileLoad.fileTooLarge text. Test…
Out of Scope Changes check ✅ Passed The changes add the file-too-large sentinel, localization, editor mapping, terminal retry handling, and focused tests. Each change supports the error behavior described in issue #21689.
  • Fix all pre-merge checks with AI

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — minor suggestions below.

Reviewed changes

  • Localized too-large copy — EditorFileLoadErrorView.localizeFileLoadError now maps the remote file_too_large token (by .code or message) to the existing localized string editor.fileLoad.fileTooLarge, matching the copy doc-preview-file-reader.ts already uses for HTTP 413.
  • New sentinels — FILE_TOO_LARGE_CODE / FILE_TOO_LARGE_ERROR added to editor-panel-content-types.ts; en.json gains editor.fileLoad.fileTooLarge, and other locales fall back to English by design.
  • Tests — two cases in EditorFileLoadErrorView.test.tsx cover the message-only and code-plus-raw-message paths; both assert the exact localized text and would fail without the new branch, so they pin the behavior rather than passing vacuously.

The end-to-end path checks out: an over-cap remote read returns an RPC envelope with code: 'runtime_error' and message: 'file_too_large' (see runtime-file-client.test.ts:310-340), the loader stores that as loadError/loadErrorCode, and the view's message branch is the one that fires for the reported repro. message === FILE_TOO_LARGE_CODE is exact, but that matches the established convention for this token (binary_file in runtime-file-read-client.ts:61, RUNTIME_TOO_LARGE_ERROR in doc-preview-file-reader.ts:40), so the shared hasRuntimeRpcErrorCode matcher is not needed here.

ℹ️ Remote too-large errors still consume the automatic retry budget

The new sentinel is now known in the view, but shouldRetryFileLoadError only treats the human text file too large (spaces) as terminal — not the machine token file_too_large (underscores) — so the remote case still passes the retry gate and runs the full automatic backoff (250 ms / 1 s / 2.5 s) on a condition that cannot succeed. Local and SSH too-large reads are already terminal, so making the remote token terminal too would drop three redundant multi-megabyte reads and the error-card flicker before the localized text settles. Not blocking — the correct text renders either way.

Technical details
# Treat the remote file_too_large token as terminal in the retry gate

## Affected sites
- `src/renderer/src/components/editor/useEditorPanelFileLoadRetry.ts:52-65` — `shouldRetryFileLoadError` checks `lower.includes('file too large')` but not the machine token `file_too_large`, so the remote case is retried.
- `src/renderer/src/components/editor/useEditorPanelFileLoadRetry.ts:96-126` — once the budget is spent, `terminalFailure` is null for this token, so the effect just returns.

## Required outcome
- A remote `file_too_large` read failure must not enter the automatic retry loop; the localized error card should be terminal, consistent with local/SSH "File too large" reads.

## Suggested approach (optional)
- In `shouldRetryFileLoadError`, return false when `code === FILE_TOO_LARGE_CODE` or the message carries the token, mirroring the existing `WORKTREE_HOST_UNRESOLVED_CODE` terminal check. `FILE_TOO_LARGE_CODE` already lives in `editor-panel-content-types.ts`, which this hook already imports from.

ℹ️ Issue #21689 also reports the remote preview cap, not just the raw token

This PR resolves the symptom the issue's title leads with, but the same issue's body reports the remote preview budget (~3.1 MiB) being roughly a third of the local 10 MiB cap, so ordinary 4–8 MiB photos still cannot open on remote hosts. Fixes #21689 will close the issue while that half remains open. Flagging so a maintainer can decide whether the cap is tracked separately or the issue should stay open.

Technical details
# Scope of "Fixes #21689"

## Affected sites
- PR body — declares `Fixes #21689`.
- Issue #21689 — reports both the raw `file_too_large` text and the reduced remote preview cap.

## Required outcome
- Decide whether the remote preview cap is in scope here or tracked/fixed separately; if separate, note the follow-up in the PR body so auto-close does not lose it.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@bbingz
bbingz force-pushed the fix/21689-editor-file-too-large-message branch from 79a2ad7 to 2555857 Compare September 21, 2026 04:07

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Remote too-large reads are now terminal in the retry gate — shouldRetryFileLoadError returns false for code === FILE_TOO_LARGE_CODE or a message containing the token, so an over-cap remote read no longer burns the three automatic backoff attempts (250 ms / 1 s / 2.5 s) on a condition that cannot succeed. This addresses the retry-budget rough edge raised in the previous review.
  • Tests pin the terminal classification — useEditorPanelFileLoadRetry.test.tsx:110-113 cover the bare token, a transport-wrapped token ('remote read failed: file_too_large'), and a code-only shape; each would fail without the new branch.

The reported repro carries code === 'runtime_error' and message === 'file_too_large', so the message substring branch is the one that fires and the code branch is defensive. Ran both affected test files locally — 12 tests pass. No further concerns.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker

Copy link
Copy Markdown
Contributor

Thank you, @bbingz! Your idea of mapping the host's file_too_large code to readable copy on the editor's "Unable to load file" card, and of not auto-retrying it, is in #33831, with you as co-author. Main now pages remote previews up to 50 MB, so the 3 MB cap from the issue is already gone. The card now says "This file is too large to open from its host." The size checks reuse the existing too-large classifier, so wrapped IPC errors and paged-read refusals are covered too. Thanks for picking this up!

@nwparker nwparker closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Remote runtime caps image previews at ~3 MB and surfaces the raw code "file_too_large"

2 participants