GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor: break the last two runtime import cycles (app current-server, codemode VM) by opencode-agent[bot] · Pull Request #64449 · anomalyco/opencode

Conversation

@opencode-agent

@opencode-agent opencode-agent Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

None. These are the last two runtime import cycles from the weekly V2 import-graph audit.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Breaks the two remaining eager import cycles on dev.

App current-server (runtime.tsx → client.tsx / notification.tsx → current.tsx → runtime.tsx)

current.tsx imported useGlobal from runtime.tsx only to read the server's health and controller, and runtime.tsx imports modules that call useServer. Now:

  • The Server context takes health as a prop and imports only types from ./runtime.
  • ServerProvider, which needs useGlobal, moves to runtime.tsx. Its 7 importers now import it from @/runtime/server/runtime.
  • The stories mock for @/runtime/server/current exports ServerContextProvider instead of its own ServerProvider, so stories render through the real provider.

Codemode VM SCC (15 files)

  • Mode, FrameMode, Frame, CustomIter and VmInternalFn move from vm.ts to a new leaf frame.ts. async.ts, generators.ts, host.ts and internal-prelude.ts now import only type Vm.
  • Vm.capture and Vm.restore are removed. execute.ts and the tests call captureVm and restoreVm from snapshot.ts directly, so vm.ts no longer imports snapshot.ts. The private initIntrinsics becomes an idempotent ensureIntrinsics(), which both of those functions call first.
  • The Interpreter and AsyncFromSyncIterator class specs move out of the generic snapshot/codec.ts and into snapshot.ts's vmSpecs. The codec no longer imports the VM, so runtime/extensions.ts → codec and prelude/bytecode.ts → snapshot/snapshot.ts → codec stop closing the loop.
  • generators.ts creates its single promise capability with vm.scheduler.resolving(vm.scheduler.newPromise(), site), which is what capability does. This drops the generators.ts ↔ runtime/promises.ts pair.

Moving the two specs changes the order of codecShape and therefore buildId(). A snapshot saved by an older build is rejected, as it already is on any other build change.

How did you verify your code works?

  • An eager-import SCC check over packages/app/src (with @/ resolved) and packages/codemode/src (with .js resolved to .ts) finds no cycles. The only remaining hits are the intentional export * as X from "./self" namespace self-imports.
  • packages/codemode: bun run typecheck, tsc --noEmit, bun test (1655 pass), and CODEMODE_ROUNDTRIP=1 bun test (1655 pass).
  • packages/app: bun run typecheck and bun run test:unit (2738 pass).
  • bun run lint:changed is clean. oxlint shows no new findings in codemode.
  • The stories Vite build gets through bundling, so the mock exports resolve. It then runs out of memory while computing gzip sizes in this sandbox.

Screenshots / recordings

No UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Requested by: @jlongster (James Long via Slack)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
James Long @opencode-agent
refactor: break the app current-server and codemode VM import cycles
fb87e6d
App: current.tsx no longer imports runtime.tsx. The Server context takes
the server's health as a prop, and ServerProvider, which reads useGlobal,
moves to runtime.tsx.

Codemode: Mode, Frame, CustomIter and VmInternalFn move to frame.ts so the
VM's helper modules import only the Vm type. Snapshots no longer run
through Vm: captureVm and restoreVm are called directly, and the
Interpreter and AsyncFromSyncIterator codec specs move from the generic
codec to snapshot.ts. generators.ts makes its promise capability through
the scheduler instead of importing runtime/promises.ts.
@opencode-agent opencode-agent Bot assigned jlongster Nov 17, 2026
@github-actions github-actions Bot added the contributor label Nov 17, 2026
opencodejr[bot]
opencodejr Bot reviewed Nov 17, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The codemode changes look correct: the new generators.ts call does exactly what capability did, the codec picks a class by its exact constructor, and every snapshot encode/decode still passes vmSpecs(), so moving the two specs only changes buildId() as described. The app runtime move also looks right; health stays reactive because Solid turns JSX props into getters.

What I ran on the PR head: in packages/codemode, tsc --noEmit is clean, bun test gives 1655 pass and 0 fail, and CODEMODE_ROUNDTRIP=1 bun test gives 0 fail. In packages/app, tsc --noEmit is clean and bun run test:unit gives 2738 pass and 0 fail.

Public API: unchanged. The codemode snapshot format is internal and already rejected across builds.

One thing worth fixing before merge: in stories, the real ServerProvider no longer fills the context that the mocked useServer reads, so story components under it fall back to stub data (see the inline comment). I found this by reading the alias config and haven't confirmed it in a stories build.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/app/src/runtime/server/runtime.tsx
import { useServerHealth } from "@/runtime/server/health"
import { selectServerHostname } from "@/runtime/server/health-machine"
import { createServerSdkContext } from "./client"
import { ServerContextProvider } from "./current"

@opencodejr opencodejr Bot Nov 17, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In stories this import gets the real context, not the mock. The stories Vite alias only matches the exact path ^@\/runtime\/server\/current$, and ./current doesn't match, so ServerProvider fills the real current.tsx context. Meanwhile every story component calling useServer/useData from @/runtime/server/current reads the mock's own context, finds nothing, and gets the stub data. The mock's ServerContextProvider is never used, and DialogStoryRuntime / the unavailable-panel story lose the controller they got from global.serverCtx(key) on the base. Importing from @/runtime/server/current here would send it through the alias without bringing back the cycle.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@opencode-agent

opencode-agent Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Split into #64454 (app) and #64455 (codemode).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@opencode-agent opencode-agent Bot closed this Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@jlongster jlongster

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@jlongster
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.