Repository navigation
feat: edge labels, neighbourhood and graph layouts, map views for any schema - #40
mindsocket wants to merge 6 commits into
Conversation
Tree and XY connectors can show the field the relationship is declared in, so typed relationships read at a glance. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019XphpcKhuNyHcNArHFELR4
Adds the compass layout with a bundled knowledge wiki neighbourhood view. Selecting a neighbour moves the focus; hosts can set it with focus. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019XphpcKhuNyHcNArHFELR4
Adds the graph layout (d3-force) and makes a definition's schema optional; without one it applies to every schema. Bundles graph, neighbourhood and tree views for any schema. Renames compass to neighbourhood. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019XphpcKhuNyHcNArHFELR4
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019XphpcKhuNyHcNArHFELR4
|
|
||
| /** | ||
| * The chosen space, map view and parameter values, mirrored in the query string so a reload (or a | ||
| * The chosen space, map view, focus node and parameter values, mirrored in the query string so a reload (or a |
There was a problem hiding this comment.
Don't list things the method signature lists. Totally redundant. Find and destroy similar examples in existing code
| ``` | ||
|
|
||
| `graph` is a structured-context `SpaceGraph` (see [Data](#data)); `values` and the controls' `onChange` belong to the host. Pass `annotations` to show validation results (see [Validation results](#validation-results)). | ||
| `graph` is a structured-context `SpaceGraph` (see [Data](#data)); `values` and the controls' `onChange` belong to the host. Pass `annotations` to show validation results (see [Validation results](#validation-results)). `focus` and `onFocusChange` set and follow the node a [neighbourhood](definitions.md#neighbourhood) layout centres on. |
There was a problem hiding this comment.
Let's not assume neighbourhood is the only layout that will care about this and create document maintenance overhead
| space[structured-context space] -->|host assembles| graph[SpaceGraph] | ||
| def[definition .json5] -->|parseMapViewDefinition| mvd[MapViewDefinition] | ||
| graph --> proj[projection<br>tree · landscape · xy] | ||
| graph --> proj[projection<br>tree · landscape · xy · neighbourhood · graph] |
There was a problem hiding this comment.
Enumerating every layout doesn't keep making sense here
| | Module | Holds | May import | | ||
| |---|---|---| | ||
| | `packages/map-views/src/core` | Definition parsing and validation, parameter resolution, graph helpers, and the projections (`buildTree`, `buildLandscape`, `buildXYPlot`) | Types from structured-context only. No React, DOM or Node | | ||
| | `packages/map-views/src/core` | Definition parsing and validation, parameter resolution, graph helpers, and the projections (`buildTree`, `buildLandscape`, `buildXYPlot`, `buildNeighbourhood`, `buildForceGraph`) | Types from structured-context only. No React, DOM or Node | |
There was a problem hiding this comment.
Don't enumerate the code
| ## Hosts | ||
|
|
||
| - **Navigator** (`apps/navigator`): dev-server middleware serves spaces (from the structured-context config), the definitions `loadMapViewDefinitions` finds, and, when a map view asks for them, validation results (`validateSpace`, expression rules only), as JSON. The chosen space, map view and parameter values live in the query string, so a reload restores them. Selecting a node opens a side panel with its fields, content and validation results. | ||
| - **Navigator** (`apps/navigator`): dev-server middleware serves spaces (from the structured-context config), the definitions `loadMapViewDefinitions` finds, and, when a map view asks for them, validation results (`validateSpace`, expression rules only), as JSON. The chosen space, map view, focus node and parameter values live in the query string, so a reload restores them. Selecting a node opens a side panel with its fields, content and validation results. |
There was a problem hiding this comment.
Guess what I'm about to say... Stop enumerating stuff from the code
There was a problem hiding this comment.
Format seems like a strange name for what this is and it looks like a barrel index file which is not the convention we use. I feel like the word format is also contributing to my confusion about what's what. Let's revisit what the concepts doc says and whether this is the right word, and if so, whether I just need to be reading the right part of that document to understand
| return <LandscapeLayout {...props} region={{ ...region, layout }} />; | ||
| case 'xy': | ||
| return <XYLayout {...props} region={{ ...region, layout }} />; | ||
| case 'graph': |
There was a problem hiding this comment.
This boilerplate and hard-coded lines with each added layout suggests refactoring opp.
| const { orientation, dag } = region.layout; | ||
| const tree = useMemo(() => buildTree(graph, region.id, dag), [graph, region.id, dag]); | ||
| const links = useMemo(() => (region.edges.show ? treeLinks(tree) : []), [tree, region.edges.show]); | ||
| const { show, labels } = region.edges; |
There was a problem hiding this comment.
This looks similar in other layouts too
| const definition = (id: string) => | ||
| `{ $id: '${id}', schema: 'sctx://x', regions: [{ id: 'main', layout: { type: 'tree' } }] }`; | ||
| const BUNDLED = [ | ||
| 'sctx-map-view://core/graph', |
There was a problem hiding this comment.
More hardcoding for no clear reason
| expect(snapshot!.definitions.map((d) => d.id)).toEqual(['sctx-map-view://mine']); | ||
| const ids = snapshot!.definitions.map((d) => d.id); | ||
| expect(ids).toContain('sctx-map-view://mine'); | ||
| expect(ids).toContain('sctx-map-view://core/graph'); |
There was a problem hiding this comment.
Is this a useful test or just asserting orthogonal stuff that happens to be true beyond the scope of the test? If the latter, drop it and hunt down similar existing cases with prejudice
…md, trimmed docs and tests Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019XphpcKhuNyHcNArHFELR4
…a/ for the shared format, no barrel Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019XphpcKhuNyHcNArHFELR4
Requested by Rog · project thread
What
edges.labels(parameterisable boolean, defaultfalse): tree, XY, neighbourhood and graph connectors show the field the relationship is declared in.neighbourhoodlayout: one focus node with its neighbours placed by role (above,below,left,right,around). Each role lists the fields that put a node there; with none listed, parents go above and children below. Selecting a neighbour moves the focus; selecting the focus is a normal selection.MapViewtakesfocusandonFocusChangeso a host can set and follow it.graphlayout: every node and edge as a network, positioned by a seededd3-forcesimulation, so the same graph gives the same positions. It needs no hierarchy.schemais optional. Without one it applies to every schema, andmapViewsForSchemaincludes it.graph,neighbourhoodandtree. The tree shows a message for a schema with no hierarchy.strategy-treestays as the view for the strategy schema.Also
assignLanesmoved fromcore/xy.tstocore/lanes.ts, as it has three users.d3-forceis a dependency, external to the library build likeajv.definitions.md,concepts.md,architecture.md,api.md,CLAUDE.md. Regeneratedlatestschemas and bundled definitions.Checks
bun test, typecheck and biome pass.test:package, which needs network access that this environment lacks. It matters here because of the newd3-forcedependency.focus; the navigator doesn't keep it in the query string. Edge labels can overlap where connectors cross.🤖 Generated with Claude Code
https://claude.ai/code/session_019XphpcKhuNyHcNArHFELR4