Repository navigation
Conversation
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a focused server bug fix that prevents duplicate native-session imports while preserving ordinary retries and provider-instance isolation. The shared persistence change is localized, atomic, and supported by targeted integration coverage. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (10)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe importer now checks native Claude and Codex session bindings before creating imported threads. It skips matching sessions and uses reservation results to handle native ownership that appears during import. ChangesNative session import deduplication
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~45 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant AgentSessionImporter
participant ProviderSessionDirectory
participant ProviderSessionRuntime
participant ThreadStore
AgentSessionImporter->>ProviderSessionDirectory: list native bindings
ProviderSessionDirectory-->>AgentSessionImporter: return native session identifiers
AgentSessionImporter->>ProviderSessionDirectory: reserve with unlessNativeSessionId
ProviderSessionDirectory->>ProviderSessionRuntime: execute guarded upsert
ProviderSessionRuntime-->>ProviderSessionDirectory: return inserted boolean
ProviderSessionDirectory-->>AgentSessionImporter: return reservation result
AgentSessionImporter->>ThreadStore: create imported thread when reservation succeeds
Merge Risk: ⚪ Minimal · up to The importer now avoids duplicate native sessions while preserving normal import retries and provider-instance isolation. No actionable merge risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Reviewed CodeRabbit's linked-issue warning. Keeping project discovery unchanged is intentional: Removing an entire project candidate because it contains native history would also hide unrelated importable sessions. This PR protects the shared bulk-import path, including an atomic native-ownership check when reserving a new import binding. Session-level discovery UX and cross-environment deduplication remain separate scope. |
|
Note: GPT-6 on behalf of shivam (@shivamhwp). The native-ownership check is bypassed when retrying an import that already reserved its binding but failed before creating the thread. If the native binding appears after Apply the ownership guard when reusing a stopped reservation as well as when inserting a new one. Its result must tell the importer whether publication is allowed; checking that the import binding exists cannot distinguish an old reservation from one allowed by the current ownership check. Preserve ordinary retry recovery when no native owner exists. |
a28e060 to
f27bba3
Compare
[claude-opus-5-5] Responding on behalf of Guille@shivamhwp addressed in f27bba3 ( Regression coverage: |
|
Thanks for working on this. We merged the orchestrator V2 rewrite in #2829, and we are closing this PR as part of that transition. This change touches ProviderSessionDirectory.ts, ProviderSessionDirectory.ts, which the V2 merge removed. V2 replaces ProviderService and ProviderSessionDirectory with its session manager. Sorry for the extra work this creates. If the change is still needed on V2, please rebuild it on current main, verify it there, and open a new PR linking back here. We're closing the current implementation without assuming the underlying request is resolved. |
Problem
Bulk import could create a second thread for a Claude or Codex session that a native T3 thread already owned. The importer only checked the generated
import:thread ID, so the same session showed up twice in one environment (#10933).Change
Read runtime bindings once per import batch to skip known native sessions, scoped to the provider instance. Check native ownership again atomically in the SQLite statement that reserves each import binding (
INSERT ... SELECT ... WHERE NOT EXISTS), so bindings created during transcript scanning are caught too. The same guarded statement runs when a retry reuses a stopped reservation, andupsertreports whether publication is allowed. The importer skips publication when a native owner exists. Ordinary retries with no native owner still recover.This does not remove existing duplicates or deduplicate across environments. Project discovery keeps its path-based meaning; #10631 handles individual Claude attachment.
Scope and approval
Fixes the same-environment duplication in #10933. Maintainer triage identifies the bulk importer as the verified defect and makes a session-level discovery flag optional: #10933 (comment).
Verification
rechecks a reserved ...cases below.vp test run src/project/AgentSessionImporter.test.ts src/provider/Layers/ProviderSessionDirectory.test.ts src/serverRuntimeStartup.reconcile.test.tsinapps/server: 59 passed. This includesrechecks a reserved {codex,claudeAgent} import with native owner in {same instance,other instance,none}, unchanged native threads, no duplicate bindings, and provider-instance isolation.tsc --noEmitinapps/server: no errors.vp fmt --checkon the changed files is clean, andvp lintreports only existing warnings outside the changed lines.Original change made by GPT-6 via Codex. Rebase and verification refresh by Claude Opus 5.5 via Claude Code.