Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
"url": "https://github.com/rmk40/opencode-session-recall/issues"
},
"license": "MIT",
"engines": {
"opencode": ">=1.15.11"
},
"peerDependencies": {
"@opencode-ai/plugin": ">=1.2.0"
},
Expand Down
9 changes: 8 additions & 1 deletion src/cards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ export type CardsRuntime = {
semanticStatus(): SemanticStatus | undefined;
/** Force the next rank() to rebuild from the source (tests). */
invalidate(): void;
/** Prevent deferred semantic warm-up from touching its source after shutdown. */
dispose(): void;
};

function basename(path: string): string {
Expand Down Expand Up @@ -366,6 +368,7 @@ export function createCardsRuntime(deps: CardsRuntimeDeps): CardsRuntime {
let lastRevision: string | undefined;
let lastVectorsRevision: string | undefined;
let loaded = false;
let disposed = false;

/** Recompute/reuse card vectors and persist newly computed ones. Returns the
* store's `{ revision, committed }` result for the caller's own-write accounting,
Expand Down Expand Up @@ -543,7 +546,7 @@ export function createCardsRuntime(deps: CardsRuntimeDeps): CardsRuntime {
// no snapshot is loaded yet (the next query then rebuilds and embeds).
if (embedder && semanticWeight > 0 && deps.semanticReady) {
void deps.semanticReady.then(() => {
if (!embedder.ready || !loaded) return;
if (disposed || !embedder.ready || !loaded) return;
if (cardVectors && cardVectors.size > 0) return;
// Deliberately leave lastVectorsRevision untouched: this pass writes vectors
// (bumping vectors_rev past the cached value), so the next refresh reloads
Expand All @@ -554,6 +557,10 @@ export function createCardsRuntime(deps: CardsRuntimeDeps): CardsRuntime {
}

return {
dispose(): void {
disposed = true;
},

rank(query, filters): CardHit[] {
refreshIfStale();
const excluded = filters.excludeFamilyOf
Expand Down
Loading