Skip to content

Conversation

@bokelley
Copy link
Contributor

@bokelley bokelley commented Nov 5, 2025

Summary

Implement hierarchical tree view for ad unit selection in product editor with search filtering, lazy loading, and response caching. Add flask-caching dependency for improved inventory API performance.

Changes

  • Added hierarchical tree view UI with expandable/collapsible nodes
  • Implemented search filtering with ancestor node expansion
  • Added flask-caching for inventory API responses (5-minute TTL)
  • Search highlighting for matching ad units

Testing

  • All unit tests passing (861 passed)
  • All integration tests passing (32 passed)
  • All integration_v2 tests passing (28 passed)

🤖 Generated with Claude Code

bokelley and others added 8 commits November 5, 2025 10:29
Implement hierarchical tree view for ad unit selection in product editor with search filtering, lazy loading, and response caching. Add flask-caching dependency for improved inventory performance. Includes expandable/collapsible tree nodes, search highlighting, and ancestor node expansion for search results.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
Extract 200+ lines of tree CSS from add_product_gam.html into shared partial component for reusability across templates. Create foundation for unified tree implementation.

Changes:
- Create templates/partials/hierarchical_tree_styles.html with shared CSS
- Create templates/partials/hierarchical_tree_scripts.html with utility functions
- Update add_product_gam.html to include shared styles via {% include %}
- Reduce duplication and enable consistent tree styling

Note: JavaScript still inline in product picker (product-specific logic). Inventory browser tree update deferred to future work.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
Fix "Select Matched Formats" button not appearing when using hierarchical tree picker. The tree API response was missing size metadata, causing the format matching logic to fail.

Changes:
- Add `sizes` field to inventory tree API response (inventory.py:885)
- Update JavaScript to use sizes from tree response (add_product_gam.html:448)
- Remove hardcoded empty sizes array that was breaking matching

This enables the "Select All Matching" button to appear when ad units with size information are selected via the hierarchical tree picker.

Fixes: Format matching now works correctly with hierarchical ad unit selection
Tests: 861 unit tests passing

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
When a parent ad unit is selected from the tree picker, recursively extract sizes from all child ad units for format matching. This enables the "Select Matched Formats" button to appear when parent units with sized children are selected.

Changes:
- Add recursive extractSizesFromUnit() helper function
- Store children array in inventoryCache during tree rendering
- Recursively traverse child units to collect all sizes

Example: Selecting "Scribd Ad Exchange Display" (parent) now includes sizes from "Scribd 300x250" (child) for format matching.

Tests: 861 unit tests passing

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
Fix child size extraction by accessing sizes directly from child objects instead of looking them up in cache. The children array contains full objects from the tree API with sizes already populated.

Changes:
- Access child.sizes directly instead of cache lookup
- Add grandchildren caching for multi-level hierarchies
- Simplify recursive extraction logic

This fixes the issue where selecting a parent ad unit wasn't extracting sizes from its children for format matching.

Tests: 861 unit tests passing

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
The critical bug: When editing a product, ad units were pre-cached from the flat list API (no children). Then when opening the tree picker, the tree rendering skipped re-caching because units were already cached, so the children array was never stored.

Solution: Always update the cache when rendering the tree, overwriting any previous data from the flat list API with the full hierarchical data including children.

This fixes child size extraction when editing existing products.

Tests: All tests passing

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
Critical fix for edit mode: When editing a product with pre-selected ad units, fetch the tree API (not flat list) to ensure all units are cached with their children arrays. This enables size extraction from child ad units.

Changes:
- Replace flat list API call with tree API call in edit mode
- Add recursive cacheTreeUnits() to process entire tree hierarchy
- Ensures children arrays are available for size extraction on page load

This fixes the issue where selecting a parent ad unit in edit mode wouldn't extract sizes from its children.

Tests: 861 unit tests passing

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
Resolved conflict in templates/add_product_gam.html by keeping our tree API approach for hierarchical size extraction (required for child ad unit sizes) while incorporating debug logging from main.

Conflict resolution:
- Kept tree API fetch (not flat list) for edit mode initialization
- Preserved recursive cacheTreeUnits() function for hierarchical caching
- Added debug console.log statements from main for troubleshooting
- This ensures child ad unit sizes are available for format matching

Other changes from main:
- Remove MCP protocol test button and APIs (PR #702)
- Make media_buy_ids optional per AdCP spec (PR #704)
- Fix User record creation during OAuth (PR #701)
- Fix inventory fetching for placements (multiple commits)
- Various bug fixes and improvements

Tests: Will run after merge completion

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
@bokelley bokelley merged commit 6a6c23d into main Nov 6, 2025
10 checks passed
danf-newton pushed a commit to Newton-Research-Inc/salesagent that referenced this pull request Nov 24, 2025
…extprotocol#707)

* feat: Add hierarchical product picker with search and caching

Implement hierarchical tree view for ad unit selection in product editor with search filtering, lazy loading, and response caching. Add flask-caching dependency for improved inventory performance. Includes expandable/collapsible tree nodes, search highlighting, and ancestor node expansion for search results.

🤖 Generated with Claude Code

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

* refactor: Extract hierarchical tree styles into reusable partial

Extract 200+ lines of tree CSS from add_product_gam.html into shared partial component for reusability across templates. Create foundation for unified tree implementation.

Changes:
- Create templates/partials/hierarchical_tree_styles.html with shared CSS
- Create templates/partials/hierarchical_tree_scripts.html with utility functions
- Update add_product_gam.html to include shared styles via {% include %}
- Reduce duplication and enable consistent tree styling

Note: JavaScript still inline in product picker (product-specific logic). Inventory browser tree update deferred to future work.

🤖 Generated with Claude Code

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

* fix: Include ad unit sizes in tree API for format matching

Fix "Select Matched Formats" button not appearing when using hierarchical tree picker. The tree API response was missing size metadata, causing the format matching logic to fail.

Changes:
- Add `sizes` field to inventory tree API response (inventory.py:885)
- Update JavaScript to use sizes from tree response (add_product_gam.html:448)
- Remove hardcoded empty sizes array that was breaking matching

This enables the "Select All Matching" button to appear when ad units with size information are selected via the hierarchical tree picker.

Fixes: Format matching now works correctly with hierarchical ad unit selection
Tests: 861 unit tests passing

🤖 Generated with Claude Code

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

* fix: Extract sizes from child ad units in hierarchical tree

When a parent ad unit is selected from the tree picker, recursively extract sizes from all child ad units for format matching. This enables the "Select Matched Formats" button to appear when parent units with sized children are selected.

Changes:
- Add recursive extractSizesFromUnit() helper function
- Store children array in inventoryCache during tree rendering
- Recursively traverse child units to collect all sizes

Example: Selecting "Scribd Ad Exchange Display" (parent) now includes sizes from "Scribd 300x250" (child) for format matching.

Tests: 861 unit tests passing

🤖 Generated with Claude Code

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

* fix: Extract sizes directly from child objects in tree

Fix child size extraction by accessing sizes directly from child objects instead of looking them up in cache. The children array contains full objects from the tree API with sizes already populated.

Changes:
- Access child.sizes directly instead of cache lookup
- Add grandchildren caching for multi-level hierarchies
- Simplify recursive extraction logic

This fixes the issue where selecting a parent ad unit wasn't extracting sizes from its children for format matching.

Tests: 861 unit tests passing

🤖 Generated with Claude Code

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

* fix: Always update cache with tree data to include children

The critical bug: When editing a product, ad units were pre-cached from the flat list API (no children). Then when opening the tree picker, the tree rendering skipped re-caching because units were already cached, so the children array was never stored.

Solution: Always update the cache when rendering the tree, overwriting any previous data from the flat list API with the full hierarchical data including children.

This fixes child size extraction when editing existing products.

Tests: All tests passing

🤖 Generated with Claude Code

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

* fix: Load tree API when editing products to cache hierarchical data

Critical fix for edit mode: When editing a product with pre-selected ad units, fetch the tree API (not flat list) to ensure all units are cached with their children arrays. This enables size extraction from child ad units.

Changes:
- Replace flat list API call with tree API call in edit mode
- Add recursive cacheTreeUnits() to process entire tree hierarchy
- Ensures children arrays are available for size extraction on page load

This fixes the issue where selecting a parent ad unit in edit mode wouldn't extract sizes from its children.

Tests: 861 unit tests passing

🤖 Generated with Claude Code

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants