Skip to content

feat(staged): add resilient web resume cache - #734

Merged
matt2e merged 1 commit into
mainfrom
reload-when-i-leave-web
Jun 27, 2026
Merged

feat(staged): add resilient web resume cache#734
matt2e merged 1 commit into
mainfrom
reload-when-i-leave-web

Conversation

@matt2e

@matt2e matt2e commented May 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add persistent web snapshot caching and invalidation for staged web sessions
  • Restore project, session, diff, and navigation state after page lifecycle reloads
  • Register service worker support and add cache, command, agent, and page lifecycle test coverage

@matt2e
matt2e requested review from baxen and wesbillman as code owners May 18, 2026 00:03

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b817705aa3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +623 to +624
export function getSessionMessages(sessionId: string): Promise<SwrResult<SessionMessage[]>> {
return cachedCommand('get_session_messages', { sessionId }, { ttl: 5 * 60_000 });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid caching live session message snapshots

In web/PWA mode this caches get_session_messages for five minutes, including empty or partial results while a session is still running. SessionModal.poll() calls getSessionMessages(sessionId) whenever messages.length === 0 and ignores revalidating; if the first poll caches [] before the agent emits output, every subsequent poll hits this fresh cache and never reaches the backend until the TTL expires, so live session output can appear frozen for up to five minutes. Running sessions should bypass this cache or use a much shorter/stale-only policy.

Useful? React with 👍 / 👎.

Comment on lines +254 to +255
export function listBranchesForProject(projectId: string): Promise<SwrResult<Branch[]>> {
return cachedCommand('list_branches_for_project', { projectId }, { ttl: 2 * 60_000 });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Invalidate branch-list cache after branch mutations

This introduces a two-minute fresh cache for branch lists, but branch-mutating commands such as renameBranch still update only local UI state and do not invalidate list_branches_for_project. After renaming a branch, any remount/navigation or cache-stale refresh that calls listBranchesForProject(projectId) within the TTL can reuse the old cached branch list and restore stale branch data until the cache expires. Please either invalidate this cache in all branch mutators or avoid fresh short-circuiting for branch lists.

Useful? React with 👍 / 👎.

@matt2e
matt2e force-pushed the reload-when-i-leave-web branch from b817705 to d84b179 Compare May 18, 2026 09:25
@matt2e
matt2e force-pushed the reload-when-i-leave-web branch from d84b179 to e5ee831 Compare May 26, 2026 10:49
@matt2e
matt2e force-pushed the reload-when-i-leave-web branch from e5ee831 to 0765166 Compare June 10, 2026 02:09
Add a stale-while-revalidate cache for command results and route the staged web UI through cached fetch helpers.

Register page lifecycle and cache invalidation listeners so the iOS web app resumes quickly while refreshing stale state in the background.

Force provider refreshes to revalidate rather than serving cached state.

Signed-off-by: Matt Toohey <contact@matttoohey.com>
@matt2e
matt2e force-pushed the reload-when-i-leave-web branch from 0765166 to 6606433 Compare June 22, 2026 07:16
@matt2e matt2e changed the title feat(staged): add PWA support with SWR cache and page lifecycle reload feat(staged): add resilient web resume cache Jun 27, 2026
@matt2e
matt2e merged commit fe54ac5 into main Jun 27, 2026
7 checks passed
@matt2e
matt2e deleted the reload-when-i-leave-web branch June 27, 2026 00:06
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.

1 participant