Repository navigation
refactor: architecture foundation — cycle-free imports, enforced layering, shared wire contract, CI-gated tests - #2199
Merged
Merged
Conversation
packages/app/ had no package.json (not a workspace) and contained a single stale, diverged copy of deep-link-bridge.ts resurrected at the pre-restructure path. The live file is apps/app/src/app/lib/deep-link-bridge.ts. Zero references to the orphan anywhere in apps/, packages/, ee/, scripts/. Tested: pnpm typecheck (clean).
Two runtime cycle edges cut:
- i18n/index.ts <-> app/constants.ts: LANGUAGE_PREF_KEY now lives in i18n
(where it's used); constants re-exports it. Kills the genuine runtime
cycle i18n -> constants -> i18n.
- lib/{openwork-server,opencode,den,den-telemetry}.ts no longer import the
1,199-line utils barrel (which drags in i18n + constants) just for
isDesktopRuntime: moved isElectronRuntime/isDesktopRuntime to new leaf
module lib/runtime-env.ts; utils re-exports for the 7 react-app callers.
madge --circular: 7 cycles -> 2, and both remaining close via import-type
edges only (extensions->types, den-session-events->den), i.e. zero runtime
cycles. Those type edges dissolve in the upcoming shared-contract step.
Tested:
- pnpm typecheck (clean)
- bun test tests/ — 51 pass, 2 fail: verified identical failures on base
via git stash (stale tests referencing removed exports, pre-existing)
- pnpm build (vite production build clean)
- live: vite dev server boots, / -> 200, transformed i18n/constants modules
serve with the new export graph
…react-app Fixes the three documented layering violations: - app-inspector.ts (zero-import window-global instrumentation) moves from react-app/shell to app/lib where analytics.ts can legally use it; the 8 react-app consumers now import from app/lib. - provider-list-query.ts moves from domains/connections to react-app/infra (it is shared query infrastructure used by kernel, shell, components, and connections — and infra already hosts query-client.ts). Kills the kernel -> domains edge in global-sync-provider. - BrowserPanelTab type moves to app/lib/desktop-types.ts (it describes desktop IPC bridge payloads); panel-tab-store re-exports it, so desktop.ts no longer reaches into the session domain. Invariant restored: grep 'react-app/' in src/app -> zero hits. Tested: - pnpm typecheck (clean) - bun test tests/ — 51 pass, 2 pre-existing failures (unchanged vs base) - pnpm build (vite production build clean) - live: vite dev server 200, analytics module serves with new import graph
packages/types gains src/workspace.ts: the canonical wire shape for
workspace records, unioned across what openwork-server emits (plain
optionals + opencode engine block) and what the desktop IPC bridge emits
(explicit nulls + openworkClientToken/openworkHostToken). This is the drift
that motivated the contract: each side had fields the other's type didn't
know existed, plus three different sandboxBackend vocabularies.
- apps/app: desktop-types.WorkspaceInfo is now an alias of WorkspaceWire;
openwork-server.ts drops its OpenworkWorkspaceInfo opencode{} patch type
(kept as plain alias for existing imports).
- apps/server: keeps its stricter internal interface but gains zero-runtime
compile-time tripwires asserting (1) every field fits the wire contract
and (2) no fields exist the contract doesn't know about. Future drift now
fails typecheck on the producer.
- @openwork/types added as devDependency of openwork-server (type-only,
erased at build; published artifact is bin/dist so npm consumers are
unaffected).
Tested:
- pnpm typecheck (app, clean) + tsc --noEmit in apps/server (clean)
- bun test apps/app tests/ — 51 pass (2 pre-existing fails unchanged)
- bun test apps/server — 215 pass (2 pre-existing better-sqlite3-under-bun
env failures, verified identical via git stash)
- pnpm build (vite production build clean)
- live: booted openwork-server (bun src/cli.ts), workspace registered,
/capabilities serves and enforces auth — new types import resolves at
runtime
The repo's strongest test suites never ran in CI (no bun setup, no test scripts), which let two app test files rot when #2016 removed the legacy message list: - session-sync-tool-parts.test.ts: drop the removed shouldDeferInProgressTool import; deferral behavior stays pinned via parseDynamicToolUIPart nulls and the end-to-end session-sync test. Unlocks 5 previously-crashed tests. - reasoning-display.test.ts: delete the markup test for the deleted SessionTranscript component (data-reasoning no longer exists in src); keep the DEFAULT_SHOW_THINKING product-default pin. - opencode-db.test.ts (server): probe better-sqlite3 by constructing an in-memory DB and describe.skipIf when the native binding cannot load under bun (oven-sh/bun#4290) — env failures become explicit skips that self-re-enable when bun gains support. - apps/app gains a 'test' script (bun test tests/); ci-tests.yml gains setup-bun + app and server unit-test steps before the e2e gate. Tested: - apps/app: bun test tests/ — 58 pass, 0 fail (was 51 pass / 2 crashed files) - apps/server: bun test — 215 pass, 6 skip, 0 fail (was 2 env fails) - tsc --noEmit in apps/server clean
The Solid entrypoint of @openwork/ui had zero import consumers (apps/app is fully React since the migration; the only reference was a cosmetic string in ui-demo). Removed src/solid/, its tsup/tsconfig, the ./solid export, and the solid-js peer dependency. Bigger win: every @openwork/ui export condition resolves to src/, so the dist/ output was referenced by nothing — yet apps/app prebuild/prebuild:web/ pretypecheck and all three ui-demo scripts rebuilt it (twice, react+solid) on every dev/build/typecheck. All five hooks removed; pnpm typecheck is now pure tsc and pnpm build skips the double tsup entirely. Tested: - pnpm install + root pnpm typecheck (clean, no tsup in the path anymore) - apps/app pnpm build (vite bundles @openwork/ui/react imports fine) - apps/ui-demo pnpm typecheck (clean)
…-free - den.ts no longer doubles as the Den type registry: the 14 wire types consumed across module boundaries (DenSettings, DenUser, DenOrg*, DenPluginConfig*, DenResourceSnapshot*) move to new leaf den-types.ts; den.ts re-exports them so its many importers are untouched. den-session-events and openwork-server now import the leaf instead of the 2k-line client implementation. - ReloadReason ownership flips from types.ts to extensions.ts (it is part of the extension manifest contract); types.ts re-exports. extensions.ts is now a leaf module. - types.ts imports OpencodeConfigFile/WorkspaceInfo from desktop-types (leaf) instead of the desktop bridge implementation. madge --circular on src/app + src/i18n: 0 cycles (7 when this branch started; the graph is now a DAG). Tested: - pnpm typecheck (clean) - bun test tests/ — 58 pass, 0 fail - pnpm build (vite production build clean) - live: vite dev server 200, den-types module serves
The doc still described the Solid-to-React migration: 'The Solid runtime still ships by default', src/react/** shims, Tauri-vs-web platform, and a porting pattern for a migration that finished long ago. src/react/ does not exist and there are zero solid-js references in src/. Rewritten around what is now true and enforced: - layer map including src/app (agnostic) + leaf modules (runtime-env, desktop-types, den-types, extensions) from this branch's refactors - dependency rules: app/i18n never import react-app, kernel/infra below domains, leaves import nothing, wire contracts in packages/types, madge --circular = 0 - current domain list (cloud, onboarding, sidebar, terminal, voice, ...) - kept the still-accurate route/state-ownership rules verbatim - testing section pointing at the now-CI-gated suites
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
A triggerless directory-level fs event arriving inside the debounce window
overwrote the pending named file trigger with undefined, so the emitted
reload event lost its trigger {name, path}. Event ordering is platform
dependent — this surfaced immediately as a macOS-only failure in
reload-events.e2e.test.ts once CI started running the server suite (this
branch), while passing on Linux and fast local runs.
Coalescing now keeps the existing named trigger unless the newer event
carries its own.
Tested: bun test src/reload-events.e2e.test.ts src/reload-watcher.test.ts
5x consecutive green; full server suite 215 pass / 6 skip / 0 fail;
tsc --noEmit clean.
On macOS, fs.watch can deliver directory events with no filename. The
workspace-root watcher then scheduled the config check without a trigger,
producing reload events missing trigger {name, path} — the remaining cause
of the macos-14 CI failure in reload-events.e2e.test.ts (Linux always
provides filenames, so ubuntu stayed green).
Mirror the inference ensureOpencodeRootWatcher already uses: resolve the
existing opencode.json(c) (and AGENTS.md for the agents reason) and
synthesize the trigger. checkReason only emits when the content fingerprint
actually changed, so inferred triggers cannot create spurious events.
Tested: reload suites + full server suite green locally (215 pass / 6 skip);
tsc --noEmit clean. Real validation is the macos-14 CI job on this PR.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Foundation refactor: 8 commits, net -397 lines, each individually tested and revertable.
1f5d2cc7epackages/app/orphan (diverged deep-link-bridge copy, zero refs)51bdff909LANGUAGE_PREF_KEY→ i18n (kills genuine i18n↔constants runtime cycle);isDesktopRuntime→ leaflib/runtime-env.tsso low-level clients stop importing the 1,199-line utils barrel18d199c12app-inspector(zero-import instrumentation) →app/lib;provider-list-query→react-app/infra;BrowserPanelTab→desktop-types. Invariant: zeroreact-app/imports insrc/app/efeff3d37packages/typesgains sharedWorkspaceWirecontract — the app↔serverWorkspaceInfoshapes had already drifted (client-only token fields vs server-only opencode block, 3 sandboxBackend vocabularies). App type is now an alias; server gets zero-runtime compile-time tripwires so future drift fails producer typecheck2de1a80c00bbf704a1@openwork/ui(zero consumers) + 5 vestigial build hooks —dist/was orphaned since all export conditions resolve tosrc/.pnpm typecheckis pure tsc now5cc673c4bden-types.ts;ReloadReasonownership → extension manifest contract. madge --circular: 0 (was 7)69175ec0aARCHITECTURE.md(claimed Solid still ships, src/react shims, Tauri) — now documents the real layout and the new enforced dependency rulesTests (ran locally, evidence per step in commit messages)
Live checks per step: vite dev server boots and serves the changed module graphs (200s); openwork-server boots with the new types import, registers a workspace, serves /capabilities with auth enforced.
No video: refactor-only PR with no user-visible UI change — the e2e suite + live boot checks above are the end-to-end evidence. Reviewer repro: the commands in the block above, plus
pnpm devfor a manual smoke.Follow-ups queued (tracked, each its own branch)
session-route/settings-route god-component decomposition · typed Electron IPC command map · server.ts route-registry split · extend contract pattern to the remaining 60 mirrored server types