feat(server): focused neighborhood mode on workspace graph endpoint (TASK-1781) - #718
Merged
Conversation
…TASK-1781)
Add ?focus=REF&depth=N to GET /workspaces/{ws}/graph. When focus is set,
BFS-traverse typed edges (undirected) out from the ref up to depth hops
(default 2, clamped to [1,5]) and return only that neighborhood's nodes +
edges. Without focus the whole-workspace behavior is unchanged.
- The focused item is always included, even when terminal (you asked to
view it); neighbors honor the existing include_terminal filter.
- Neighborhood is intersected with the visibility-filtered item set, so a
guest can't infer hidden items from dangling edges.
- Node-count cap (maxFocusNodes=200) stops BFS expansion early and sets a
new GraphResponse.Truncated flag (omitempty — whole-workspace payload
shape unchanged) so the client can offer expand-on-click.
- An unknown/invisible focus ref returns 404.
Tests: depth bounds + clamping, both-direction traversal, terminal focus
node inclusion, terminal-neighbor filtering, cross-collection typed edges,
unknown ref 404, and truncation.
Parent: PLAN-1780.
… (round 1) In focus mode child_count was derived from the depth/cap-filtered edge set, so a boundary parent whose children fell outside the neighborhood reported child_count=0. The web UI gates hub-label and children-pill visibility on child_count > 0, so those would wrongly hide. Count children over the full visible item set instead (terminal filter on the child preserved), independent of the focus subgraph. This also reproduces the whole-workspace semantics exactly. Added a regression test (focused parent with a child beyond depth still reports count=1). Parent: PLAN-1780.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
?focus=REF&depth=NtoGET /api/v1/workspaces/{ws}/graph. In focus mode the endpoint BFS-traverses typed edges (undirected) out from the given item up todepthhops (default 2, clamped to [1,5]) and returns just that neighborhood's nodes + edges. Withoutfocus, the whole-workspace behavior is byte-for-byte unchanged.This is the backend foundation for the per-item dependency graph view (PLAN-1780).
Details
include_terminalfilter.maxFocusNodes=200) stops BFS expansion early (closest nodes first) and sets a newGraphResponse.Truncatedflag. The flag isomitempty, so the whole-workspace payload shape is unchanged for the existing 3D view.depthclamped server-side; a huge value resolves the full reachable chain rather than erroring.Context
Implements
TASK-1781underPLAN-1780(per-item dependency graph view). TS types + client params are the follow-upTASK-1782.Test plan