You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(desktop-control): ignore free pages in SQLite state size limit - #1301
Fix Invalid or oversized Desktop global state file when a valid Desktop SQLite state database grows beyond 32 MiB because of reusable free pages. The reported database was 48,848,896 bytes, passed SQLite integrity checks, and contained only 265,395 bytes of setting values; 11,849 of its 11,926 pages were free.
Keep the regular-file check for SQLite, but apply the 32 MiB read limit to the combined stored bytes of scope, key, and value instead of the physical database file size.
Check the payload size inside the existing read transaction, before materializing rows in JavaScript. Keep read-only access, schema-version handling, SQLite precedence, and the legacy JSON file-size limit.
Add regression coverage for a database inflated by deleted rows, stale legacy JSON, atom-state reconstruction, and aggregate multibyte payloads above the limit in both formats.
The loader does not compact or write the Desktop-owned database. This is limited to packages/desktop-control; no Harness semantics, public contracts, Rust code, or dependency versions change.
Minimal reproduction: create a version-1 settings database with a small valid setting, insert and delete a setting larger than 32 MiB without running VACUUM, then call readDesktopGlobalState. Previously, the loader rejected the database before reading its current settings. It now reads those settings while retaining the payload limit.
Related issues
N/A — encountered locally while displaying conversations in codexhost.
UI Demo
No visual changes: only the read-only Desktop global-state loader and regression tests change.
Test plan
Automated
Before the fix: node node_modules/vitest/vitest.mjs run --config tests/vitest.config.js packages/desktop-control/test/desktop-global-state.test.ts — 1 failed / 2 passed. The free-page regression failed with the original Invalid or oversized Desktop global state file error.
After the fix: node node_modules/vitest/vitest.mjs run --config tests/vitest.config.js packages/desktop-control/test/desktop-global-state.test.ts packages/desktop-control/test/remote-project-metadata.test.ts — 2 files, 5 tests passed. This covers successful reads from an inflated database, rejection of oversized JSON and SQLite payloads, and existing remote-project metadata behavior.
Local data validation
macOS 15.7.9 / arm64, Node.js 24.14.0; installed codexhost 0.28.1 via npm, local Codex Harness CLI 0.147.0; no SSH or Remote Control involved.
Called the patched TypeScript reader against a backup of the original affected 48,848,896-byte database, without compacting it: read succeeded with 46 top-level setting groups. SHA-256 before and after confirmed the database was unchanged. No private state or database files are included in this PR.
Full Codex Desktop version/build was not independently confirmed. Installing this branch into a running Desktop and end-to-end UI validation were not performed; the active session was kept running. Linux, Windows, and other Harnesses were not manually tested.
Full-repository checks are left to CI, following AGENTS.md.
This change lets Desktop global state load from SQLite databases that are large only because of free pages, while still bounding the actual stored payload. No concrete merge-blocking risk was found, and the change does not write to or compact the database.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
标题“fix(desktop-control): ignore free pages in SQLite state size limit”与变更内容一致。变更将 SQLite 的 32 MiB 上限改为按 scope、key、value 的合计字节数计算,不再按物理文件大小计算。空闲页(free pages)是问题根因,标题准确指出了这一点。标题简短,能让团队成员快速理解主要变更。
Description check
描述与变更内容直接相关。描述说明了问题现象(Invalid or oversized Desktop global state file)、根因(空闲页使数据库文件超过 32 MiB)、修复方式(按 scope、key、value 的字节合计做上限检查,并在读取事务内完成)、回归测试以及本地验证步骤。这些内容与 packages/desktop-control 中的读取逻辑和测试文件一致。
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Fix failing CI checks
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
Recent review details
Context from checks skipped due to timeout: 8
GitHub Check: CodeRabbit
GitHub Check: Check macos-26
GitHub Check: Check ubuntu-22.04
GitHub Check: Web Host tests
GitHub Check: Check windows-latest
GitHub Check: Vitest
GitHub Check: Check Linux ARM64
GitHub Check: Static checks
Additional context used
Code guidelines: 1
AGENTS.md — auto-discovered
Path-based instructions: 1
Source excerpt: Use package public exports for cross-package dependencies.
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
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
Fix
Invalid or oversized Desktop global state filewhen a valid Desktop SQLite state database grows beyond 32 MiB because of reusable free pages. The reported database was 48,848,896 bytes, passed SQLite integrity checks, and contained only 265,395 bytes of setting values; 11,849 of its 11,926 pages were free.scope,key, andvalueinstead of the physical database file size.The loader does not compact or write the Desktop-owned database. This is limited to
packages/desktop-control; no Harness semantics, public contracts, Rust code, or dependency versions change.Minimal reproduction: create a version-1
settingsdatabase with a small valid setting, insert and delete a setting larger than 32 MiB without runningVACUUM, then callreadDesktopGlobalState. Previously, the loader rejected the database before reading its current settings. It now reads those settings while retaining the payload limit.Related issues
N/A — encountered locally while displaying conversations in codexhost.
UI Demo
No visual changes: only the read-only Desktop global-state loader and regression tests change.
Test plan
Automated
node node_modules/vitest/vitest.mjs run --config tests/vitest.config.js packages/desktop-control/test/desktop-global-state.test.ts— 1 failed / 2 passed. The free-page regression failed with the originalInvalid or oversized Desktop global state fileerror.node node_modules/vitest/vitest.mjs run --config tests/vitest.config.js packages/desktop-control/test/desktop-global-state.test.ts packages/desktop-control/test/remote-project-metadata.test.ts— 2 files, 5 tests passed. This covers successful reads from an inflated database, rejection of oversized JSON and SQLite payloads, and existing remote-project metadata behavior.Local data validation
AGENTS.md.