Skip to content

W-22203667: add preview session store functions to utils#269

Closed
andresrivas-sf wants to merge 2 commits intomainfrom
W-22203667/preview-session-store
Closed

W-22203667: add preview session store functions to utils#269
andresrivas-sf wants to merge 2 commits intomainfrom
W-22203667/preview-session-store

Conversation

@andresrivas-sf
Copy link
Copy Markdown
Contributor

Summary

  • Moves all preview session store logic out of plugin-agent and into this library so the VS Code extension and the CLI share the same storage layer (per review feedback on W-22203667: add timestamp, session type, and index to agent preview sessions output salesforcecli/plugin-agent#400)
  • Adds createPreviewSessionCache, validatePreviewSession, removePreviewSessionCache, getCachedPreviewSessionIds, getCurrentPreviewSessionId, listCachedPreviewSessions to src/utils.ts
  • Introduces SessionType, PreviewSessionMeta, CachedPreviewSessionInfo, CachedPreviewSessionEntry types
  • Atomic write (temp file + rename) for the sessions index to reduce race conditions on concurrent start calls
  • All new functions exported from src/index.ts

Test plan

  • 19 new tests added in test/utils.test.ts covering create, validate, remove, list, index ordering, removal from index, and directory-scan fallback
  • All 132 unit tests pass (yarn test:only)
  • Lint clean (yarn lint)

@W-22203667@

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@andresrivas-sf andresrivas-sf requested a review from a team as a code owner April 27, 2026 13:51
andresrivas-sf added a commit to salesforcecli/plugin-agent that referenced this pull request Apr 27, 2026
The file:../agents dependency breaks CI since runners only clone this repo.
Restore the full inline implementation and ^1.1.2 semver until
forcedotcom/agents#269 merges and a new version is published, at which
point previewSessionStore.ts can become the thin shim again.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
W-22203667

- Add createPreviewSessionCache, validatePreviewSession, removePreviewSessionCache,
  getCachedPreviewSessionIds, getCurrentPreviewSessionId, listCachedPreviewSessions
  to utils.ts so VS Code extension and CLI share the same storage layer
- Introduce SessionType, PreviewSessionMeta, CachedPreviewSessionInfo,
  CachedPreviewSessionEntry types
- Use atomic write (temp file + rename) for the index to avoid partial writes
- Export all new functions and types from index.ts
- Add tests covering create, validate, remove, list, ordering, fallback dir scan

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@andresrivas-sf andresrivas-sf force-pushed the W-22203667/preview-session-store branch from 3f400be to ac831be Compare April 27, 2026 14:09
@andresrivas-sf
Copy link
Copy Markdown
Contributor Author

Superseded by #270 — rebased onto origin/main to exclude the unrelated SKILL.md commit from the diff.

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