Skip to content

feat(devtool): implement component hover highlight#168

Merged
nurulhudaapon merged 4 commits into
mainfrom
devtool/components_highlight
Jul 18, 2026
Merged

feat(devtool): implement component hover highlight#168
nurulhudaapon merged 4 commits into
mainfrom
devtool/components_highlight

Conversation

@Andrew-Velox

Copy link
Copy Markdown
Member

No description provided.

@nurulhudaapon

nurulhudaapon commented Jul 18, 2026

Copy link
Copy Markdown
Member

@Andrew-Velox We shouldn't have much changes to the actual Ziex code, we can have things that is inside (if (comptime is_dev) block, but shouldn't definitely not have to change the data structure or add field to Ziex code.

As I suggested, for client components we just inject the id/idx to the component as element property to the root element only, same for server component we can render an data-zx-cid to the root element only. When hovered if the current element doesn't have an id we keep going up in the tree until we find one with id then we highlight that area.

We are fine adding dozens of logic in DevTool as it is the scope of the devtools mostly to figure things out.

Another idea is that for server component we should be able to do that just by including component index to the component tree we sent to DevTool, no? IN that way we don't have any change in the Ziex server side code at all just the DevServer API Endpoint that returns serialized component tree, when we do the serialization we can just include the idx.

@Andrew-Velox

Copy link
Copy Markdown
Member Author

Got it, I've reverted all the Ziex core changes (Component.zig, render.zig, handler.zig, devtool.zig). No new fields or data structure changes.
I moved everything into the DevTool. Instead of injecting attributes, it just builds a CSS selector + occurrence index from the tree we already get from the endpoint.
Tested manually and it's working perfectly now. this approach also fixed the issue with incorrect highlight positioning for a few components.

image

@Andrew-Velox
Andrew-Velox marked this pull request as ready for review July 18, 2026 21:03
Copilot AI review requested due to automatic review settings July 18, 2026 21:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements inspected-page hover highlighting from the devtool component tree by deriving a DOM locator (CSS selector + occurrence index) per component and evaluating an overlay script inside the inspected window.

Changes:

  • Add inspected-window eval helper + overlay-based hover highlight logic, wired to mouseover/mouseout in the devtool UI.
  • Always fetch native elements so every component can be mapped to a DOM locator (UI filtering remains controlled by settings).
  • Extend serialized component mapping to compute and propagate selector + occurrence through the tree UI.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
ide/devtool/app/scripts/client.ts Adds inspected-window eval and hover event handling to render/clear a highlight overlay over the inspected page DOM.
ide/devtool/app/pages/page.zx Always fetches native elements; passes selector/occurrence into rendered component buttons as data-* attributes.
ide/devtool/app/pages/data.zig Computes per-node DOM locator (selector + occurrence counter) while mapping serialized component trees.

}

async function refreshFromNavigation(href?: string): Promise<void> {
await clearInspectedComponentHighlight();
Comment on lines +176 to +180
async function stopHover(): Promise<void> {
if (!hoveredKey) return;
hoveredKey = null;
await clearInspectedComponentHighlight();
}
@nurulhudaapon

Copy link
Copy Markdown
Member

Got it, I've reverted all the Ziex core changes (Component.zig, render.zig, handler.zig, devtool.zig). No new fields or data structure changes. I moved everything into the DevTool. Instead of injecting attributes, it just builds a CSS selector + occurrence index from the tree we already get from the endpoint. Tested manually and it's working perfectly now. this approach also fixed the issue with incorrect highlight positioning for a few components.

image

Awelsome, I'm merging this, and once it is in main let's compile and publish (just to see how long it takes to publish new version). And then we follow up with the following two:

  • Clicking on components should focus the component on the browser, auto scroll up/down if needed.
  • Add pointer feature, like the chrome native arrow that you can click and then hovering over the things on browser auto highlights things.

@nurulhudaapon
nurulhudaapon merged commit 8c1f8de into main Jul 18, 2026
1 check passed
@nurulhudaapon
nurulhudaapon deleted the devtool/components_highlight branch July 18, 2026 21:22
@github-project-automation github-project-automation Bot moved this from Todo to Done in Ziex Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants