You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ab483c1
Browse filesBrowse the repository at this point in the historyBrowse files
docs: rewrite CLAUDE.md for the generic navigation_devtools architecture
Reflects the merged structure: navigation_devtools core + adapters (auto_route,
go_router, Navigator1, RouterDelegate), v2 wire protocol, the shipped bundle
living in navigation_devtools, and the pub.dev OIDC publishing setup.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+84-33Lines changed: 84 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,70 +4,108 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
5
5
## What this is
6
6
7
-
A standalone, publishable **Flutter DevTools panel extension** for `auto_route` (v11). Inside the DevTools tab of a running app it shows the live backstack, full router tree, per-route args + path/query params, and confirm-gated interactive navigation. (auto_route ships no DevTools extension; `developer_tools_auto_route` is only an in-app overlay — this is a proper DevTools panel.)
7
+
A standalone, publishable **Flutter DevTools panel extension** for **navigation** — a generic core
8
+
(`navigation_devtools`) with per-router **adapters** (auto_route, go_router, Navigator 1.0, and any
9
+
custom `RouterDelegate`). Inside the DevTools tab of a running app it shows, per registered router:
10
+
the live backstack, the static route tree (as a list **and** an Android-Studio-style route **graph**),
Multiple routers can be registered and switched between in the panel.
13
+
14
+
Fills a real gap: none of these routers ship a DevTools extension; `developer_tools_auto_route` is only
15
+
an in-app overlay — this is a proper DevTools panel.
8
16
9
17
## Environment
10
18
11
19
-**Always use FVM**: `fvm flutter` / `fvm dart` (Flutter 3.44.0). Plain `flutter`/`dart` may resolve to the wrong SDK.
12
20
-**Dart pub workspace** (`resolution: workspace`) with **Melos 8** as the publish handler. Melos config lives in the root `pubspec.yaml` under the `melos:` key (pub-workspace mode) — **NOT** in `melos.yaml`, which is kept only for discoverability.
13
21
- freezed **3.x** and build_runner 3.x are forced by auto_route 11's constraints.
14
22
15
-
## Packages (monorepo, 4 packages)
23
+
## Packages (monorepo)
16
24
17
25
| Package | Role | Published? |
18
26
|---|---|---|
19
-
|`auto_route_devtools_shared`| freezed/JSON protocol models — the wire contract between runtime and UI | yes |
20
-
|`auto_route_devtools`| Runtime companion attached to the consumer app; registers service extensions | yes |
21
-
|`auto_route_devtools_extension`| The DevTools web UI (Flutter web) | no (`publish_to: none`) |
22
-
|`example`| Runnable auto_route demo + test fixture | no |
23
-
24
-
The extension UI is **prebuilt** into `packages/auto_route_devtools/extension/devtools/build/` and shipped inside the published `auto_route_devtools` package. That build dir is force-included in `.gitignore` (`!packages/auto_route_devtools/extension/devtools/build/`) — do not delete it; it must exist for the published extension to load.
|`navigation_devtools_extension`| The DevTools web UI (Flutter web) | no (`publish_to: none`) |
33
+
|`examples/{auto_route,go_router,navigator1,router_delegate}_example`| Runnable demos + test fixtures | no |
34
+
35
+
The extension UI is **prebuilt** into `packages/navigation_devtools/extension/devtools/build/` and shipped
36
+
inside the published `navigation_devtools` package (the adapter packages do **not** ship a bundle). That
37
+
build dir is force-included in `.gitignore` (`!packages/navigation_devtools/extension/devtools/build/`) —
38
+
do not delete it; it must exist for the published extension to load.
25
39
26
40
## Architecture — the wire protocol
27
41
28
-
The runtime and the UI never share Dart objects; they communicate over the VM service using the shared freezed models (`packages/auto_route_devtools_shared/lib/src/models.dart`: `RouterConfigNode`, `StackEntry`, `NavigateRequest`/`NavigateResult`, `NavigateAction`).
29
-
30
-
**Runtime side** (`auto_route_devtools/lib/src/auto_route_devtools.dart`): `AutoRouteDevTools.init(router)` registers three `dart:developer` service extensions and posts one event:
31
-
-`ext.autoRouteDevtools.getRouterConfig` → serialized router tree
-`ext.autoRouteDevtools.navigate` → executes a `NavigateRequest`, returns `NavigateResult`
34
-
-`postEvent('auto_route_devtools:stack_changed')` — pushed by the `AutoRouterObserver` on every nav change (this is the live-update mechanism; there is intentionally **no** polling fallback).
35
-
36
-
Everything is **inert in release** (`kReleaseMode` guards in `init`/`notifyStackChanged`).
37
-
38
-
**UI side** (`auto_route_devtools_extension/lib/src/data_source.dart`): `AutoRouteDataSource` is the abstraction. `VmServiceDataSource` calls the service extensions above via `serviceManager` and listens to `onExtensionEvent` for `stack_changed`. `FakeAutoRouteDataSource` backs widget tests with in-memory data. Views (`panel.dart`, `backstack_view.dart`, `router_tree_view.dart`, `detail_view.dart`) render off the data source.
39
-
40
-
When you change any model in `auto_route_devtools_shared`, you are changing the wire contract — update **both** the runtime serializers (`stack_serializer.dart`, `router_config_serializer.dart`) and the UI's decode path, and regenerate code.
42
+
The runtime and the UI never share Dart objects; they communicate over the VM service using the shared
Codegen (after editing any freezed/JSON model, only `_shared` has generated code):
92
+
Codegen (after editing any freezed/JSON model; only `_shared` has generated code):
57
93
```bash
58
-
cd packages/auto_route_devtools_shared&& fvm dart run build_runner build --delete-conflicting-outputs
94
+
cd packages/navigation_devtools_shared&& fvm dart run build_runner build --delete-conflicting-outputs
59
95
```
60
96
61
97
Analyze (clean is required):
62
98
```bash
63
99
fvm flutter analyze
64
100
```
65
101
66
-
Tests — **the extension package must run on Chrome** (it uses `dart:js_interop`); the other two run on the Dart VM:
102
+
Tests — **the extension package must run on Chrome** (it uses `dart:js_interop`); the rest run on the Dart VM:
67
103
```bash
68
-
cd packages/auto_route_devtools_shared && fvm flutter test
104
+
cd packages/navigation_devtools_shared && fvm flutter test
105
+
cd packages/navigation_devtools && fvm flutter test
69
106
cd packages/auto_route_devtools && fvm flutter test
70
-
cd packages/auto_route_devtools_extension && fvm flutter test --platform chrome
107
+
cd packages/go_router_devtools && fvm flutter test
108
+
cd packages/navigation_devtools_extension && fvm flutter test --platform chrome
71
109
```
72
110
73
111
Single test file / single test:
@@ -76,27 +114,40 @@ fvm flutter test test/panel_test.dart --platform chrome
76
114
fvm flutter test test/panel_test.dart --plain-name "renders backstack"
77
115
```
78
116
79
-
Rebuild the shipped extension bundle (from the extension package) — needed whenever the UI changes, so the prebuilt bundle in the published package stays current:
117
+
Rebuild the shipped extension bundle (from the extension package) — needed whenever the UI changes, so the
118
+
prebuilt bundle in the published `navigation_devtools` package stays current (a CI job fails on drift):
80
119
```bash
81
-
cd packages/auto_route_devtools_extension&& fvm dart run devtools_extensions build_and_copy \
Run the demo app to verify live DevTools behavior end-to-end:
124
+
Run a demo app to verify live DevTools behavior end-to-end:
86
125
```bash
87
-
cdexample&& fvm flutter run # then open DevTools and enable the auto_route_devtools tab
126
+
cdexamples/auto_route_example&& fvm flutter run # then open DevTools and enable the navigation_devtools tab
88
127
```
89
128
90
-
Publish dry-run (Melos publishes in dependency order: `_shared`before `auto_route_devtools`; `publish_to: none` packages are skipped):
129
+
Publish dry-run (Melos publishes in dependency order: `_shared`first, then core and adapters; `publish_to: none` packages are skipped):
91
130
```bash
92
131
fvm dart run melos publish --dry-run
93
132
```
94
133
134
+
## Release / CI-CD
135
+
136
+
-`.github/workflows/ci.yaml` — analyze + test + publish dry-runs + extension-bundle-drift check (on push to `main` / PRs).
137
+
-`.github/workflows/publish.yml` — **pub.dev automated publishing via GitHub Actions OIDC**, triggered by
138
+
tags of the form `<package>-v<version>` (glob `<package>-v*`). Each publishable package must be configured
139
+
once on pub.dev (Admin → Automated publishing: repo `masreplay/auto_route_devtools`, tag pattern
140
+
`<package>-v{{version}}`). A brand-new package's **first** version must be published manually with
141
+
`fvm dart pub publish` — pub.dev does not allow automated first-publish.
142
+
95
143
## Conventions
96
144
97
145
-`analysis_options.yaml`: `flutter_lints` + `prefer_single_quotes`. Generated files (`*.g.dart`, `*.freezed.dart`, `*.gr.dart`) are excluded from analysis — never hand-edit them.
98
146
- Design/plan docs live in `docs/superpowers/`; the SDD progress ledger is `.superpowers/sdd/progress.md`.
99
147
100
148
## Known gaps (deferred by design)
101
149
102
-
Live DevTools click-through has been unverified in headless sessions — verify manually via the `example` app. Not yet implemented: redirect-route filtering in the tree, a guarded-route fixture (the guards→name mapping is untested), and a `_defaultConfirm` dialog test.
150
+
Live DevTools click-through has been unverified in headless sessions — verify manually via an `examples/*` app.
151
+
Not yet ported from the old auto_route-only UI: nested-route `fullPath` navigation (the v2 `RouteNode` has no
152
+
`fullPath` field) and redirect **target** edges in the graph (v2 exposes only a `hasRedirect` badge). Also
153
+
deferred: redirect-route filtering in the tree, a guarded-route fixture (guards→name mapping untested).
0 commit comments