Skip to content

Conversation

@bfollington
Copy link
Contributor

@bfollington bfollington commented Mar 31, 2025

Fixes #910 #912

image image

bfollington and others added 6 commits March 31, 2025 12:40
…yCharms

- Fixed infinite recursion by replacing deep traversal with top-level property scanning
- Added proper entity ID tracking to avoid duplicate references
- Removed dependency on findAllAliasedDocs which was causing runtime issues
- Fixed type issues in tests and cleaned up debug logging
- Both reference directions now correctly show all references between charms

Fixes #758

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add proper error handling by rethrowing instead of silently failing
- Replace comments with TODO items for future recursive implementation
- Remove findAllAliasedDocs export that isn't being used
- Fix type checking errors in tests

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Based on PR review feedback in #909 (comment)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>\
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>\
…ndling

- Added recursive traversal of sourceCell chains to find resultRefs
- Implemented safe traversal to avoid triggering Copy trap errors
- Fixed cycle detection by tracking object references directly
- Added improved error handling to gracefully handle issues without crashing
- Added safeguards to prevent array access issues and property access errors
- Limited the maximum number of references to avoid UI overload
- Thoroughly tested with nested reference chains

Fixes #758
- Refactored to use followAliases and isAlias for better alias handling
- Added type checking and proper error boundaries
- Used existing utility functions instead of reimplementing them
- Reduced code verbosity and improved readability
- Safely handles Cell objects to avoid Copy trap errors

Continues work on #758
@bfollington bfollington force-pushed the feat/2025-03-27-read-by-reads-from branch from dcce75e to 42d4daa Compare March 31, 2025 02:43
Comment on lines +557 to +599
if (Array.isArray(value)) {
for (let i = 0; i < value.length; i++) {
// Skip null/undefined items
if (value[i] == null) continue;

// Skip items that might be cells to avoid Copy trap
if (typeof value[i] === 'object' &&
(isCell(value[i]) || isDoc(value[i]) || isCellLink(value[i]))) {
try {
// Process each cell directly
processValue(value[i], parent, new Set([...visited]), depth + 1);
} catch (err) {
console.debug(`Error processing special array item at index ${i}:`, err);
}
continue;
}

// Process regular items
try {
processValue(value[i], parent, new Set([...visited]), depth + 1);
} catch (err) {
console.debug(`Error processing array item at index ${i}:`, err);
}
}
} else if (typeof value === 'object') {
// Process regular object properties
const keys = Object.keys(value);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];

// Skip properties that might be or contain Cell objects
if (key === 'sourceCell' || key === 'cell' || key === 'value' ||
key === 'getAsCellLink' || key === 'getSourceCell') {
continue;
}

try {
processValue(value[key], parent, new Set([...visited]), depth + 1);
} catch (err) {
console.debug(`Error processing object property '${key}':`, err);
}
}
}
Copy link
Contributor Author

@bfollington bfollington Mar 31, 2025

Choose a reason for hiding this comment

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

I don't really understand how or why, but I was triggering the copy trap by naively traversing.

@bfollington bfollington changed the title Feat/2025 03 27 read by reads from Show full-depth reference in CharmDetails panel Mar 31, 2025
@bfollington bfollington requested a review from Copilot March 31, 2025 03:04
@bfollington bfollington marked this pull request as ready for review March 31, 2025 03:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR aims to enhance the CharmDetails panel by showing full-depth references and improving the UI for reference sections. The changes include updating the runner export to include followAliases, refactoring the combined references section in the CharmDetailView, and adding a new test for n-depth reference detection.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
runner/src/index.ts Added re-export for followAliases to support full-depth reference detection.
jumble/src/views/CharmDetailView.tsx Refactored reference sections by combining "Reading From" and "Read By" into a unified UI and renaming/toggling states.
charm/test/charm-references.test.ts Introduced a test to verify chained reference detection through sourceCell and resultRef.
Comments suppressed due to low confidence (2)

jumble/src/views/CharmDetailView.tsx:1190

  • [nitpick] Consider renaming 'isReferencesExpanded' to a more descriptive state variable that clearly indicates it controls the unified references section, to avoid confusion with the legacy 'Lineage' toggle.
onClick={() => setIsReferencesExpanded(!isReferencesExpanded)}

jumble/src/views/CharmDetailView.tsx:1272

  • [nitpick] The use of 'isLineageExpanded' here is inconsistent with the revised combined references approach; consider unifying the toggle logic with 'isReferencesExpanded' to reduce ambiguity in the UI.
onClick={() => setIsLineageExpanded(!isLineageExpanded)}

@bfollington bfollington merged commit a9fc9cc into main Mar 31, 2025
6 checks passed
@bfollington bfollington deleted the feat/2025-03-27-read-by-reads-from branch March 31, 2025 03:11
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.

UI rendering for reading from / read from section

2 participants