Skip to content

Fix type display in hhds_tree_diff#217

Open
cravishe wants to merge 1 commit into
masc-ucsc:mainfrom
cravishe:fix-tree-diff-display
Open

Fix type display in hhds_tree_diff#217
cravishe wants to merge 1 commit into
masc-ucsc:mainfrom
cravishe:fix-tree-diff-display

Conversation

@cravishe
Copy link
Copy Markdown
Contributor

@cravishe cravishe commented May 17, 2026

Summary

Fixes type name display in hhds_tree_diff and adds attribute handling to match hhds_tree_cat output.

Changes

  • Persist type_names vector in DumpData to ensure Type_entry string views remain valid throughout the tree lifecycle
  • Inline type table construction and full label extraction into load_dump for cleaner ownership semantics
  • Add attribute recovery and display in print_tree, matching the approach used by hhds_tree_cat

Summary by CodeRabbit

  • Refactor

    • Consolidated dump-loading into a single, more robust flow that reliably collects full node labels and handles load failures gracefully.
  • Enhancements

    • Tree display now surfaces all node attributes and shows per-node attribute values alongside the tree.

Review Change Stack

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6ecbc0d5-5368-42ab-9a8c-47d4440fbfa7

📥 Commits

Reviewing files that changed from the base of the PR and between a5f2ee4 and 5b0580e.

📒 Files selected for processing (1)
  • hhds/hhds_tree_diff.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • hhds/hhds_tree_diff.cpp

📝 Walkthrough

Walkthrough

Consolidates dump parsing and full-line label extraction into a single load_dump(), extends DumpData with type_names, and updates print_tree() to register per-key attribute callbacks so attributes are available during tree printing.

Changes

Dump Processing and Attribute Display

Layer / File(s) Summary
DumpData struct extension
hhds/hhds_tree_diff.cpp
DumpData adds a type_names field; copy ops disabled, moves defaulted.
load_dump() consolidation
hhds/hhds_tree_diff.cpp
load_dump() opens the dump, parses type names (skipping header), builds type_table, calls hhds::Tree::read_dump to populate node_texts, reopens the dump to extract full per-line labels into full_labels, and clears data.tree on reopen failure or label-count mismatch.
Node attribute printing in print_tree()
hhds/hhds_tree_diff.cpp
print_tree() aggregates attribute keys across nodes and registers per-key opts.attributes callbacks returning each node's attribute value or std::nullopt; retains opts.node_text callback.

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly Related PRs

  • masc-ucsc/hhds#214: Initial introduction of hhds_tree_diff tool with foundational dump-loading and tree-printing infrastructure that this PR refactors and extends.

Poem

I hopped through dumps with nimble paws,
Gathered type names and stitched their laws,
Read each line and kept labels bright,
Sprinkled attributes into the light —
A rabbit's patch to make trees pause. 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main objective of the PR: fixing type display in hhds_tree_diff, which aligns with the summary's focus on persisting type names and improving type name display.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@hhds/hhds_tree_diff.cpp`:
- Around line 66-72: DumpData's default copy operations can leave type_table's
Type_entry string_views pointing into the original type_names; make DumpData
safe by either deleting copy constructor and copy assignment (declare
DumpData(const DumpData&)=delete; DumpData& operator=(const DumpData&)=delete;)
or implement custom copy/move that rebuilds type_table from the destination's
type_names after copying (ensure symbols DumpData, type_table, type_names, and
hhds::Type_entry are updated so string_view targets the new storage).
- Around line 120-140: The second-pass loader currently skips the first line and
pushes only non-empty extracts from extract_full_content into contents, then
quietly writes whatever it has into data.full_labels; instead enforce that the
second pass produced a full label for every node: after collecting contents,
check that contents.size() == data.nodes.size() and that no entry is empty (or
that extract_full_content succeeded for every node), and if not, fail the load
(e.g., return an error/empty result or throw) instead of partially populating
data.full_labels; update the logic around contents, data.nodes and
data.full_labels to perform this validation and abort early on mismatch so
cost_fn can't fall back to empty strings.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 70609e9c-b1f1-439b-973b-2307b4b3db01

📥 Commits

Reviewing files that changed from the base of the PR and between 66198bc and dca8c42.

📒 Files selected for processing (1)
  • hhds/hhds_tree_diff.cpp

Comment thread hhds/hhds_tree_diff.cpp
Comment thread hhds/hhds_tree_diff.cpp
@cravishe cravishe force-pushed the fix-tree-diff-display branch from dca8c42 to a5f2ee4 Compare May 17, 2026 18:44
@cravishe cravishe force-pushed the fix-tree-diff-display branch from a5f2ee4 to 5b0580e Compare May 17, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant