Repository navigation
feat(viewer): add overlay and focus props to EmbeddingAtlas - #292
dataelvisliang wants to merge 10 commits into
Conversation
|
A bit more context on the use case. In my application the viewer is driven by an agent. The agent runs its own queries, decides where to go next, and navigates the map on its own. What it needs from the viewer is a way to show where it has been and what it has found, like footprints on the map, and a way to move the view as it goes. The highlight prop cannot cover this. It also highlights rows in the instances view and shares state with clicks and brushing, so the agent's progress would fight with whatever the user is doing. That is why this PR keeps the external overlay separate from the internal search overlay, so the agent's footprints can be drawn and cleared without touching the user's state, and why focus carries a key, so the agent can move the view to the same point again when it comes back to it. With these two props the application can drop its fork and use the stock viewer. |
|
Hi @donghaoren, friendly ping on this one. CI is green and the PR is ready for review whenever you have a moment. Happy to make changes if you have any feedback. Thanks! |
| * passing `null` (or leaving the prop unset) never moves the viewport. | ||
| * A request given when the component mounts is executed once the data is ready. | ||
| */ | ||
| focus?: FocusRequest | null; |
There was a problem hiding this comment.
I think we should probably call this focusRequest
There was a problem hiding this comment.
Done. I renamed the prop to focusRequest. The name now matches the one used inside the store, and I updated the API docs and the React and Svelte wrappers to match.
| * Tracks which focus requests have already been handled, so that a request is | ||
| * acted upon only once even if views are re-created or multiple views observe it. | ||
| */ | ||
| focusTracker: FocusRequestTracker; |
There was a problem hiding this comment.
I think the tracker shouldn't be on the ChartContext / EmbeddingAtlasStore. We can have more than one view that focusRequest might want to affect. A shared tracker means only one view will handle the request (whoever gets it first). I think each view that want to respond to the request should handle it in its own scope. A way to test that this works is to add two embedding views (can be identical), and see if a focusRequest makes both focus to the desired point.
Also, should we make the instances view also respond to the focusRequest?
There was a problem hiding this comment.
Done. I moved the tracker out of the shared chart context and the store. Each embedding view now keeps its own tracker, so one request can move more than one view. I added a test where two trackers each accept the same request and each still ignores a repeat of it.
Two behavior notes. Clearing the prop cancels a request that has not run yet, but it does not reset the key, so sending the same key again is still ignored. A view that is destroyed and rebuilt will run the current request again, because its new tracker starts empty.
On the instances view, I left it out for now because the intended use case is agent-driven map navigation without interrupting the user's position in the instances list. The instances view already supports revealing a row through pagination and scrolling, so it could also respond to focusRequest. Would you prefer this request to coordinate both views, or remain scoped to embedding views?
|
Thanks for the PR! Left two comments. |
|
Hi donghaoren, just checking in on this one. I pushed the focusRequest rename and the per-view tracker with the two-view test on Nov 7. Please let me know if the instances view scope needs a change, or if anything else is blocking review. |
Use case: applications that embed the viewer often run their own search or query outside the viewer and need to show the results on the map. The highlight prop is the only tool for this today, but it is built for cross-view coordination. It highlights rows in the instances view and shares state with user interactions, so external results can disturb what the user is doing. The overlay and focusRequest props cover this case directly, so applications no longer need a fork for it.
This PR builds on the highlight prop added in #262 and adds two more props for applications that embed the viewer.
overlay draws markers for results produced outside the viewer, using the existing overlay rendering in the embedding view. The external overlay is stored separately from the internal overlay produced by search. When the prop is set to an object, the external overlay is shown, even when it has no nodes. When the prop is null or unset, the internal overlay is shown again. The overlay does not change the selection, brush, filters, or highlight, and it does not scroll the instances view.
focusRequest moves the viewport to a single point. Each request has an id and a key. A request is handled only when its key is new, so an application can focus the same point again by sending a new key. Requests with unknown IDs are ignored. When requests arrive in quick succession, the latest one wins. Setting only overlay never moves the viewport.
Overlay coordinate lookups now drop stale async results. A slow lookup for an older overlay can no longer repaint outdated markers.