Skip to content

[bugfix] assets: keep media used by live pinned references listed - #130

Merged
nikiwang-125 merged 1 commit into
mainfrom
fix/asset-list-pinned-references
Nov 6, 2026
Merged

nikiwang-125 merged 1 commit into
mainfrom
fix/asset-list-pinned-references

Conversation

@nikiwang-125

Copy link
Copy Markdown
Collaborator

Summary

Fixes #120.

An asset that a generation config pins directly (binding=pinned, no canvas node) disappeared from the asset list ("all" and "hidden") and became available=false in reference-catalog once another asset listed it in provenance.sources, for example after a generation result was registered. The file and the live reference were still there.

Cause: CreationHistory._inventory puts every provenance.sources asset into historical, while current only counted canvas items, current results, and subject documents. It did not count live pinned references. Both asset_list and reference_catalog hide historical - current.

Fix: _inventory now adds the assets of active pinned references to current.

  • Listing: with no canvas owner, the asset shows under "hidden" (未显示).
  • Removing the reference: the asset goes back to being filtered as a historical source, as before.
  • Deletion protection: unchanged. _usage_many already treats live references, provenance, and history as dependencies.

Test plan

New test test_asset_used_only_by_an_active_pinned_reference_stays_listed_after_becoming_a_source:

  • pins an asset with no canvas node, then makes it another asset's provenance.sources;
  • checks it is still in "all" and "hidden", catalog available and fileAvailable are true, the result survives a fresh store (reopen), and usage still reports it as used;
  • after reference.remove, checks it is filtered as before and still protected from deletion.

Results:

  • The new test fails on main and passes with the fix.
  • tests/test_creation_history_service.py: 17 passed.
  • History, reference editor, API, node versions, workflow, canvas service, and assets test files: 113 passed, 1 failed (Windows).
  • The 1 failure is test_symlinked_content_and_asset_paths_are_rejected_without_external_writes. It fails identically on unmodified main on Windows (symlink permissions).

Not covered: this was run on Windows only, not Linux, and there is no browser end-to-end check. The new test makes the asset a source through asset.writeText with previousAsset, which writes the same provenance.sources as a registered result, instead of going through artifact.publish, which does not run on Windows.

Note for review: a canvas-derived pinned reference (with sourceVersion) that still pins an older node version will now also be listed as hidden, because it is a live reference too. Pure historical versions that nothing references are still filtered.

🤖 Generated with Claude Code

## summary

- An asset that a generation config pins directly (no canvas node) vanished
  from the asset list and was marked unavailable in the reference catalog as
  soon as another asset named it in provenance.sources, e.g. after a
  generation result was registered.
- `_inventory` now counts active pinned references as current, so the asset
  stays in "all" / "hidden" and remains selectable; once the reference is
  removed it is filtered as historical again, as before.
- Deletion protection is unchanged; it already read live references.

Fixes #120

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nikiwang-125
nikiwang-125 merged commit 4c05ef3 into main Nov 6, 2026
@hsliuustc0106
hsliuustc0106 deleted the fix/asset-list-pinned-references branch November 6, 2026 08:52
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.

[bug] 素材管理:仍被有效固定参考使用的素材从资产列表消失

1 participant