Skip to content

fix(workspace): keep local files out of localStorage - #2866

Merged
openai0229 merged 2 commits into
mainfrom
fix/local-file-workspace-storage-quota
Sep 2, 2026
Merged

openai0229 merged 2 commits into
mainfrom
fix/local-file-workspace-storage-quota

Conversation

@openai0229

@openai0229 openai0229 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Related issue

N/A - reported through a direct customer reproduction; no existing Issue was found.

Summary

  • keep local SQL, Markdown, and other text-file bodies out of the persisted workspace localStorage payload while preserving file metadata
  • reload restored local text tabs through the existing workspace file reader with path, directory token, relative path, encoding, and tab identity
  • migrate and immediately rewrite legacy persisted workspace state so open and recently closed local-file bodies are removed on hydration
  • update closed-tab state atomically and prevent synchronous storage quota failures from interrupting UI state changes
  • cover 2.8 MiB local files across SQL, Markdown, TXT, and JSON plus quota failure, recovery, legacy migration, and directory access metadata

Affected surfaces

  • Frontend / Web
  • Backend / API / Storage
  • Database plugin / Driver
  • JCEF / Desktop packaging
  • CI / Build / Release
  • Documentation only

Verification

  • Commands and results:
    • yarn install --frozen-lockfile - passed; generated the isolated worktree Umi setup
    • yarn test:local-file-encoding - passed
    • yarn test:saved-console-lifecycle - passed
    • yarn test:editor-close - passed
    • yarn run lint - passed before and after rebasing onto current main
    • yarn run build:web:community --app_version=0.0.0 - passed after each implementation round, including all prebuild contract tests and production-bundle verification
    • CHAT2DB_FRONTEND_SRC_ROOT=<pr-community-src> yarn run build:web:desktop --app_version=0.0.0 in a clean Studio main worktree - passed at final PR head 88f4e8af; Community source lock, API contract, and Pro composition bundle verified
  • Manual verification: a Pro desktop dist was generated from final PR head 88f4e8af; the final 200 MiB local-file runtime reproduction is pending user execution.
  • UI evidence: N/A - persistence and recovery behavior has no visual design change.

Risk and compatibility

  • Public API or stored data: no API change; legacy workspace entries are migrated and rewritten without local file bodies, while local files on disk remain untouched.
  • Database or driver compatibility: N/A - no database or driver behavior changed.
  • Network, privacy, or security: local file bodies are no longer copied into browser localStorage; no network behavior changed.
  • Community / Local / Pro boundary: implementation remains in the shared Community frontend; a clean Pro desktop composition build passed. Studio should update its Community ref only after this PR is merged.
  • Backward compatibility: persisted tab metadata remains compatible; restored text tabs reread their path through the existing workspace file API. Existing behavior applies when a referenced file has been moved or deleted.

Reviewer map

  • Start here: chat2db-community-client/src/store/workspace/utils/workspaceTabPersistence.ts, then review versioned hydration in store.ts and the tested local-file reload request in localFileWorkspaceTab.ts.
  • Failure condition: a local file body appears in the persisted workspace payload, quota failure escapes a workspace write, legacy payloads are not rewritten, or a restored text tab drops directory access metadata.
  • Rollback or disable path: revert this PR.

Contributor declaration

  • I linked the Issue that defines this change.
  • I tested the affected behavior and reported the actual results above.
  • I did not include credentials, private data, or generated build output.
  • I disclosed substantial AI assistance below, or this PR contains no substantial AI-generated code.

AI assistance: OpenAI Codex investigated the failure path, implemented the scoped frontend changes and regression tests, addressed automated review findings, reviewed the diff, and ran the reported verification commands.

@openai0229
openai0229 requested a review from a team as a code owner September 2, 2026 04:51
@openai0229 openai0229 moved this to In Review in Chat2DB Community Sep 2, 2026

@github-actions github-actions Bot 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.

Reviewed 4b88216: 1 high, 1 medium, 0 critical findings. Request changes because the restored local SQL/TXT/JSON path can fail for files represented by persisted directory-handle metadata; legacy payload cleanup also does not rewrite localStorage during hydration. Coverage was limited to the five-file current GitHub API diff and related PR metadata; no tests or runtime checks were run.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by AI Pull Request Reviewer for #2866 · 22.1 AIC · ⌖ 0.848 AIC · ⊞ 17.4K

Comment thread chat2db-community-client/src/store/workspace/store.ts Outdated

@github-actions github-actions Bot 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.

Reviewed short SHA 970ee9f. Findings: 0 critical, 0 high, 0 medium. The prior blocking findings are addressed by handle-aware local-file reload and versioned hydration migration that sanitizes legacy persisted tabs. Merge recommendation: ready to merge. Coverage limit: review was limited to the current GitHub API diff, PR metadata, existing reviews, and line comments; no tests or runtime checks were run. ``

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by AI Pull Request Reviewer for #2866 · 4.11 AIC · ⌖ 2.76 AIC · ⊞ 27.8K

@github-actions
github-actions Bot dismissed their stale review September 2, 2026 05:10

Superseded by updated review from same workflow.

@openai0229
openai0229 force-pushed the fix/local-file-workspace-storage-quota branch from 970ee9f to 88f4e8a Compare September 2, 2026 05:18
@openai0229
openai0229 merged commit a829708 into main Sep 2, 2026
16 of 19 checks passed
@openai0229
openai0229 deleted the fix/local-file-workspace-storage-quota branch September 2, 2026 05:46
@openai0229 openai0229 moved this from In Review to Done in Chat2DB Community Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant