GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(core): pull pending registry changes on read by kitlangton · Pull Request #45822 · anomalyco/opencode Conversation
|
| Operation | Before | After |
|---|---|---|
| Read after an awaited transform inside a batch | Previous snapshot | Latest accepted definitions |
| Read after reload is requested, before 500 ms elapses | Previous snapshot | Synchronous ordered replay |
| Repeated reads without another change | Cached snapshot | Cached snapshot, without another replay |
| Observer awaits another registration or reload | Can wait on the replay it is observing | No State replay lock or shared read flight |
| One batch observer or replay fails | Later states can lose their notifications | All pending notifications are attempted; failures remain observable |
The existing transform, Registration.dispose, and reload interfaces remain intact. Changing captured source data still requires reload; this is not automatic dependency tracking or a new contribution API.
The same OpenCode Drive fixture cold-starts with an expired, stored OAuth credential. The config endpoint stays healthy: it returns 401 for the expired token and 200 after refresh. This reproduces a startup ordering bug, not a DNS outage or a cache-recovery scenario.
Left: recorded base f6992059be. Right: recorded pre-rebase PR head be8f5a5242. The first three seconds show the same model-picker search; the next three show a prompt using the same saved model selection. The same after-scenario was rerun successfully on rebased head 57a079b874; this existing video retains its original, accurate revision labels.
| Verified observation | Before | After |
|---|---|---|
| OAuth refresh before the first cold-start config request | Skipped | Refresh completes first |
| Config response | 401 |
200 |
Search for Orbit Fixture |
No results found |
Orbit Fixture Model is listed |
| Stored credential | Remains expired | Refreshed credential is persisted |
| Prompt with the saved model | ModelUnavailableError; zero LLM requests |
One LLM request and a response |
The TUI, server, Console plugin, registration/lookup, OAuth refresh, and database persistence are real production code. The device-login, account, token, and inventory endpoint responses use a loopback fixture with dummy data; the LLM response is canned Drive output. Request order, the model-list API, and persisted credential expiry independently verify the result; the canned response is not evidence of OAuth behavior. Before's error is in the server log; the visible composer labels the saved model unavailable rather than displaying that error message.
Both runs use a fresh isolated database, a naturally expiring token, and the same loopback-only simulation transport adapter. No real provider account, live service, manual credential edit, or post-restart account/model switch is involved. The Console plugin and TUI source are identical between these revisions. Playback is side-by-side at normal speed, with setup and navigation omitted between matched checkpoints.
Precondition: the account is already connected, its stored access token has expired, and its refresh token is valid. Plugin activation runs setup inside State.batch. The HTTP endpoint can successfully refresh the token throughout both sequences.
sequenceDiagram
autonumber
participant P as Console plugin setup
participant I as Integration
participant H as OAuth/config endpoint
participant C as Catalog
participant U as TUI / Session
Note over P,C: Plugin.activate opens State.batch
P->>I: transform(register OAuth refresh handler)
I-->>P: Registration accepted, replay deferred
P->>I: connection.active("opencode")
I->>I: state.get() returns old snapshot
I-->>P: Stored connection still found in credentials
P->>I: connection.resolve(connection)
I->>I: Old snapshot has no refresh implementation
I-->>P: Fallback returns expired stored token
P->>H: GET /api/config with expired token
H-->>P: 401 Unauthorized
P->>P: Catch fetch failure<br/>providers = undefined
P->>C: Register transform reading captured providers
Note over P,C: All plugin setup finishes, activation batch closes
I->>I: Replay registrations<br/>refresh handler now visible
C->>C: Replay transform over providers ?? empty object
Note over P,C: No automatic rerun of load(), token resolution, or HTTP fetch
U->>C: List models
C-->>U: Orbit model absent
U->>U: Saved-model prompt fails with ModelUnavailableError
The Integration snapshot eventually catches up. The lasting failure is the plugin's captured result: making the handler visible later does not retry the earlier request, and replaying the catalog transform only reuses providers = undefined.
sequenceDiagram
autonumber
participant P as Console plugin setup
participant I as Integration
participant H as OAuth/config endpoint
participant C as Catalog
participant U as TUI / Session
Note over P,C: Plugin.activate opens State.batch
P->>I: transform(register OAuth refresh handler)
I-->>P: Registration accepted, snapshot marked dirty
P->>I: connection.active("opencode")
I->>I: state.get() synchronously replays pending transforms
Note over I: Refresh handler is now readable<br/>notifications remain batched
I-->>P: Stored OAuth connection
P->>I: connection.resolve(connection)
I->>I: Read cached implementation<br/>detect expired token
I->>H: POST /auth/device/token using refresh token
H-->>I: Fresh access token
I->>I: Persist refreshed credential
I-->>P: Fresh credential
P->>H: GET /api/config with fresh token
H-->>P: 200 OK with Orbit inventory
P->>P: Capture providers containing Orbit
P->>C: Register transform reading captured providers
Note over P,C: All plugin setup finishes, activation batch closes
I->>I: Publish deferred Integration update
C->>C: Rebuild if dirty<br/>publish Catalog update
U->>C: List models
C-->>U: Orbit model is listed
U->>U: Saved-model prompt reaches simulated LLM and responds
In this concrete path, connection.active() is the first read and performs the replay; connection.resolve() then sees the cached fresh implementation. The read itself does not perform HTTP: the subsequent explicit resolve() invokes refresh. Catalog reads can likewise pull accepted definitions before notification, without waiting for the batch to close.
Accepted registration, disposal, and reload operations invalidate the derived snapshot. State.get() rebuilds it with initial, ordered synchronous transforms, and optional synchronous prepare, then caches the result. A failed replay does not mark the previous snapshot fresh.
notify observes changes outside the read path. Batches coalesce notifications, not visibility; directly awaiting reload inside a batch accepts the invalidation without waiting for that batch to finish. Outside a batch, reload retains its trailing-edge notification debounce. Reading early does not consume the pending notification, and a state with no readers is rebuilt before notifying.
Reload callers in one debounce window share one Deferred, rather than a waiter array and completion fan-out. The cell is claimed before scheduling and cleared before observers run: cancelling one caller does not cancel the notification, and reentrant reloads get a separate completion window.
The old finalize hook mixed derived metadata with effects. Its consumers now make the distinction explicit:
notify only.prepare; scoped repository cache work stays in notify.The test-only follow-up replaces repeated State and Location construction with two small fixture helpers, uses explicit layers and virtual time for synthetic VCS/SSE cases, keeps real platform fixtures live, and makes cleanup ordering explicit. It removes 70 net lines across nine test/fixture files without dropping cases or assertions. Un-nesting existing cases adds Git diff churn; this is shorter test code, not a smaller additions/deletions counter or new production machinery.
This is a fresh v2 alternative to the pending read/flush fixes in #44813 and #45810, with regression coverage for the notification failures documented in #44843. It does not introduce another plugin lifecycle phase or change resource readiness: an available definition does not imply that an MCP handshake, Git checkout, or VCS refresh has finished. Bus-wide nested-event ordering, bounded SSE capacity/overflow behavior, and outside-batch atomic registration/disposal semantics remain unchanged.
Corrective VCS notifications converge after successful publication; transient older and duplicate notifications can still appear. This PR remains draft for independent review.
Rebased onto origin/v2 at d837ffe70f, producing head 57a079b874, on Effect 4.0.0-rc.112. All four commits are retained. The only manual conflict preserves upstream's Effect.fnUntraced(..., Effect.uninterruptible) wrapper while retaining the fresh OAuth implementation lookup inside Effect.sync(...).pipe(..., Effect.exit), so replay failure still settles the attempt. range-diff shows only the expected wrapper indentation and upstream MCP import context changes.
Current rebased-head verification: 279 Core tests passed, 990 assertions across 13 files, including State, OAuth activation/settlement, MCP/VCS ownership, Bus, and models.dev; 8 focused Server tests passed, including the actual bounded EventFeed. Full Core with the disclosed --timeout 30000 passed 3,837 tests, 40 skips, 0 failures, with 79,154 assertions across 225 files in 147.07 seconds. The full Server suite passed 40 tests, 3 existing skips, 0 failures, with 159 assertions. Core, Server, and WWW typechecks, formatting, and Effect structural checks passed. Normal pre-push typechecking passed all 33 tasks. No test deadline or skip was changed by this rebase.
The unchanged isolated Drive fixture also passed on 57a079b874: naturally expired stored OAuth, refresh before the first cold config 200, the fixture model visible in the real picker, one simulated LLM request with the same saved selection, and refreshed expiry persisted under the same credential identity. No live service or real provider account was used.
For 57a079b874, typecheck and normal PR Linux/Windows unit and e2e CI are now green. The first test attempt failed Linux's TUI assertion closing a tab is not undone by another TUI viewing the same session: persisted tabs still contained shared instead of []. This was an assertion failure, not a timeout. The test uses a fake HTTP client rather than Core State; TUI sources are unchanged by this PR. The first attempt checked out GitHub merge commit dc130469f6 against then-current v2 d0baff184b, not the standalone head tree. Windows freshly executed Core: 3,590 passed, 293 skipped, 0 failed. Locally on the head, the tab case passed 10 targeted repetitions, and its full file passed 96 cases / 207 assertions across three repetitions. The requested Linux unit-job rerun passed without any branch code or deadline change. The original Linux failure's cause remains unestablished; a successful rerun is not a claimed fix. The remaining CI history below belongs to earlier revisions.
For pre-rebase be8f5a5242, the normal PR Linux/Windows unit and e2e workflow and typecheck passed. A separate, expanded full-repository workflow still has a failed Windows result: its first attempt hit five-second deadlines in Linux's failing-shell-command test and Windows's Session UI source-import scan; both cleared on rerun. Attempt 2 passed Linux unit and both e2e jobs but hit the same deadline in Windows's project-identity-after-creation integration test. Those test files were unchanged from that base. Local normal-timeout repetitions passed 10 shell cases, 40 import-boundary checks, and 5 project-identity cases, but this does not prove the Windows CI cause. No code, skip, or deadline was changed in this branch, and a third automatic rerun was not requested.
The separate project-adoption fixture cleanup, #46009, is merged into v2 and included in this new base, retaining the same assertions and deadline. Its Linux/Windows unit and e2e workflow passed for 6ce6d92199, including fresh Windows Core execution with zero failures. The Session UI scan cleanup is owned by #45970. These separate results do not replace fresh CI for the rebased State-pull head.
# packages/core RECORD=false bun run test --timeout 30000 bun typecheck # packages/server, using Core's environment-isolating test wrapper RECORD=false bun run ../core/script/test.ts bun typecheck # packages/www bun typecheck bun run check:generated bun run build
73423fd3e2: blocked batch-observer shutdown, queued MCP work after owner closure, and stale final VCS delivery. Each new regression was verified failing before its fix. VCS coverage includes the real bounded EventFeed.make(bus.listen) SSE path, not only Bus subscriptions.07b5d00fb0: active MCP reconciliation surviving teardown, queued VCS refresh touching a closed layer, and a VCS replay exception permanently stopping filesystem refresh. Actual-service regressions reproduced all three before the fixes. Stronger teardown checks also prove shutdown and both reload callers settle before the fixture releases blocked I/O; the guard-only/direct-notify negative control failed all four boundary tests, and scoped execution plus per-event failure containment passed them.Plugin.activate. Coalesced reload coverage cancels one caller, verifies the surviving callers receive the same notification failure, and verifies a later reload recovers.be8f5a5242, affected Core suites on Effect rc.112: 216 passed, 0 failed, 837 assertions across 11 files, including upstream's additional plugin/MCP coverage. Bounded SSE feed and Server models: 8 passed, 0 failed, including existing encoding and overflow behavior. Earlier, the four new boundary regressions also passed 40/40 runs with --rerun-each 10.be8f5a5242, full Core suite with --timeout 30000: 3,839 passed, 39 skipped, 0 failed, 79,174 assertions across 225 files.SIGTERM as an inter-test error. Isolated npm passed 12/12; isolated Project passed 24, with 1 skip. Full-suite validation uses the explicitly disclosed --timeout 30000 CLI override; no fixture timeout was edited and no skip was added. The changed-area suites and 40 repeated boundary checks passed with the normal timeout.a629943c8e found no actionable change. Bounded probes covered replay/disposal recovery, debounce result isolation, caller cancellation, active/queued MCP and VCS teardown, and mixed interruption/defect causes. The implementation was left unchanged; 212 focused Core tests, 8 Server tests, both package typechecks, and the full Core suite were rerun successfully with the timeout policy above.a629943c8e via explicit workflow dispatch.e43f58d973. Its unit/e2e workflow failed in Linux's TUI tab-rendering test, not a changed file in this PR; Core's parallel test task was interrupted. On the rebased branch, the focused tab-status and session-row suites passed 22 tests / 139 assertions. Current-head CI is reported separately above.be8f5a5242, the full Server suite after upstream baseline repairs had 39 passed, 3 skipped, 0 failed, 136 assertions across 16 files. Upstream test: repair 19 pre-existing V2 test failures #45826 occupies both IPv4/IPv6 callback addresses, resolving the three previously documented baseline port-fixture failures. The three skips require an optional PTY binary. No Server runtime or callback-fixture repair is added by this PR.OAuth credentials and resource endpoints in tests are dummy or loopback fixtures. Verification did not restart a live service or use a real provider account.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Run MCP reconciliation and VCS state-driven refreshes in their layer-owned runtimes so shutdown cancels active and queued work. Contain VCS replay failures at the filesystem event boundary, and share one Deferred per reload debounce window.
Reuse small State and Location fixture constructors, use explicit Effect test layers and virtual time for synthetic providers, and ensure cleanup precedes registration disposal. Preserve regression cases, failure causes, and pre-release shutdown assertions.
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.