fix: check settings write result before applying in desktop UI - #4520
Conversation
|
@coderabbitai review |
|
/review |
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? |
Greptile SummaryThe PR makes desktop settings writes persist before updating local state, reports rejected writes, serializes concurrent writes, and gates UI effects on successful persistence.
Confidence Score: 4/5The PR is not yet safe to merge because the outstanding reset and pending-target interaction can persist and display the wrong text size. The reset shortcut queues 15 px without replacing the pending zoom target, so a subsequent rapid zoom step advances from the stale value and can leave both persisted and displayed size at 18 px rather than 16 px. Files Needing Attention: src/praisonai-desktop/ui/index.html
|
| Filename | Overview |
|---|---|
| src/praisonai-desktop/ui/index.html | Settings writes are now serialized and failure-aware, but the reset shortcut still bypasses pending text-size synchronization and can persist the wrong final size. |
| src/praisonai-desktop/frontend/tests/settings-effects.test.mjs | Adds focused rejected-write and rapid-step coverage using an isolated settings endpoint stub. |
Reviews (3): Last reviewed commit: "test: reflect POST /settings echo in stu..." | Re-trigger Greptile
|
@claude You are the FINAL architecture reviewer. If the branch is under MervinPraison/PraisonAI (not a fork), you are able to make modifications to this branch and push directly. SCOPE: Review changes in this PR. Python SDK: praisonaiagents, praisonai. TypeScript SDK: src/praisonai-ts/. Do NOT modify src/praisonai-rust. Read ALL comments above from Gemini, Qodo, CodeRabbit, and Copilot carefully before responding. Phase 1: Review per AGENTS.md
Phase 2: FIX Valid Issues Phase 3: Final Verdict |
|
Claude finished @MervinPraison's task —— View job Final Architecture Review — PR #4520 ✅Verdict on the original change: Correct and valuable. The persist-then-mutate refactor makes desktop settings writes transactional — theme, toggles, and text size no longer diverge from what actually persisted. In scope (desktop Valid issue fixed (Greptile P1 — a regression this PR introduced)Moving the Fix (
Test (
TestingFull desktop suite: 179/179 pass ( Skipped / not changed
Recommendation: Approve & merge. The originally-reported bug is fixed and the one valid reviewer concern (Greptile P1) is resolved with test coverage.
|
| // Once the queue drains, drop the optimistic target so the next burst starts | ||
| // from CFG again -- and a failed write does not leave us stepping from a size | ||
| // that never persisted. | ||
| if(pendingTextSize===px) pendingTextSize=null; |
There was a problem hiding this comment.
When the user rapidly presses zoom-in, reset, then zoom-in again, reset queues 15 without updating pendingTextSize, so the final step advances the stale pending value from 16 to 18. The writes persist 16, 15, then 18, leaving the displayed and stored size at 18 px instead of the expected 16 px.
|
@claude this PR has merge conflicts with |
|
Claude finished @MervinPraison's task —— View job Rebase complete ✅Rebased
Files resolved
TestsFull desktop suite: 180/180 pass ( Skipped / not changed
|
…4497) saveCfg mutated CFG/cfg and applied prefs before POSTing /settings, with no r.ok check and no catch. A rejected write (e.g. across the engine restart the base_url/api_key rows warn about) left the theme button dead, toggles diverged from stored state, and setTextSize toasted success while every write failed. saveCfg now persists first, mutates only on r.ok, toasts on failure, and returns a boolean. apply() and setTextSize gate their visible effects on it. Co-authored-by: MervinPraison <MervinPraison@users.noreply.github.com>
Moving the CFG mutation to after the await made rapid text-size steps read stale state, collapsing bursts and letting overlapping writes land out of order. Queue writes FIFO and step from the pending target so bursts accumulate (fixes Greptile P1). Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
… write After rebasing onto main, saveCfg reconciles the server's echoed settings back into CFG. The stub returned the original settings for both GET and POST, so the persisted step was overwritten and rapid text-size steps collapsed. Echo the written patch like the real engine does. Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
a19a22a to
e8b82ad
Compare
|
Merge gate scan — eligible for assessment. Claude merge gate will assess and may auto-merge if |
|
Merged by Claude PR merge gate ( |
Fixes #4497
Problem
saveCfgmutatedCFG/cfgand calledapplyPrefsbeforeawait fetch(POST /settings), with nor.okcheck and nocatch.applyawaited it and unconditionally ranapplyTheme/renderSettings;setTextSizedidn't even await.When the write was rejected — which the
base_url/api_keyrows explicitly warn happens across an engine restart:data-theme, no highlight, no error.cfgmoved in memory but the switch never moved, and the next click flipped the invisible one back.Fix (
ui/index.html)saveCfgnow persists first, mutates only onr.ok, toastsCould not save that setting.on failure, and returns a boolean.applygatesapplyTheme/model name/renderSettingson that boolean (if(!await saveCfg(...)) return;).setTextSizeawaits and only toasts the size that actually stuck.Minimal, backward-compatible; no new params, deps, or exports.
Tests (
frontend/tests/settings-effects.test.mjs)Added a
failSettingsWriteoption to the harness (stubsPOST /settingsas 500) and two tests:data-themestays off) and surfaces a toast.Verified these two fail against the pre-fix code and pass with the fix. Full desktop suite: 178/178 pass.
Generated with Claude Code