Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): prevent duplicate and subagent history imports #11807

Closedadamblumoff(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/11807/headopened View on GitHub

Showing 12 changed files with 41 additions and 6 deletions (loading 11).

x
0 of 12 viewed, 12 left
41 additions and 6 deletionsapps/server/src/persistence/ProviderSessionRuntime.tsModified
View file
@@ -67,6 +67,8 @@
​
export interface ProviderSessionRuntimeUpsertOptions {
readonly onConflict?: "update" | "ignore";
+ readonly unlessNativeSessionId?: string;
+ readonly sharedHomeInstanceIds?: ReadonlyArray<ProviderInstanceId>;
​
/**
@@ -84,7 +86,7 @@
readonly upsert: (
runtime: ProviderSessionRuntime,
options?: ProviderSessionRuntimeUpsertOptions,
- ) => Effect.Effect<void, ProviderSessionRuntimeRepositoryError>;
+ ) => Effect.Effect<boolean, ProviderSessionRuntimeRepositoryError>;
​
/** Record one source file without replacing the current session state. */
readonly recordImportedTranscript: (
@@ -234,8 +236,15 @@
});
​
- const insertRuntimeRow = SqlSchema.void({
- Request: ProviderSessionRuntimeDbRowSchema,
+ // A no-op conflict update lets RETURNING report allowed reuse without changing the binding.
+ const insertRuntimeRow = SqlSchema.findOneOption({
+ Request: ProviderSessionRuntimeDbRowSchema.mapFields(
+ Struct.assign({