GeezerVison is showing github.com — refactor(app): break the current-server import cycle by opencode-agent[bot] · Pull Request #64454 · anomalyco/opencode
Conversation
Issue for this PR
None. This is one of the last two runtime import cycles found by the weekly V2 import-graph audit.
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
Breaks the app current-server import cycle (runtime.tsx → client.tsx / notification.tsx → current.tsx → runtime.tsx). The codemode VM cycle is in #64455.
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.
How did you verify your code works?
- An eager-import SCC check over
packages/app/src (with @/ resolved) finds no cycles. The only remaining hits are the intentional export * as X from "./self" namespace self-imports.
packages/app: bun run typecheck and bun run test:unit (2738 pass).
bun run lint:changed is clean.
- 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.
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.
This was referenced Nov 17, 2026
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.
Requesting changes. The import cycle is gone, and type-check (tsc --noEmit) plus bun run test:unit (2738 pass) are clean in packages/app. Public API unchanged: these are app-internal modules only.
Two things to fix before merge:
- The commit undoes two recent fixes. Besides the refactor, it reverts #64443 (the browser pane stays live while resizing on macOS:
panel-motion.ts and its macOS test in browser-pane.spec.ts) and #64450 ("Use main checkout" stays on one line in selector.tsx). The commit's parent already contains both, so this looks like a stale working tree. Please drop those three files from the PR.
- Stories no longer use the mocked server context.
runtime.tsx imports ./current with a relative path, but the stories Vite alias only matches @/runtime/server/current. I checked with Vite's resolver: in stories, ServerProvider now provides the real current.tsx context, while components read the mock's useServer. Story components under ServerProvider therefore get the mock's fallback data, and the new ServerContextProvider in the mock is never used. Importing from @/runtime/server/current in runtime.tsx fixes this.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
import { useServerHealth } from "@/runtime/server/health"
|
|
|
import { selectServerHostname } from "@/runtime/server/health-machine"
|
|
|
import { createServerSdkContext } from "./client"
|
|
|
import { ServerContextProvider } from "./current"
|
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 relative import skips the ^@/runtime/server/current$ alias in packages/stories/vite.config.ts (Vite resolves ./current to the real current.tsx). So ServerProvider provides the real context, while story components read the mock's useServer and fall back to its default data. The mock's new ServerContextProvider is never used. import { ServerContextProvider } from "@/runtime/server/current" keeps the mock in place.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
|
|
|
/** Pass to a resize handle's `onDraggingChange` when its drag moves a panel that can hold a native view. */
|
|
|
export const setPanelResizing = (dragging: boolean) => setResizing(dragging && !/Mac/.test(navigator.platform))
|
|
|
export const setPanelResizing = (dragging: boolean) => setResizing(dragging)
|
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.
This reverts #64443 (the macOS check that keeps native views live during resize), and the macOS test in component-tests/browser-pane.spec.ts is removed with it. Neither is part of the import-cycle change, so please drop both files from this PR.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
<span class="shrink-0 whitespace-nowrap">
|
|
|
{language.t("session.new.workspace.useMainCheckout")}
|
|
|
</span>
|
|
|
<span>{language.t("session.new.workspace.useMainCheckout")}</span>
|
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.
This reverts #64450 (keeping "Use main checkout" on one line). It's unrelated to the refactor, so please drop it from this PR.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
The previous commit was cut from a stale tree and reverted panel-motion.ts,
its macOS browser-pane test and selector.tsx. Restore them from dev.
runtime.tsx imports ServerContextProvider as @/runtime/server/current so
the stories alias replaces it with the mock.
|
Addressed in f683b1a: restored panel-motion.ts, its macOS test in browser-pane.spec.ts, and selector.tsx from dev, which undoes the accidental reverts of #64443 and #64450. runtime.tsx now imports ServerContextProvider from @/runtime/server/current, so the stories alias swaps in the mock. The diff is now only the 10 intended files. App typecheck and unit tests (2738) pass, and the cycle check is still clean.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
All earlier points are fixed. The unrelated reverts of #64443 and #64450 are gone. runtime.tsx now imports ServerContextProvider through the @/runtime/server/current alias, and I confirmed with the stories Vite config that this resolves to the mock. The type check (tsc --noEmit) and bun run test:unit (2738 pass) are clean in packages/app. Public API unchanged. Nothing new to raise.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
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.
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.
|