Skip to content

Commit 143752a

Browse files
authored
feat(ui): serve the upstream browser viewer (#298)
Port upstream v1.6.1's browser viewer as the codegraph-ui crate: a loopback server that answers the viewer API from an existing index (stats, search, node, source, file, routes, entry points, map, dead code, flow, screens, trails, and live updates over server-sent events) with upstream's wire shapes, limits, error codes and security boundary, serving the upstream ui/ frontend embedded in the binary, changed in one adapter line. - Engine ports the routes need, all read-only: dead code, named-symbol flow, flow continuations, symbol lookup, type hierarchy, ICU-order collation and the viewer's aggregate store queries; WatchOptions::observe_only lets the live channel reuse the watcher without writing the index. - codegraph ui (alias web), gated by CODEGRAPH_UI=1 exactly as upstream gates it. - A UI CI job rebuilds the committed bundle and fails on any drift. - Steps and screen navigation wait for their ports; docs/ui.md lists every difference from upstream. No extraction, resolution or schema change; golden output is unchanged.
1 parent 5b9e39b commit 143752a

241 files changed

Lines changed: 56395 additions & 86 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,29 @@ jobs:
229229
cargo test -p codegraph-extract --locked --test scan_symlinks
230230
cargo test -p codegraph-watch --locked symlink
231231
232+
ui:
233+
name: UI
234+
runs-on: ubuntu-24.04
235+
timeout-minutes: 20
236+
steps:
237+
- name: Checkout
238+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
239+
with:
240+
persist-credentials: false
241+
242+
- name: Set up Node.js
243+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
244+
with:
245+
node-version: "24"
246+
cache: npm
247+
cache-dependency-path: ui/package-lock.json
248+
249+
# npm ci from the committed lockfile, svelte-check, the vitest suites, a
250+
# production build, and a byte check that the embedded bundle under
251+
# crates/codegraph-ui/viewer is exactly this build.
252+
- name: Check, test and rebuild the viewer
253+
run: make ui-check
254+
232255
audit:
233256
name: Security Audit
234257
needs: workspace-version
@@ -306,7 +329,7 @@ jobs:
306329

307330
ci-success:
308331
name: CI Success
309-
needs: [workspace-version, linux, windows-clippy, windows-test, macos-watcher, audit]
332+
needs: [workspace-version, linux, windows-clippy, windows-test, macos-watcher, ui, audit]
310333
if: always()
311334
runs-on: ubuntu-24.04
312335
timeout-minutes: 5

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ target/llvm-cov/
3434
.aws/*.local
3535
.aws/*.rendered.local.json
3636
.aws/pipeline.rendered*
37+
38+
# The browser viewer's npm install (ui/); its build output is committed under crates/codegraph-ui/viewer/.
39+
node_modules/

‎.oxfmtignore‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ release-please-config.json
1414
docs/upstream-sync/UPSTREAM.md
1515
docs/upstream-sync/V1_5_COMMIT_MANIFEST.md
1616

17+
# The selected viewer design, transcribed from the Penpot boards: its tables
18+
# are numeric specs read against the board exports, so their layout is frozen.
19+
docs/design/viewer-d.md
20+
1721
# Golden artifacts are byte-compared by the equivalence/golden oracle tests
1822
# (include_str! / fs::read). Reformatting them breaks the test suite.
1923
reference/
@@ -40,6 +44,13 @@ KNOWN_DIFFS.md
4044
# Rust sources are formatted by `cargo fmt`.
4145
*.rs
4246

47+
# The browser viewer is vendored from upstream colbymchenry/codegraph (ui/,
48+
# MIT, see ui/LICENSE) and keeps upstream's formatting so it stays diffable
49+
# against the release it was imported from; svelte-check and the UI tests are
50+
# its gate. Its committed build output is generated, not authored.
51+
ui/
52+
crates/codegraph-ui/viewer/
53+
4354
# Build artifacts / vendored deps.
4455
target/
4556
dist/

‎AGENTS.md‎

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,19 @@ or required by that guidance.
7171
The workspace members are declared in root `Cargo.toml`; that manifest is the
7272
authority when the list changes.
7373

74-
| Crate | Owns |
75-
| -------------------------------- | ------------------------------------------------------------------ |
76-
| `codegraph-core` | shared types, config, IDs, file classification, logging |
77-
| `codegraph-extract` | language detection, tree-sitter/custom extraction, scan policy |
78-
| `codegraph-store` | SQLite schema/migrations, FTS5, persistence and queries |
79-
| `codegraph-resolve` | import/name resolution and framework resolvers |
80-
| `codegraph-graph` | traversal, impact, search scoring and query parsing |
81-
| `codegraph-mcp` | MCP schemas, rmcp transports, project resolution, tool rendering |
82-
| `codegraph-watch` | incremental synchronization and filesystem watching |
83-
| `codegraph-daemon` | shared process lifecycle, IPC, registries and detach behavior |
84-
| `codegraph-cli` (`codegraph-rs`) | CLI, installer, orchestration and shipped binary |
85-
| `codegraph-bench` | equivalence oracle and reproducible benchmark harness; not shipped |
74+
| Crate | Owns |
75+
| -------------------------------- | --------------------------------------------------------------------- |
76+
| `codegraph-core` | shared types, config, IDs, file classification, logging |
77+
| `codegraph-extract` | language detection, tree-sitter/custom extraction, scan policy |
78+
| `codegraph-store` | SQLite schema/migrations, FTS5, persistence and queries |
79+
| `codegraph-resolve` | import/name resolution and framework resolvers |
80+
| `codegraph-graph` | traversal, impact, search scoring and query parsing |
81+
| `codegraph-mcp` | MCP schemas, rmcp transports, project resolution, tool rendering |
82+
| `codegraph-watch` | incremental synchronization and filesystem watching |
83+
| `codegraph-daemon` | shared process lifecycle, IPC, registries and detach behavior |
84+
| `codegraph-ui` | browser viewer: loopback JSON API, live channel, embedded `ui/` build |
85+
| `codegraph-cli` (`codegraph-rs`) | CLI, installer, orchestration and shipped binary |
86+
| `codegraph-bench` | equivalence oracle and reproducible benchmark harness; not shipped |
8687

8788
Keep dependency direction acyclic and lower layers independent of presentation.
8889
Extraction must not depend on store/graph. Query rendering must not leak into core
@@ -93,17 +94,18 @@ semantics. See [`docs/architecture.md`](docs/architecture.md) for the current gr
9394
Run the narrowest relevant tests while iterating, then the complete gate before
9495
handoff. Do not use a narrow test to claim a workspace-wide property.
9596

96-
| Change | Minimum focused proof | Required documentation |
97-
| -------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
98-
| extraction/language rules | extractor tests; affected golden corpus; incremental/full equivalence | `languages.md`, `grammar-manifest.md`, and golden recipe when behavior moves |
99-
| resolution/framework rules | resolver unit/integration tests; ambiguity negatives; affected golden | `equivalence.md` or framework reference when public behavior moves |
100-
| schema/migrations/store | schema parity; migration replay; state/lease tests; golden equivalence | `data-model.md` |
101-
| graph/search | graph/query tests; deterministic ordering and limit cases | CLI/MCP docs for public output changes |
102-
| MCP/protocol | engine tests; structural MCP goldens; rmcp stdio/HTTP/version tests | `mcp.md` |
103-
| CLI/installer | command tests; installer round trips; script contract fixtures | `cli.md`, README only for landing-page behavior |
104-
| daemon/watch/concurrency | lifecycle, lock, recovery, watcher and platform-focused tests | architecture/CLI/MCP lifecycle sections |
105-
| release/install/checksum | shell/PowerShell fixtures, asset-name checks, archive smoke | README install section and release workflow contract |
106-
| docs/community files | `python3 scripts/docs-check.py`; formatter; link/anchor checks | update the canonical page, not a duplicate summary |
97+
| Change | Minimum focused proof | Required documentation |
98+
| ------------------------------ | ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------- |
99+
| extraction/language rules | extractor tests; affected golden corpus; incremental/full equivalence | `languages.md`, `grammar-manifest.md`, and golden recipe when behavior moves |
100+
| resolution/framework rules | resolver unit/integration tests; ambiguity negatives; affected golden | `equivalence.md` or framework reference when public behavior moves |
101+
| schema/migrations/store | schema parity; migration replay; state/lease tests; golden equivalence | `data-model.md` |
102+
| graph/search | graph/query tests; deterministic ordering and limit cases | CLI/MCP docs for public output changes |
103+
| MCP/protocol | engine tests; structural MCP goldens; rmcp stdio/HTTP/version tests | `mcp.md` |
104+
| CLI/installer | command tests; installer round trips; script contract fixtures | `cli.md`, README only for landing-page behavior |
105+
| daemon/watch/concurrency | lifecycle, lock, recovery, watcher and platform-focused tests | architecture/CLI/MCP lifecycle sections |
106+
| release/install/checksum | shell/PowerShell fixtures, asset-name checks, archive smoke | README install section and release workflow contract |
107+
| viewer (`codegraph-ui`, `ui/`) | crate tests over indexed fixtures; `cli_ui`; `make ui-check` (rebuilds and byte-checks the committed bundle) | `ui.md`; `cli.md` for the command |
108+
| docs/community files | `python3 scripts/docs-check.py`; formatter; link/anchor checks | update the canonical page, not a duplicate summary |
107109

108110
If a change alters nodes, edges, reference resolution, file classification, or
109111
stored graph meaning, decide explicitly whether the extraction version must move.
@@ -136,7 +138,10 @@ The authoritative local/CI entry point is:
136138
make check
137139
```
138140

139-
`make ci` is a compatibility alias for the same complete gate. `make pre-ci` adds a package/unpack/execute smoke over the built release bytes.
141+
`make ci` is a compatibility alias for the same complete gate. `make pre-ci` adds the
142+
viewer frontend gate (`make ui-check`: `npm ci`, svelte-check, vitest, a production
143+
build, and a byte check of the committed bundle under `crates/codegraph-ui/viewer`)
144+
and a package/unpack/execute smoke over the built release bytes.
140145
It validates workspace-version consistency before any Cargo subprocess, required
141146
tool versions, Rust and repository-text formatting, workflow/shell linting,
142147
Clippy with warnings denied, locked tests, a locked release build, guardrails,

‎Cargo.lock‎

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ members = [
88
"crates/codegraph-mcp",
99
"crates/codegraph-daemon",
1010
"crates/codegraph-watch",
11+
"crates/codegraph-ui",
1112
"crates/codegraph-cli",
1213
"crates/codegraph-bench",
1314
]

‎Makefile‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ OXFMT_ARGS := --no-error-on-unmatched-pattern --ignore-path .oxfmtignore .
1515
.PHONY: all build build-dev build-prod release release-target install uninstall \
1616
fmt fmt-rust fmt-oxfmt fmt-check fmt-rust-check fmt-oxfmt-check \
1717
tools-check workflow-lint docs-check workspace-version typecheck lint test guardrail script-tests archive-smoke \
18-
check ci pre-ci hooks setup-hooks clean size-compare help \
18+
check ci pre-ci ui ui-check hooks setup-hooks clean size-compare help \
1919
coverage coverage-html coverage-lcov coverage-open coverage-clean
2020

2121
all: build
@@ -139,7 +139,23 @@ check:
139139
@echo "All checks passed."
140140

141141
ci: check
142-
pre-ci: check archive-smoke
142+
pre-ci: check ui-check archive-smoke
143+
144+
# Rebuild the embedded viewer bundle (crates/codegraph-ui/viewer) from ui/.
145+
ui:
146+
cd ui && npm ci && npm run build
147+
148+
# The browser viewer's frontend (`ui/`, Node + npm): install from the lockfile,
149+
# type-check, test, rebuild, and require the committed bundle under
150+
# crates/codegraph-ui/viewer to be exactly that build. CI runs it as its own job.
151+
ui-check:
152+
cd ui && npm ci && npm run check && npm test && npm run build
153+
git diff --exit-code -- crates/codegraph-ui/viewer
154+
@stale="$$(git status --porcelain --untracked-files=all -- crates/codegraph-ui/viewer)"; \
155+
if [ -n "$$stale" ]; then \
156+
echo "the committed viewer bundle is not this build; commit crates/codegraph-ui/viewer:"; \
157+
echo "$$stale"; exit 1; \
158+
fi
143159

144160
archive-smoke:
145161
bash scripts/smoke-release-archive.sh
@@ -189,7 +205,8 @@ help:
189205
@printf '%s\n' \
190206
'Targets:' \
191207
' check / ci complete quality gate (ci is an alias)' \
192-
' pre-ci complete gate plus local archive smoke' \
208+
' pre-ci complete gate, viewer frontend, and local archive smoke' \
209+
' ui / ui-check rebuild the viewer bundle / also check, test, and byte-check it' \
193210
' fmt / fmt-check Rust plus repository text formatting' \
194211
' typecheck locked cargo check for the workspace' \
195212
' lint / test / release locked Rust gates and shipped build' \

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ make check
291291
- [`docs/architecture.md`](docs/architecture.md) — workspace and runtime design
292292
- [`docs/cli.md`](docs/cli.md) — complete command reference
293293
- [`docs/mcp.md`](docs/mcp.md) — MCP transports, tools, and clients
294+
- [`docs/ui.md`](docs/ui.md) — local browser viewer (preview, `CODEGRAPH_UI=1`)
294295
- [`docs/languages.md`](docs/languages.md) — language coverage and boundaries
295296
- [`docs/equivalence.md`](docs/equivalence.md) — deterministic golden contract
296297
- [`docs/upstream-sync/UPSTREAM.md`](docs/upstream-sync/UPSTREAM.md) — upstream ledger

‎crates/codegraph-cli/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ codegraph-graph = { path = "../codegraph-graph" }
2525
codegraph-mcp = { path = "../codegraph-mcp" }
2626
codegraph-resolve = { path = "../codegraph-resolve" }
2727
codegraph-store = { path = "../codegraph-store" }
28+
codegraph-ui = { path = "../codegraph-ui" }
2829
codegraph-watch = { path = "../codegraph-watch" }
2930
serde = { workspace = true }
3031
serde_json = { workspace = true }

0 commit comments

Comments
 (0)