Skip to content

fix: restore unsent drafts after browser navigation - #68

Merged
kahme247 merged 3 commits into
ompweb-dev:mainfrom
andrebrait:fix/persist-unsent-drafts
Sep 10, 2026
Merged

kahme247 merged 3 commits into
ompweb-dev:mainfrom
andrebrait:fix/persist-unsent-drafts

Conversation

@andrebrait

@andrebrait andrebrait commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Unsent composer text was kept only in an in-memory map, so a full browser Back/Forward navigation or reload discarded it. Persist text in tab-scoped sessionStorage and hydrate the existing draft map in each fresh document.

  • Keep existing conversation/new-workspace keys and the 50-draft cap.
  • Clear stored text on send/clear, empty text, and eviction so stale drafts do not return.
  • Preserve in-memory editing when storage is denied or full. Attachments deliberately remain in memory only.
  • Document recovery behavior in the three existing READMEs. No beforeunload warning or navigation interception; no new dependencies.

Verification

  • Regression reproduced against the original code, then passed after the fix.
  • Fresh-document tests cover exact multiline Unicode recovery, key isolation, clearing, eviction, attachment-only replacement, and denied storage.
  • npm run release:check: typecheck, lint, 628 tests passed / one platform-specific skip, production build passed.
  • Actual production browser smoke with isolated HOME/agent directory/workspaces: Chromium mobile/touch emulation at 390x844; Back to about:blank → Forward and a fresh reload restored the full multiline draft; new-workspace draft survived separately; clearing followed by reload stayed empty. No page errors. This is emulation, not physical-phone verification.
  • One condensed adversarial review approved contract, correctness/hostile input, test honesty, and simplicity.

Scope and limitations

Recovery is best effort within the same browser tab while storage remains available. Images/files are not persisted. Existing FIFO retention is bounded to 50 drafts. No deployment or installed-package changes.

Review follow-up

Fixed Copilot's stored-overflow finding in 68bb4b3: snapshot storage keys, remove overflow beyond 50 on restore, and preserve unrelated settings. The new fresh-document regression failed before the correction and passes afterward. Final production browser smoke also confirmed 55 stored drafts are pruned to 50, unrelated storage survives, and Back/Forward plus clear/reload still work. Final Windows/Linux CI: https://github.com/andrebrait/ompweb/actions/runs/34480437640 . Empty stored values are also removed in ef1d51c; the same malformed-storage regression verifies this and preservation of unrelated settings.

@andrebrait

Copy link
Copy Markdown
Collaborator Author

Fork CI passed all gates for f2ee487 on both Windows and Linux: https://github.com/andrebrait/ompweb/actions/runs/34477574109 . Upstream Actions requires maintainer approval. Copilot and CodeRabbit review requested on the CI mirror: https://github.com/andrebrait/ompweb/pull/7 . No deployment or installed-package changes.

@andrebrait

Copy link
Copy Markdown
Collaborator Author

Final head ef1d51c is green on Windows and Linux: https://github.com/andrebrait/ompweb/actions/runs/34480437640 . Copilot recommends approval with zero new comments: https://github.com/andrebrait/ompweb/pull/7#pullrequestreview-5167497792 . CodeRabbit completed review of the same head with no actionable comments and minimal merge risk: https://github.com/andrebrait/ompweb/pull/7#issuecomment-5618760888 . Its generic docstring-coverage warning is informational; no boilerplate comments or lowered thresholds were added. Both storage-cleanup findings have regression-tested fixes. Upstream Actions still requires maintainer approval; nothing was deployed or installed.

@kahme247
kahme247 merged commit 01fc51a into ompweb-dev:main Sep 10, 2026
@andrebrait
andrebrait deleted the fix/persist-unsent-drafts branch September 14, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants