Skip to content

Improve PTY device error messages with localization support - #23538

Merged
AmethystLiang merged 2 commits into
mainfrom
improve-pty-device-error-msg
Sep 28, 2026
Merged

AmethystLiang merged 2 commits into
mainfrom
improve-pty-device-error-msg

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​137 $\color{#cf222e}{\Huge{\mathbf{−}}}$​23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​114
Prod 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​124 $\color{#cf222e}{\Huge{\mathbf{−}}}$​35 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​89

Problem

PTY device and terminal process limit errors were English-only and used verbose multi-line hints. Error messages were scattered across the codebase, and the toast component could show duplicate "file an issue" links when both the host and toast tried to request one.

Solution

  • Centralized terminal spawn error copy to src/shared/terminal-spawn-error-copy.ts for reuse across host and renderer
  • Updated error hints to use newline separators instead of space-separated to allow cleaner display and parsing
  • Added terminal-spawn-error-display.ts to localize resource-limit hints and remove duplicate issue requests in the toast
  • Swapped English hints for the viewer's locale using translations in 6 languages (es, fr, ja, ko, zh)
  • Maintained backwards compatibility by detecting both old multi-line and new single-line hint formats from hosts

Testing

  • Unit tests cover hint detection, localization, and deduplication
  • Tests verify compatibility with older hosts publishing legacy multi-line hints
  • i18n translations added for all supported locales

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)
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

- Extract error hints to shared module for reuse across host and renderer
- Change multi-line hints from space to newline separator for readability
- Add localization of resource-limit hints in the renderer
- Prevent duplicate issue requests when toast renders its own link
- Handle legacy hint formats from older hosts
@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

Shared PTY-allocation and terminal-process-limit hints are now used in daemon and renderer error handling. The renderer translates current and legacy hints and preserves diagnostic text. English, Spanish, French, Japanese, Korean, and Chinese messages were added. Local shell-spawn errors use a shared issue request, which the toast removes when it displays its own issue link.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 2677d

Some terminal allocation errors may display duplicate recovery guidance. The impact is limited to the error message, so this is mergeable with a focused follow-up.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 2677d

The new error presentation does not appear to grant access or create a new action controlled by error text. One narrow recovery risk remains: additional diagnostic lines can now affect how a failed terminal connection is classified.

Retained concerns

  • Low · reliability · inferred: Later lines of a wrapped spawn diagnostic now participate in existing connection-recovery substring checks. If such a line contains a recognized killed-session or SSH marker, a failed connection may be suppressed or classified differently than before.
Security review details

Security Blast Radius

  • inferred — The identified recovery-classification exposure is confined by the inspected code to failed terminal connections in the renderer, including its SSH-specific branches; no new credential, network, or service authority is evidenced.

Trust Boundaries and Controls

  • observed — Host error detail crosses into renderer display as text. The new copy transformations do not turn that detail into an HTML or link target, while recovery decisions still inspect the error string.

Resilience and Maintainability Implications

  • inferred — Using the complete diagnostic for both display and recovery classification couples diagnostic copy to error-state handling. The extent to which a remote or local producer can supply misleading later lines remains unverified.

Hardening Proposals

  • proposed — Keep classification inputs distinct from the full diagnostic shown to users, or constrain recovery markers to a defined error field or position.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, solution, testing, and compatibility impact. It omits required template sections and information, including ELI5, Why, Linked Issue, Visual Proof or an explicit N… Add the missing template sections. Provide the linked issue, add before/after visual proof or state N/A with a reason, complete the ELI5 and Why sections, document review and platform considerations, and mark or explain the testing checklis…
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 8 functions across 10 files. (7 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: improving PTY device error messages with localization support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the problem, solution, testing, and compatibility impact. It omits required template sections and information, including ELI5, Why, Linked Issue, Visual Proof or an explicit N/A explanation, Review, Notes, and the testing checklist selections.

Resolution

Add the missing template sections. Provide the linked issue, add before/after visual proof or state N/A with a reason, complete the ELI5 and Why sections, document review and platform considerations, and mark or explain the testing checklist items.

Full details: Docstring Coverage

Explanation

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 8 functions across 10 files. (7 skipped: 7 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 960b6838-f765-4431-a5b6-9cac8364c032

📥 Commits

Reviewing files that changed from the base of the PR and between 47b8408 and 2677d84.

📒 Files selected for processing (17)
  • src/main/daemon/node-pty-error-hints.test.ts
  • src/main/daemon/node-pty-error-hints.ts
  • src/main/providers/local-pty-utils.ts
  • src/renderer/src/components/terminal-pane/TerminalErrorToast.test.ts
  • src/renderer/src/components/terminal-pane/TerminalErrorToast.tsx
  • src/renderer/src/components/terminal-pane/ipc-pty-connect.ts
  • src/renderer/src/components/terminal-pane/pty-transport-connect-spawn.test.ts
  • src/renderer/src/components/terminal-pane/terminal-spawn-error-display.test.ts
  • src/renderer/src/components/terminal-pane/terminal-spawn-error-display.ts
  • src/renderer/src/i18n/en-runtime-required.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/terminal-spawn-error-copy.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread src/main/daemon/node-pty-error-hints.ts Resolved

@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 — one backwards-compatibility edge case inline.

Reviewed changes

  • Shared copy module — extracts the new one-line resource-limit hints, the legacy multi-line pair, and the issue-request string into src/shared/terminal-spawn-error-copy.ts for host and renderer.
  • Host hint format — addNodePtyRecoveryHint newline-separates the two new hints, keeps a space for other hints, and skips re-prepending when a string already carries a hint.
  • Renderer localization — terminal-spawn-error-display.ts swaps the host's English hints (new and legacy) for translated copy and drops the host's plain-text issue request where the toast renders its own linked one.
  • IPC error detail — ipc-pty-connect.ts uses readIpcErrorDetail so a wrapped spawn error keeps its full multi-line hint and diagnostic instead of only the first line.
  • Translations — adds ptyAllocationLimit / terminalProcessLimit to en-runtime-required.json, en.json, and the es/fr/ja/ko/zh catalogs.

The new/legacy hint matching, the $&-safe replacers, the newline separator rationale, and the i18n catalog generation all check out.

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

Comment thread src/main/daemon/node-pty-error-hints.ts Resolved
- Extract hint-detection logic into hasPtyAllocationHint() helper
- Check for both current and legacy PTY allocation hint variants
- Prevents duplication when messages already contain legacy hints
@AmethystLiang
AmethystLiang merged commit 708123b into main Sep 28, 2026
43 of 44 checks passed
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.

1 participant