fix(tui): avoid duplicate project initialization#22
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesInstance lifecycle coordination
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant StoreA
participant StoreB
participant InstanceStore
participant Initializer
participant Disposer
StoreA->>InstanceStore: load directory
InstanceStore->>Initializer: start initialization
StoreB->>InstanceStore: load same directory
InstanceStore-->>StoreB: join in-flight initialization
Initializer-->>StoreA: resolve shared instance
Initializer-->>StoreB: resolve shared instance
StoreA->>InstanceStore: dispose owner
InstanceStore-->>Disposer: retain instance while StoreB owns it
StoreB->>InstanceStore: dispose final owner
InstanceStore->>Disposer: dispose instance
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
8700272 to
9c51d8a
Compare
Ported from upstream anomalyco#35998.
Addresses Opus review of PR #22: if an in-flight instance init fiber was interrupted (owning layer scope closed mid-init), the shared entry.deferred was never settled and cross-store joiners parked on it hung forever. completeLoad now settles the deferred on every exit via Effect.ensuring. Deferred.interrupt proved insufficient (it only woke the creating store's awaiter, not cross-store joiners), so a concrete failure exit is used. Adds two regression tests: refcounted cross-store disposal, and settling on init interruption.
9c51d8a to
d81bbe1
Compare
Port of upstream anomalyco/opencode#35998.
Adds a process-local in-flight map with ownership tracking to the instance store so concurrent opens of the same directory share one bootstrap instead of racing duplicate initializations.
Verified:
bun test test/project/instance.test.ts(10 pass, includes new concurrency regression tests) andbun typecheckfrom packages/opencode. Applied cleanly.Summary by CodeRabbit
Bug Fixes
Tests