fix: pad-wide view settings apply to the creator's own view (#7900)#7902
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 enforced pad-wide settings overridden by creator's personal cookies
WalkthroughsDescription• Fix enforced pad-wide RTL settings being masked by creator's stale personal cookie • Gate personal override merge on enforceSettings directly instead of isPadSettingsEnforcedForMe() • Creator's pad-wide controls remain editable; lock notice not shown to them • Add regression test reproducing stale personal cookie scenario with RTL toggle Diagramflowchart LR
A["Creator toggles personal RTL"] --> B["Stale cookie rtlIsTrue=false"]
B --> C["Set pad-wide RTL + enforce"]
C --> D["Old: Personal cookie masks pad-wide value"]
D --> E["Content stays LTR - bug"]
C --> F["New: enforceSettings gates override merge"]
F --> G["Pad-wide value is authoritative"]
G --> H["Content flips to RTL - fixed"]
File Changes1. src/static/js/pad.ts
|
Code Review by Qodo
Context used✅ Tickets:
🎫 RTL Flips entire page aswell as Toolbar 1. Wrong context cookie clearing
|
| test.beforeEach(async ({page, browser}) => { | ||
| const context = await browser.newContext(); | ||
| await context.clearCookies(); | ||
| await goToNewPad(page); | ||
| }); |
There was a problem hiding this comment.
1. Wrong context cookie clearing 🐞 Bug ☼ Reliability
The new RTL enforcement test creates a fresh BrowserContext and clears its cookies, but then navigates using the existing page fixture from a different context, so the cookie clear is a no-op and the newly created context is leaked (never closed). This can make the regression test not reliably start from a clean cookie state and can exhaust resources over the suite run.
Agent Prompt
### Issue description
`rtl_pad_wide_enforce.spec.ts` calls `browser.newContext()` and `context.clearCookies()`, but continues using the existing `page` fixture, so cookies are not cleared for the page under test. The created context is also never closed.
### Issue Context
Other frontend-new specs document this exact Playwright pitfall and use `page.context().clearCookies()` to clear cookies for the active page context.
### Fix Focus Areas
- src/tests/frontend-new/specs/rtl_pad_wide_enforce.spec.ts[14-18]
### Suggested fix
Option A (simplest, matches intent):
- Replace the beforeEach body with:
- `await page.context().clearCookies();`
- `await goToNewPad(page);`
- Remove the unused `browser` fixture parameter.
Option B (if you truly need a separate context):
- Create `const context = await browser.newContext(); const page = await context.newPage(); ...` and ensure `await context.close()` in `afterEach`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
cf3145a to
cf5208b
Compare
The pad creator is never "enforced upon themselves" (isPadSettingsEnforcedForMe is false whenever canEditPadSettings is true), so getEffectivePadOptions always merges their personal view overrides (cookies) on top of the pad-wide options. As a result, a creator who had at some point toggled e.g. their personal "Read content from right to left" carried a stale rtlIsTrue=false cookie that silently masked the pad-wide value they later set — toggling the pad-wide control (and then enforcing it) appeared to do nothing on the creator's own screen. Fix: when the creator changes a pad-wide view option, sync their personal pref to the chosen value so their own view adopts the pad-wide setting immediately. This deliberately does NOT change the precedence model — the creator can still override the setting afterwards via the "My view" controls, so the existing behaviour where a creator keeps personal overrides while enforcing settings for other users (pad_settings.spec.ts) is preserved. Adds a frontend test reproducing the stale-personal-cookie scenario. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…7900) browser.newContext()+clearCookies() cleared cookies on a throwaway context (not the page fixture under test) and leaked the context. Use page.context().clearCookies() so the regression test reliably starts without a stale rtlIsTrue pref. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
cf5208b to
2c20e27
Compare
Found while fixing #7900 (split out from #7901, which covers the page-flip bug).
Problem
After the pad creator has at some point toggled their personal "Read content from right to left", setting pad-wide RTL (and enforcing it) does nothing on the creator's own screen — the content stays LTR.
Root cause
The pad creator is never "enforced upon themselves" (
isPadSettingsEnforcedForMe()is false whenevercanEditPadSettings()is true), sogetEffectivePadOptions()always merges their personal view overrides (cookies) on top of the pad-wide options. A stalertlIsTrue=falsecookie therefore silently masks the pad-wide value the creator just set.Fix
When the creator changes a pad-wide view option, sync their personal pref to the chosen value (
changePadViewOption→setMyViewOption), so their own view adopts the pad-wide setting immediately.This deliberately does not change the precedence model: the creator can still override the setting afterwards via the "My view" controls. The existing behaviour where a creator keeps a personal override while enforcing settings for other users (
pad_settings.spec.ts) is preserved — verified that whole spec still passes.Test
rtl_pad_wide_enforce.spec.tsreproduces the stale-personal-cookie scenario: toggle personal RTL on/off, then set pad-wide RTL, and assert the creator's content flips to RTL (and the personal control reflects the synced value). Verified red→green and confirmedpad_settings.spec.tsstill passes.🤖 Generated with Claude Code