Skip to content

[6.x] Prototype of an asset reference viewer#13832

Draft
jackmcdade wants to merge 1 commit into6.xfrom
asset-reference-viewer
Draft

[6.x] Prototype of an asset reference viewer#13832
jackmcdade wants to merge 1 commit into6.xfrom
asset-reference-viewer

Conversation

@jackmcdade
Copy link
Member

@jackmcdade jackmcdade commented Feb 5, 2026

CleanShot 2026-02-05 at 11 47 49@2x

It's just a Cursor prototype of the feature, nothing production-ready. But useful to chat about if this is the direction we'd like to go with this feature.

From statamic/ideas#1412


Note

Cursor Bugbot is generating a summary for commit f0f314b. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

if ($matches[3] === $this->assetPath) {
$this->found = true;
}
}
Copy link

Choose a reason for hiding this comment

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

Only first statamic URL checked in string fields

Medium Severity

The findStatamicUrlsInStringValue method uses preg_match which only finds the first statamic URL in a string field. If a Bard or Markdown field contains multiple asset references and the target asset isn't in the first URL, the reference will be missed. The existing AssetReferenceUpdater::updateStatamicUrlsInStringValue correctly uses preg_replace_callback to process all matches, but this new finder only checks the first one.

Fix in Cursor Fix in Web

$entries = $entries->slice(($page - 1) * $perPage, $perPage)->values();

// Use the first entry's blueprint for processing, but we'll use simple columns
$blueprint = $entries->first()->blueprint();
Copy link

Choose a reason for hiding this comment

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

Null pointer error on out-of-bounds pagination page

Medium Severity

When a pagination page beyond the available results is requested, $entries->slice() returns an empty collection. The subsequent call to $entries->first()->blueprint() then attempts to call blueprint() on null, causing a fatal error. The emptiness check on line 184 only validates the original unsliced collection, not the paginated result.

Fix in Cursor Fix in Web

@martyf
Copy link
Contributor

martyf commented Feb 5, 2026

This looks awesome Jack, and thanks for considering the idea. If that real estate feels too tight, a Stack could be useful too as then it could be triggered from the Asset browser for an individual “…” for an asset. Like the Revisions panel approach.

@edalzell
Copy link
Contributor

edalzell commented Feb 5, 2026

I loooove this feature. However I wonder if it might be structured a bit differently. Instead of finding everything, what if we kept track of where everything was used (like in https://github.com/thoughtco/statamic-cache-tracker). That way the CP side is extremely performant (imagine some sites that have 20k+ entries etc) and we can use that for other bits of components too, like entries. We could even use a local sqlite db to store all of this, which would make the look ups wicked fast.

The stache watcher would do this work locally to keep things up to date and of course the save listeners/etc used on the CP side.

Only brainstorming here, this caught my interest.

@jasonvarga
Copy link
Member

Instead of finding everything, what if we kept track of where everything was used

This is ideal, but would require some rearchitecture. I think the idea of this PR is to get something, even if it's not performant.

a Stack could be useful

I think this is a good idea. It probably takes some overhead to find references, especially when there's a lot of content. Showing it in a stack means you could trigger it when you open the stack. As opposed to doing all the work whenever the asset editor is opened.

Or maybe not a stack - could even be a popover. But I think making it happen on click might be a better idea.

@edalzell
Copy link
Contributor

edalzell commented Feb 5, 2026

Instead of finding everything, what if we kept track of where everything was used

This is ideal, but would require some rearchitecture. I think the idea of this PR is to get something, even if it's not performant.

Yup, I get it, was only doing some thinking while it was top of mind.

@jackmcdade
Copy link
Member Author

But I think making it happen on click might be a better idea.

It does this now actually. You click a button and then it fetches.

@jasonvarga
Copy link
Member

Well then.

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.

4 participants