Skip to content

Reuse memoizeAsyncWithTtl for the codex metadata scan#171

Merged
luckeyfaraday merged 1 commit into
mainfrom
refactor/codex-metadata-ttl-cache
Jun 20, 2026
Merged

Reuse memoizeAsyncWithTtl for the codex metadata scan#171
luckeyfaraday merged 1 commit into
mainfrom
refactor/codex-metadata-ttl-cache

Conversation

@luckeyfaraday

Copy link
Copy Markdown
Owner

Summary

Fold the inline codex metadata TTL cache into the shared memoizeAsyncWithTtl helper.

#169 bounded the workspace-independent ~/.codex/sessions metadata scan with a hand-rolled 30s cache. #170 then added memoizeAsyncWithTtl (client/electron/ttl-cache.ts) for the Hermes scan dedup — with identical semantics: share one in-flight promise per TTL window, never cache rejections. This PR removes the duplicated bookkeeping by reusing the helper for the codex scan too.

Change

  • Drop the module-level codexMetadataCache variable and the cachedCodexJsonlMetadata() function body.
  • Replace with const cachedCodexJsonlMetadata = memoizeAsyncWithTtl(CACHE_TTL_MS, scanCodexJsonlMetadata).

scanCodexJsonlMetadata is a hoisted function declaration and memoizeAsyncWithTtl defers invocation to first call, so there is no TDZ concern. No behavior change.

Stacking

Based on fix/hermes-session-scan-dedup (#170), since the helper lands there. Retarget to main once #170 merges.

Verification

  • npm run build:electron — clean
  • npm run test:electron — 138/138 pass

🤖 Generated with Claude Code

The codex `~/.codex/sessions` metadata scan (bounded in #169) carried its
own inline TTL cache with identical semantics to the `memoizeAsyncWithTtl`
helper added for the Hermes scan dedup (#170): share one in-flight promise
per TTL window, never cache rejections. Fold the codex cache into the shared
helper to remove the duplicated cache bookkeeping. No behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@luckeyfaraday luckeyfaraday deleted the branch main June 20, 2026 16:18
@luckeyfaraday luckeyfaraday reopened this Jun 20, 2026
@luckeyfaraday luckeyfaraday changed the base branch from fix/hermes-session-scan-dedup to main June 20, 2026 16:20
@luckeyfaraday luckeyfaraday merged commit 6e5fb92 into main Jun 20, 2026
@luckeyfaraday luckeyfaraday deleted the refactor/codex-metadata-ttl-cache branch June 20, 2026 16:22
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