Skip to content

fix: improve editor responsiveness and session reliability - #1921

Merged
renkun-ken merged 20 commits into
mainfrom
codex/usage-responsiveness-review
Nov 6, 2026
Merged

renkun-ken merged 20 commits into
mainfrom
codex/usage-responsiveness-review

Conversation

@renkun-ken

@renkun-ken renkun-ken commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Repeated document scans, fragmented IPC input, long Interactive histories, and synchronous compiler probes can stall extension commands. Unresolved terminal PIDs and failed startup attempts can leave session operations waiting indefinitely. This change removes those stalls and fixes related editor and viewer failures.

  • Cache chunk parsing by document version, avoid redundant decorations and hover lookups, and use indexed transcript and plot-history lookups.
  • Process fragmented IPC input incrementally and cancel obsolete connections. Keep language-server startup cancellable through executable lookup and initialization for TCP and stdio, cancel pending multi-server starts, and allow bounded cleanup after normal shutdown.
  • Discover terminal PIDs concurrently, return exact matches immediately, and bound unresolved attachment lookups to one second. Refresh other terminals' discovery files while one PID remains pending.
  • Use the requested document's selection, report save failures, handle escaped strings and paths, run compiler probes asynchronously, and wait for completed CSV exports with reliable cleanup.
  • Persist help favorites safely, deduplicate help-index loads, keep navigation usable without scroll acknowledgements, discard stale Help refreshes and page rendering after close or navigation, prioritize explicit navigation over background refreshes and commit Back/Forward history only after successful rendering, preserve httpgd HTTPS/authentication, and load initial standard plots without waiting for resize.

Validation on macOS with VS Code 1.144 and R 4.6.1:

  • All six GitHub Actions checks passed for 980b7a0, including the macOS, Linux, and Windows test jobs.
  • 17 Help navigation/refresh regressions passed locally, including pending fetch/HTML preparation, refresh precedence, cancelled or failed navigation, and Back/Forward retries. The five new race regressions fail with the previous logic and pass with the fix.
  • Build, lint, formatting, typecheck, and production VSIX packaging passed.
  • A local parser microbenchmark of a 1.5 MB Unicode frame in 256-byte fragments improved from approximately 656 ms to 3.45 ms; this measures parsing rather than end-to-end editor latency.
  • R integration used temporary libraries with matching sess, renv, and a committed languageserver snapshot. Browser fixtures disable background throttling and release their mocks and viewers after timeouts.

Remote SSH lifecycle checks have not been run.

@renkun-ken
renkun-ken requested a review from eitsupi October 30, 2026 19:08
@renkun-ken
renkun-ken requested review from Fred-Wu and a balanced review from Copilot November 3, 2026 03:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Disposal can hang indefinitely during language-server initialization because startup is not cancellable, and a pending Help refresh can recreate a panel after it is closed.

2 open issues
What changed in this PR

This PR improves responsiveness and lifecycle reliability across the R extension’s editor commands, session connections, help panels, and plot viewers.

Changes:

  • Reduce repeated parsing and lookups, process fragmented input incrementally, and run compiler probes asynchronously.
  • Improve terminal discovery, connection cancellation, startup cleanup, document operations, and CSV export handling.
  • Fix help persistence and viewer behavior, with regression coverage and more reliable browser fixtures.
File Description
src/​util.ts Correct in-memory state storage semantics.
src/​test/​suite/​util.test.ts Test falsy values and key deletion.
src/​test/​suite/​standardPlotViewer.test.ts Cover initial readiness and disposed panels.
src/​test/​suite/​sessionTerminalLifecycle.test.ts Test concurrent and bounded terminal PID discovery.
src/​test/​suite/​sessionTerminalIntegration.test.ts Verify discovery refresh despite pending PIDs.
src/​test/​suite/​rstudioapi.test.ts Cover target selections, save failures, and paths.
src/​test/​suite/​preview.test.ts Test CSV completion, timeout, and cleanup.
src/​test/​suite/​languageService.test.ts Cover startup failures and disposal.
src/​test/​suite/​interactiveInputFeatures.test.ts Isolate formatting triggers from bracket auto-closing.
src/​test/​suite/​interactiveEditor.test.ts Wait for dynamically registered formatting providers.
src/​test/​suite/​httpgdViewer.test.ts Test sizing, timing, HTTPS, and token changes.
src/​test/​suite/​htmlWidgetBrowser.test.ts Improve fixture cleanup and browser synchronization.
src/​test/​suite/​helpPanel.test.ts Test navigation without scroll acknowledgements.
src/​test/​suite/​helpPackages.test.ts Cover favorites persistence and shared index loads.
src/​test/​suite/​fileGeneration.test.ts Test asynchronous compiler probes and quoted paths.
src/​test/​suite/​extendSelection.test.ts Cover strings ending in escaped backslashes.
src/​test/​suite/​completions.test.ts Test skipped and cancelled help hovers.
src/​test/​suite/​chunks.test.ts Verify chunk caching and editor-independent lookup.
src/​test/​suite/​chunkDecorations.test.ts Test decoration reuse and resource disposal.
src/​test/​node/​languageServerTransport.test.ts Cover TCP startup failure and cancellation.
src/​test/​node/​interactiveCore.test.ts Test fragmented frames and connection replacement.
src/​test/​common/​editorState.ts Include input text in assertion diagnostics.
src/​session.ts Discover terminal PIDs and refresh files concurrently.
src/​selection.ts Handle escaped backslashes during quote scanning.
src/​rstudioapi.ts Use target selections and report save failures.
src/​rmarkdown/​index.ts Avoid redundant decorations and dispose resources.
src/​rmarkdown/​chunks.ts Cache chunk scans and simplify iteration.
src/​preview.ts Await completed CSV exports with cleanup.
src/​plotViewer/​standardViewer.ts Request initial plots on webview readiness.
src/​plotViewer/​httpgdViewer.ts Preserve HTTPS/authentication and improve plot lookups.
src/​languageService.ts Track startup and coordinate disposal.
src/​languageServerTransport.ts Add cancellable TCP startup with failure cleanup.
src/​interactive/​manager.ts Use indexed transcript lookups.
src/​interactive/​framing.ts Parse fragmented input without repeated full scans.
src/​interactive/​client.ts Clean up failed and obsolete connections.
src/​helpViewer/​panel.ts Fall back when scroll acknowledgements are unavailable.
src/​helpViewer/​packages.ts Persist favorites safely and deduplicate index requests.
src/​extension.ts Register providers and listeners for disposal.
src/​cppProperties.ts Run compiler probes asynchronously with cleanup.
src/​completions.ts Skip unnecessary and stale help-hover results.
.vscode-test.mjs Disable browser background throttling during tests.

Review effort: Balanced

Comment thread src/languageService.ts Resolved
Comment thread src/helpViewer/panel.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Overlapping refreshes can share a revision, allowing an older refresh to invalidate a newer one and leave stale Help HTML displayed after rapid preview updates.

1 open issue
2 resolved since last review

Review effort: Balanced

Comment thread src/helpViewer/panel.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved regressions can corrupt help-viewer history, let background refreshes cancel navigation, and remove R Markdown chunk highlighting when CodeLens is disabled.

2 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Preserve R Markdown chunk highlighting when CodeLens is disabled

src/​rmarkdown/​index.ts:67

Excluding rmd editors here removes their chunk highlighting when VS Code's editor.codeLens is disabled: the remaining decoration update lives in provideCodeLenses, which VS Code does not invoke in that configuration. Previously cursor movement still applied the independently configured chunk background color. Keep a document-version-cached decoration update for R Markdown editors as well.

1 resolved since last review

Review effort: Balanced

Comment thread src/helpViewer/panel.ts Resolved
Comment thread src/helpViewer/panel.ts Resolved
@renkun-ken
renkun-ken merged commit 5c0e522 into main Nov 6, 2026
6 checks passed
@renkun-ken
renkun-ken deleted the codex/usage-responsiveness-review branch November 6, 2026 13:28
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.

2 participants