Skip to content

fix(sidebar): enhance node selection to show details for single nodes - #1235

Open
Maystern wants to merge 6 commits into
DeusData:mainfrom
Maystern:fix/sidebar-show-node-and-details
Open

fix(sidebar): enhance node selection to show details for single nodes#1235
Maystern wants to merge 6 commits into
DeusData:mainfrom
Maystern:fix/sidebar-show-node-and-details

Conversation

@Maystern

@Maystern Maystern commented Jul 23, 2026

Copy link
Copy Markdown

What does this PR do?

What

Fixes sidebar node selection in the graph UI:

  • Directory clicks now clear the details panel instead of leaving stale details from a previously selected node (previously handleSelectPath never reset selectedNode, so the panel kept showing the last selected file)
  • Search results without a file_path can now open the panel — previously they were dropped by an early if (!path) return, so clicking them did nothing
  • Unified selection through one code path: handleSelectPath now takes an optional node and delegates to handleNodeClick, so selecting from the sidebar, search results, and the graph all share the same selection/highlighting behaviour (and leaf clicks now highlight direct neighbours, matching graph clicks)

Tests

Adds GraphTab.selection.test.tsx (168 lines, 5 cases) covering leaf clicks, directory clicks, file_path-less search results, clearing selection, and neighbour highlighting — the leaf-click test fails against the previous implementation.

Misc

Drops the accidentally committed build artifact src/ui/embedded_assets.c (generated by scripts/embed-frontend.sh; contains machine-specific asset hashes).

Checklist

  • Every commit is signed off (git commit -s) — required, CI rejects
    unsigned commits (DCO, see CONTRIBUTING.md)
  • Tests pass locally (make -f Makefile.cbm test)
  • Lint passes (make -f Makefile.cbm lint-ci)
  • New behavior is covered by a test (reproduce-first for bug fixes)

@Maystern
Maystern requested a review from DeusData as a code owner July 23, 2026 16:47
Signed-off-by: Maystern <12112910@mail.sustech.edu.cn>
@Maystern
Maystern force-pushed the fix/sidebar-show-node-and-details branch from c85c66d to 883d3b2 Compare July 23, 2026 16:58
@DeusData DeusData added the bug Something isn't working label Jul 24, 2026
@DeusData DeusData added this to the 0.9.1-rc milestone Jul 24, 2026
@DeusData DeusData added ux/behavior Display bugs, docs, adoption UX priority/high Needs near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker. labels Jul 24, 2026
@DeusData

Copy link
Copy Markdown
Owner

Thanks for addressing #1197. Two selection cases remain incorrect in this head. nodeIds.size === 1 does not distinguish a leaf from a directory containing one node, so a one-node directory opens details even though Sidebar passes no node for directories. Search results without file_path still pass an empty path and clear selection, while the new GraphNode callback argument is ignored. The patch also duplicates the existing handleNodeClick neighbor and camera behavior. Please route explicit leaf/search-node selection through one canonical node-selection handler and add RED tests for leaf click, one-node directory, search result without file_path, clear selection, and neighbor highlighting.

Signed-off-by: Maystern <12112910@mail.sustech.edu.cn>
@Maystern
Maystern force-pushed the fix/sidebar-show-node-and-details branch from d31f9ee to 2147732 Compare July 24, 2026 17:03
@DeusData

Copy link
Copy Markdown
Owner

Thank you for this — the UI fix itself is good and I would like to merge it. One file needs to come out first, and it is not your logic.

What is right. handleSelectPath taking an optional node and delegating to handleNodeClick is the correct shape: it sets the selected node and the neighbour highlight through the existing path rather than duplicating that behaviour. Two real bugs fall out of it — directory clicks now clear the panel instead of leaving stale details from a previously selected node, and search results with no file_path can finally open the panel at all. The 168-line vitest suite is solid, and the leaf-click test genuinely fails against the old code.

Security-wise it is clean: everything renders through React text nodes, no innerHTML, so none of the graph-derived strings (which come from indexed repositories and are therefore attacker-influenced) reach the DOM as markup.

What needs to change: please drop src/ui/embedded_assets.c from the diff.

That file is a build artifact — it carries a "DO NOT EDIT — regenerated by scripts/embed-frontend.sh" header, and the copy in this PR contains asset hashes from your machine (index-D27RSPSK.css). It is harmless to the build, because the default build uses embedded_stub.c and the with-UI build regenerates the file first, which is why the smoke legs are green. But if it becomes tracked, every with-UI build will dirty the working tree with rotating hashes, forever, for everyone.

That is our gap, not yours — the file should have been in .gitignore and was not. We will fix that on our side. Removing it here is a one-commit change:

git rm --cached src/ui/embedded_assets.c
git commit -s -m "chore: drop generated embedded_assets.c from the diff"
git push

One small ask: the PR description is currently the empty template. A sentence or two on the behaviour you were fixing would help the next person reading the history — and would have made this review faster.

With the artifact removed, this merges. Thanks for the clean test coverage; it is the reason the review was straightforward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working priority/high Needs near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker. ux/behavior Display bugs, docs, adoption UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants