Docs: build hash grammar, theme rollback, reference-identity change detection, option-list boundary rule

This commit is contained in:
2026-06-12 21:53:42 +03:00
parent 5fe5aed50f
commit af9cc8a716
4 changed files with 48 additions and 12 deletions
+19 -10
View File
@@ -33,18 +33,22 @@ Zustand stores. Components never read `location.hash` or attach
The hash is the serialized view. Astrolabe's forms:
| State | Hash |
| --------------------------- | ------------------------------ |
| Default snippets view | _(empty / absent)_ |
| A selected snippet | `#snippet-<id>` |
| Datasets manager (list) | `#datasets` |
| A specific dataset | `#datasets/dataset-<id>` |
| New-dataset form | `#datasets/new` |
| Chart Builder for a dataset | `#datasets/dataset-<id>/build` |
| State | Hash |
| ------------------------------ | ------------------------------ |
| Default snippets view | _(empty / absent)_ |
| A selected snippet | `#snippet-<id>` |
| Datasets manager (list) | `#datasets` |
| A specific dataset | `#datasets/dataset-<id>` |
| New-dataset form | `#datasets/new` |
| Chart Builder for a dataset | `#datasets/dataset-<id>/build` |
| Chart Builder, no dataset open | `#build` |
Snippet `id` is an opaque string; dataset `id` is the numeric dataset id
rendered as a decimal string. The hash is the **only** persisted view-routing
state — there is no in-memory "current route" that can drift from it.
state — there is no in-memory "current route" that can drift from it. `#build`
serializes the builder's no-datasets state only: an un-targeted builder open
picks a dataset itself when any exist, so the derived view immediately
self-corrects to the `dataset-build` form.
### 1.2 The adapter: `infrastructure/url-hash.ts`
@@ -62,7 +66,8 @@ export type ViewState =
| { kind: 'datasets' } // #datasets
| { kind: 'dataset'; datasetId: number } // #datasets/dataset-<id>
| { kind: 'dataset-new' } // #datasets/new
| { kind: 'dataset-build'; datasetId: number }; // .../build
| { kind: 'dataset-build'; datasetId: number } // .../build
| { kind: 'build' }; // #build — builder, no dataset loaded
export function parseHash(rawHash: string): ViewState {
const hash = rawHash.replace(/^#/, '');
@@ -71,6 +76,8 @@ export function parseHash(rawHash: string): ViewState {
const snippet = /^snippet-(.+)$/.exec(hash);
if (snippet) return { kind: 'snippet', snippetId: snippet[1] };
if (hash === 'build') return { kind: 'build' };
const parts = hash.split('/').filter(Boolean);
if (parts[0] === 'datasets') {
if (parts.length === 1) return { kind: 'datasets' };
@@ -100,6 +107,8 @@ export function serializeHash(view: ViewState): string {
return '#datasets/new';
case 'dataset-build':
return `#datasets/dataset-${view.datasetId}/build`;
case 'build':
return '#build';
}
}