fix(pad): URL view-option params lost to padeditor.init race (#7840)#7843
Merged
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Review Summary by QodoFix URL view-option params lost to padeditor.init race
WalkthroughsDescription• Move URL view-option overrides into postAceInit to prevent race condition - Fixes showLineNumbers, noColors, useMonospaceFont params being clobbered • Generalizes fix from #7464 (RTL race) to all three neighboring view toggles • Add comprehensive test suite for URL view-option parameters on initial load Diagramflowchart LR
A["_afterHandshake sync tail<br/>queues URL overrides"] -->|"race condition"| B["padeditor.init resolves<br/>calls setViewOptions"]
B -->|"clobbers URL values"| C["Server defaults applied<br/>URL params lost"]
D["postAceInit<br/>after padeditor.init"] -->|"fix: moved here"| E["URL overrides applied<br/>after initialViewOptions"]
E -->|"no race"| F["URL params preserved"]
File Changes1. src/static/js/pad.ts
|
`?showLineNumbers=false` and `?useMonospaceFont=true` were being silently clobbered shortly after pad load. Same race that affected `?rtl=false` before #7464: 1. _afterHandshake → getParams() sets settings.LineNumbersDisabled (or useMonospaceFontGlobal, noColors). 2. _afterHandshake calls padeditor.init(view).then(postAceInit) — async; ace iframes still loading. 3. Sync tail of _afterHandshake hits the URL-param overrides and calls changeViewOption('showLineNumbers', false) etc. These queue setProperty('showslinenumbers', false) in Ace2Editor's actionsPendingInit queue (loaded=false). 4. ace.init resolves → loaded=true → queue flushes → URL-driven value applied. 5. padeditor.init resumes past its own await and calls setViewOptions(initialViewOptions) — initialViewOptions is built from clientVars.initialOptions.view (server defaults ∨ cookie), which does NOT carry the URL preference. The resulting setProperty('showslinenumbers', true) runs against loaded=true ace and immediately re-shows the gutter. #7464 noticed this race for RTL and moved the override into postAceInit. The neighbouring blocks for showLineNumbers / noColors / useMonospaceFontGlobal were left at the synchronous-tail site — generalise the same fix to all three. Direct-browser users typically had a `prefs` cookie with showLineNumbers=false from a prior in-pad toggle, so the initialViewOptions value happened to match the URL param and the race was unobservable. Cross-context iframe embeds (the reporter's configuration) start with no cookie, so the server default true fights the URL false and the race becomes visible. Adds src/tests/frontend-new/specs/url_view_options.spec.ts covering the showLineNumbers=false / =true / useMonospaceFont=true cases on initial-load navigation (the path where the race actually fires). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fixes CI ts-check: parameters page/padId/param implicitly had `any`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
e54cfba to
769c08f
Compare
SamTV12345
approved these changes
May 25, 2026
Member
|
Makes sense that it is now firing correctly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #7840.
?showLineNumbers=false(and?useMonospaceFont=true) on an iframe-embedded pad get re-applied to the server default a few hundred ms after pad boot. Same race that affected?rtl=falsebefore #7464 — generalises that fix to the neighbouring URL view-toggles.Why the iframe reporter sees it and direct users don't
The race always fires, but it only becomes observable when the value
padeditor.init's deferredsetViewOptions(initialViewOptions)call re-applies disagrees with the URL param.initialViewOptionsis built fromcookie pref ?? server default:prefscookie from a prior in-pad toggle that matches what they're asking for via URL → no observable race.showLineNumbers:truefights the URLfalse→ URL preference visibly lost.What the race looks like
_afterHandshake→getParams()setssettings.LineNumbersDisabled = true._afterHandshakecallspadeditor.init(view).then(postAceInit)— async; ace iframes still loading._afterHandshakehits the URL-param block:changeViewOption('showLineNumbers', false)→ queuessetProperty('showslinenumbers', false)inAce2Editor.actionsPendingInit(loaded=false).ace.initresolves →loaded=true→ queue flushes → URL-drivenfalseapplied.padeditor.initresumes past its ownawaitand runsself.setViewOptions(initialViewOptions)—initialViewOptions.showLineNumbers === true(server default) →setProperty('showslinenumbers', true)runs againstloaded=trueand immediately re-shows the gutter.#7464 spotted this for RTL and moved the override into
postAceInit. The neighbouring blocks forshowLineNumbers/noColors/useMonospaceFontGlobalat the same synchronous-tail site never got the same treatment. This PR generalises that fix.Test plan
Not in scope
🤖 Generated with Claude Code