Skip to content

avnd ui: resolve file-path templates before syncing them to custom items#2114

Open
bltzr wants to merge 1 commit into
ossia:masterfrom
bltzr:fix/avnd-ui-file-paths
Open

avnd ui: resolve file-path templates before syncing them to custom items#2114
bltzr wants to merge 1 commit into
ossia:masterfrom
bltzr:fix/avnd-ui-file-paths

Conversation

@bltzr

@bltzr bltzr commented Jul 13, 2026

Copy link
Copy Markdown
Member

Problem

File-chooser port values are stored in the document as path templates (<PROJECT>:..., <LIBRARY>:..., or document-relative). Score's own file widgets resolve them through score::locateFilePath, but the avnd layout builder pushed the raw template string into custom UI items' value.

So an add-on widget bound to a soundfile/file/folder port received a path it cannot use — e.g. a waveform widget that decodes the file to display it in edit mode could never find <PROJECT>:samples/foo.wav. Values worked during execution only because the engine resolves paths on its own side, which made panels that depend on the path (waveform displays, folder pickers) appear empty until playback started.

Fix

Resolve through score::locateFilePath in LayoutBuilder::setupControl, both for the initial sync and in the valueChanged connections, whenever the inlet is a Process::FileChooserBase or Process::FolderChooser and the value is a non-empty string. Other value types and non-file ports are untouched.

Verified with an avnd add-on (Granola) whose custom waveform widget decodes the Sound port's file: with this change the widget receives /abs/path/samples/foo.wav at document load and can display the waveform in edit mode, matching the behavior of score's built-in file widgets.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AvD2PFHZtW6pfsh3gGhayg

File-chooser port values are stored in the document as path templates
(<PROJECT>:..., <LIBRARY>:..., or document-relative). Score's own file
widgets resolve them via score::locateFilePath, but the avnd layout
builder pushed the raw template string into custom ui items' `value`, so
an add-on widget bound to a soundfile/file/folder port received a path it
could not use (e.g. a waveform widget that decodes the file in edit mode
could never find it after the document moved or used project-relative
paths).

Resolve through score::locateFilePath in setupControl, both for the
initial sync and in the valueChanged connections, whenever the inlet is a
FileChooserBase or FolderChooser and the value is a non-empty string.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AvD2PFHZtW6pfsh3gGhayg
@bltzr bltzr requested a review from jcelerier July 13, 2026 22:38
@bltzr

bltzr commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

I think this is the reason why Granola's sound file port would not load the waveform at scenario load.

using avnd_port_type = pmf_member_type_t<decltype(item.model)>;
avnd_port_type p;
oscr::from_ossia_value(p, inl->value(), item.value);
oscr::from_ossia_value(p, resolveFilePath(inl->value(), inl, doc), item.value);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

arf, this is incurring the qobject_cast cost *2 on every widget creation, that's not great :/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the correct way here would be to do it statically: from avnd_port_type we know whether something is a file port, folder port, or something else. I'd add a separate "SetGUIValue" struct that follows the existing patterns for pattern-matching avendish port types at compile-time with concepts

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This way instead of being done at run-time it is done 100% at compile-time

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