Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .claude/docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,25 @@ CodeXR is a VS Code extension (291 TS files under `src/`, in five layers since #
```
User command (context menu / tree / palette)
└─> src/features/analysis/commands/... (per-mode command handlers)
└─> src/core/analysis/launchers/launcherXRAnalysis.ts | launcherLivePanel.ts | launcherVisualizeDOM.ts
└─> launchers/launchPipeline.ts → creates a UnifiedAnalysisSession
└─> src/core/analysis/analysisOrchestrator.ts → session/sessionRegistry.ts (one session per targetKey)
└─> launch/launchKinds.ts resolveLauncher(kind, targetType)
└─> launchers/launcherXRAnalysis.ts | launcherLivePanel.ts | launcherVisualizeDOM.ts
└─> launchers/launchPipeline.ts → one transaction under launch/launchControl.ts
(abort signal + 10 min deadline + teardown stack; process → save → server → watcher)
├─> python/executePython.ts → spawns managed venv, runs python/main.py → JSON metrics
├─> src/core/charts/ → validates dimension mapping, fills HTML template
│ (chart registry + placeholder processing over templates/xr/...)
├─> scene-assets/*ComponentAsset.ts
│ → inlines browser runtimes from templates/components/**/*.js into the HTML
└─> session-servers/serverLaunchOrchestrator.ts (+ sessionServerManager)
└─> session-servers/serverLaunchOrchestrator.ts (SSE + file map keyed by session id)
└─> src/core/server (HTTP/HTTPS) serves the scene
└─> registered in src/core/server/registry → shown in sidebar tree (src/features/active-servers)
Live updates: core/analysis/watchers/* detect file changes → re-run Python →
core/analysis/session-servers/sseNotificationManager.ts → src/core/server/sse/SSEManager.ts → browser reloads data
src/core/server/sse/SSEManager.ts (by session id) → browser reloads data
```

Analysis types (what the table shows) and launch kinds (how a page is served) are descriptors in `core/analysis/launch/` (`analysisTypes.ts`, `launchKinds.ts`, `storageFolders.ts`); the server-capability, controller-view and snapshot-probe tables are derived from them. Checklist: `apps/vscode-extension/docs/adding-an-analysis-type.md`.

Three analysis modes share this pipeline: **XR** (A-Frame scene in browser/headset), **LivePanel** (2D webview panel), **DOM visualization** (HTML DOM structure in XR). Each mode has its own launcher and parser (`core/analysis/parsers/`); one shared requirement processor (`core/analysis/processors/FileRequirementProcessor.ts` → `analysisBootstrap.ts`) loads the templates the mode needs.

## Activation flow (`src/extension.ts`)
Expand All @@ -46,7 +51,7 @@ Three analysis modes share this pipeline: **XR** (A-Frame scene in browser/heads
| Module | Responsibility | Key files |
|---|---|---|
| `features/analysis/` | The ANALYSES section: the per-mode analysis commands (file, directory, DOM, clean), the tree and its subsections (active analyses, files/project by language, analysis settings), the workspace scan and the server watcher integration | `commands/analysisCommandRegistrations.ts`, `commands/analysisCommands.ts`, `commands/{file,directory,dom}/`, `views/AnalysisSectionProvider.ts`, `sections/active-analyses/activeAnalysesCommands.ts` (Active Analyses actions and export), `sections/settings/` (one folder per setting; `chartTypeCommandFactory.ts` and the two `shared*SettingCore.ts` at its root), `workspace/workspaceSnapshotService.ts`, `workspace/workspaceFileScanner.ts`, `services/serverWatcherIntegration.ts` |
| `core/analysis/` | **The analysis engine.** Pipeline: launchers, parsers, the requirement processor, sessions, session servers, watchers, refresh, the Python bridge, the scene-asset injection, the language tables | `analysisOrchestrator.ts`, `launchers/launchPipeline.ts`, `launchers/launcherXRAnalysis.ts`, `session/analysisSession.ts`, `session/sessionRegistry.ts`, `session-servers/sessionServerManager.ts`, `watchers/sessionWatcherManager.ts`, `python/executePython.ts`, `python/xrFieldSchemaService.ts`, `configuration/analysisConfigurationStorage.ts`, `languages/languageMetadata.ts`, `languages/supportedLanguages.ts` |
| `core/analysis/` | **The analysis engine.** Pipeline: launchers, parsers, the requirement processor, sessions, session servers, watchers, refresh, the Python bridge, the scene-asset injection, the language tables | `analysisOrchestrator.ts`, `launchers/launchPipeline.ts`, `launchers/launcherXRAnalysis.ts`, `session/analysisSession.ts`, `session/sessionRegistry.ts`, `launch/launchControl.ts`, `launch/analysisTypes.ts`, `launch/launchKinds.ts`, `session-servers/serverLaunchOrchestrator.ts`, `watchers/sessionWatcherManager.ts`, `python/executePython.ts`, `python/xrFieldSchemaService.ts`, `configuration/analysisConfigurationStorage.ts`, `languages/languageMetadata.ts`, `languages/supportedLanguages.ts` |
| `backend/src/` (repository root, outside `src/`) | Python analysis backend (see `PYTHON_ANALYSIS.md`); copied into `dist/code_analysis/python` by webpack | `main.py`, `tools/lizard_analyzer.py`, `utils/xr_field_schema.py` |
| `core/dependencies/` | Dependency-graph analysis service (see `docs/features/DEPENDENCY_GRAPH_XR.md`) | `dependencyGraphService.ts`, `dependencyGraphModels.ts` |
| `core/export/` | Analysis export: the manifest, the package transaction and the Git-revision exporter with its Python worker pool | `exportManifest.ts`, `exportPackageTransaction.ts`, `gitRevisionExporter.ts`, `gitRevisionExportCore.ts`, `gitTimelineBlobAnalyzer.ts` |
Expand Down
8 changes: 8 additions & 0 deletions .claude/docs/V1.2.1_STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,11 @@ Then pushed `v1.2.1` to `origin` at the maintainer's request. **No merge and no
**E2E findings (older behaviour, identical on the pre-cleanup VSIX, recorded for 1.3.0)**: the Barsmap and Pie examples get 404 for `../../data/*.json` (static root is the example folder); the same target analysed in two modes at once leaves the first server's `/events` at 404 (one port per file in the file-to-server map); `babia-html`'s html2canvas throws in headless Chromium.

**Where it is written up**: `docs/cleanup/REPORT.md` (repository root): findings, story/PR table, neutrality evidence, the §5 table, the 1.3.0 deferrals, the E2E result per feature-baseline §10 row and the **consolidated maintainer F5/VSIX checklist**, which is what remains before the release is cut.

### XR bug-fix epic #72 — S5 unified launcher (#77) [confirmed by unit tests] (2026-11-25, branch `claude/project-thread-kvvyg6-launcher`)

**Scope**: the XR audit (`docs/xr-audit/`, PR #67) found the launch path non-transactional (LAUNCHER-2/5/7/10/14/17 and related). Fixes of this epic land in 1.2.1 by the author's decision (CHANGELOG `Fixed`), overriding the maintenance-only rule for them.

**What changed**: `core/analysis/launch/` (new): `targetKey.ts`, `launchControl.ts` (AbortController + 10 min deadline + teardown stack per session, signal carried to the Python spawn via AsyncLocalStorage), `analysisTypes.ts` / `launchKinds.ts` / `storageFolders.ts` (descriptors; server capabilities, default controller views and router snapshot probes are derived). `launchPipeline.ts` is a transaction: server before watcher for every kind, rollback newest first, one error toast, silent on Close. Registry reserves the target before its first await. SSE + file map keyed by session id; `sessionServerManager.ts` and `sseNotificationManager.ts` deleted; close path matches servers by `metadata.sessionId` only. Startup cleanup sweeps the folders the launchers write.

**Measured**: ESLint warnings 158 → 155 (budget `--max-warnings` lowered to 155); guardrails any.total 84 → 83, complexity.over10 53 → 52 (baseline regenerated). New suite `test/analysis/launchTransaction.test.cjs` (15 tests). Not done here: progress notifications are not cancellable (Close Analysis is the cancel path); LAUNCHER-11 belongs to another story.
9 changes: 9 additions & 0 deletions apps/vscode-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@
- The table fit checked the chart's size but not its position: centring the bars could push the axis off one side. The axes are now kept on the table, and a chart that still sticks out is no longer reported as fitted.
- The fit could measure a cached, outdated size of a line that had just changed. Sizes are now re-read when the geometry changes.
- Generated scenes first built every chart over all files and only then switched to the top 20/30 shown. They now build once, from the files that are shown.
- **Launching an analysis is one transaction that can be stopped.** Every analysis kind (XR, LivePanel, DOM visualization) now runs through the same launcher, and several problems it had are fixed:
- Closing an analysis while it is still analysing stops it: the Python analysis is killed and no server or file watcher is started afterwards. Before, the launch went on and left a server and a watcher running that nothing could reach.
- If the server cannot start, the file watcher is not left running, and you get one error message instead of two. The server now starts before the watcher for every kind.
- A launch that takes more than 10 minutes is stopped and reported instead of waiting forever.
- Two quick launches of the same file, or the same file spelled differently (`C:\proj\a.ts` and `c:\proj\a.ts` on Windows, a trailing slash on a folder), no longer create two sessions.
- Two analyses of the same file no longer share one live-reload channel, and closing one analysis no longer stops the server of another whose path merely contains the same text.
- Startup cleanup now removes the old generated files of file, folder and DOM analyses. It used to clean a folder nothing wrote to, so the real ones grew without limit.
- Analysis output with non-ASCII characters (accented file names, for example) is read correctly on Windows.
- Internally, the analysis types and launch kinds are declared once and the tables that repeated them are derived; `docs/adding-an-analysis-type.md` explains how to add one.
- **Charts no longer flash oversized, grow into towers or leave the table while they are rebuilt.** Every way a chart is (re)built now follows the same rules: it reads the row-limited data, stays hidden until it has been fitted to the table, and only then appears.
- Switching chart type drew the new chart at the previous chart's scale for a moment, up to 75 m wide. It is now hidden until fitted.
- Bar and cylinder charts grew up from the floor on their first build, reaching 26-32 m before the fit caught up. BabiaXR's grow animation is now off for them.
Expand Down
73 changes: 73 additions & 0 deletions apps/vscode-extension/docs/adding-an-analysis-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Adding an analysis type

An **analysis type** is *what* the analysis table shows: the classic chart,
the dependency graph, the historical comparison, the project evolution. A
**launch kind** is *how* a page is produced and served for a target: an XR
scene, a LivePanel webview, a DOM visualization. Since 1.2.1 (S5, issue #77)
both are declared once, as descriptors, and the host tables that used to
restate them are derived.

| Descriptor list | File | Read by |
|---|---|---|
| `ANALYSIS_TYPES` | `src/core/analysis/launch/analysisTypes.ts` | server features per surface (`core/server/analysisServerCapabilities.ts`), the default controller view per mode (`core/analysis/refresh/analysisViewModes.ts`, also used by the export manifest), the room-cache probes of the collaboration router (`core/server/analysis/analysisMessageRouter.ts`) |
| `LAUNCH_KINDS` | `src/core/analysis/launch/launchKinds.ts` | `AnalysisOrchestrator` (dispatch through `resolveLauncher`) |
| `ANALYSIS_STORAGE_FOLDERS` | `src/core/analysis/launch/storageFolders.ts` | the launchers (where to write) and startup cleanup (what to sweep) |

## Checklist: a new in-scene analysis

1. **Descriptor.** Add an entry to `ANALYSIS_TYPES`: `id` (also the
coordinator mode and the browser runtime id), `label`, `controllerView`,
`serverFeature` (or `null`), `surfaces`, and a `snapshotProbe` if the room
can replay its result from a cached entity. Keep the file import-free: the
export manifest requires it from `out/` without a vscode stub.
2. **Server feature** (only if it needs endpoints). Add the name to
`AnalysisServerFeature` and a boolean to `AnalysisServerCapabilities`, then
attach the service where the existing ones are attached (follow
`projectEvolution` through `core/server/analysis/analysisFeatureHost.ts`).
A service that resolves an XR-only session must only be listed on the
surfaces that serve it, or it aborts every other launch.
3. **Browser runtime.** Register the mode in the analysis-mode runtime
(`templates/components/codexr/analysis-mode/`) with the same `id`, and add
its view to `MODE_CONTROLLER_VIEW_BY_ID` there.
`test/analysis/controllerViewMapSync.test.cjs` fails until the browser map
and the descriptors agree. Respect the load order in
`templates/components/COMPONENTS.md` and rebuild the assembled runtimes
(`node test/manual/buildAssembledRuntimes.cjs`).
4. **Chart.** Build and rebuild its chart through the analysis-table
containment (`beginRebuild` → fit → reveal) and read rows through a
row-budgeted slice (`prepareChartDataSlice`), never the raw source; see
"Rebuild and reveal (1.2.1)" in `COMPONENTS.md`.
5. **Tests.** Extend `test/analysis/launchTransaction.test.cjs` ("the host
tables derived from the analysis types are unchanged") with the new row,
plus the capability test (`analysisServerCapabilities.test.cjs`) if it
attaches a feature.

## Checklist: a new launch kind

1. Add the id to `LaunchKindId` (`analysisTypes.ts`) and to `AnalysisMode`.
2. Write a launcher that builds a `LaunchPipelineConfig` and calls
`executeLaunchPipeline` (see `launchers/launcherLivePanel.ts`). Do not start
a server or a watcher yourself: the pipeline starts the server, then the
watcher, and owns their teardown.
3. Add a folder to `ANALYSIS_STORAGE_FOLDERS` and pass it as `folderName`
(never a string literal: the cleanup test checks it).
4. Add the descriptor to `LAUNCH_KINDS` with one launcher per supported target
type; an unsupported combination is refused by `resolveLauncher` with a
message that names it.
5. List the kind in the `surfaces` of the analysis types it serves.

## What the pipeline guarantees

Every launch runs as a transaction under `LaunchControl`
(`launch/launchControl.ts`):

- one session per target: the registry reserves the target **before** its
first `await`, and compares targets through `targetKey()` (resolved, no
trailing separator, case-folded on Windows and macOS);
- steps run in order pre-validation → analysis → save → server → watcher, and
each step that starts something records how to undo it;
- a failure, the 10-minute deadline or **Close Analysis** aborts the launch,
kills a running Python analysis, and undoes the started steps newest first,
exactly once. A closed launch shows nothing; a failed one shows one error;
- the server's SSE channel and file mapping are keyed by the session id, so
two sessions on the same file never cross their live reloads.
2 changes: 1 addition & 1 deletion apps/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@
"typecheck": "node ../../node_modules/typescript/bin/tsc --noEmit --incremental false -p tsconfig.check.json && node ../../node_modules/typescript/bin/tsc --incremental false -p tsconfig.tooling.json",
"compile-tests": "node -e \"require('fs').rmSync('out',{recursive:true,force:true})\" && node ../../node_modules/typescript/bin/tsc -p . --outDir out",
"watch-tests": "node ../../node_modules/typescript/bin/tsc -p . -w --outDir out",
"lint": "node ../../node_modules/eslint/bin/eslint.js src test scripts templates webpack.config.js eslint.config.mjs --max-warnings 158",
"lint": "node ../../node_modules/eslint/bin/eslint.js src test scripts templates webpack.config.js eslint.config.mjs --max-warnings 155",
"test": "npm run test:basic",
"test:basic": "npm run typecheck && npm run lint && npm run compile-tests && npm run test:unit",
"test:unit": "node test/runners/run-node-tests.cjs",
Expand Down
Loading
Loading