Skip to content

Support for metadata and script subtype.#5583

Merged
Rider-Linden merged 4 commits intoproject/lua_editorfrom
rider/script_metadata
Mar 30, 2026
Merged

Support for metadata and script subtype.#5583
Rider-Linden merged 4 commits intoproject/lua_editorfrom
rider/script_metadata

Conversation

@Rider-Linden
Copy link
Copy Markdown
Contributor

@Rider-Linden Rider-Linden commented Mar 26, 2026

Description

Uses script subtype (LSL/lua) and new script.runtime metadata to select correct language parser and default compile target in editor.

Issue #4840

Depends On

https://github.com/secondlife/agent-inventory-service/pull/77
https://github.com/secondlife/server/pull/2414

Copy link
Copy Markdown
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

Adds viewer-side support for script language subtype (LSL vs Lua) and new script.runtime inventory metadata to pick the correct editor language mode and default compile target when opening scripts.

Changes:

  • Update script preview editor to switch language mode (setLuauLanguage) when the compile target changes.
  • On inventory script load, derive is_lua from inventory subtype and derive compile target from script.runtime (with sensible defaults).
  • Extend inventory model/serialization with a new mRuntime field (LLSD + legacy metadata import).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
indra/newview/llpreviewscript.cpp Uses subtype/runtime to initialize editor language + compile target; updates compile-target-change handling to set language mode.
indra/llinventory/llinventory.h Adds getRuntime() / setRuntime() APIs and stores runtime string on inventory objects.
indra/llinventory/llinventory.cpp Imports runtime from legacy metadata, includes runtime in LLSD serialization/deserialization, and copies runtime during object/item copy.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2060 to +2062
bool is_lua = (mScriptEd->mCompileTarget->getValue().asString() == "luau");
mScriptEd->mEditor->setLuauLanguage(is_lua);
mScriptEd->processKeywords(is_lua);
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

LLPreviewLSL::onCompileTargetChanged() now updates the editor’s language mode via setLuauLanguage(), but LLLiveLSLEditor::onCompileTargetChanged() in the same file still only calls processKeywords(...). If setLuauLanguage() is required for correct parsing/diagnostics (not just highlighting), the live editor path should be updated similarly to keep behavior consistent when changing compile targets.

Copilot uses AI. Check for mistakes.
Comment on lines +818 to +825
if (metadata.has("script") && metadata["script"].has("runtime"))
{
setRuntime(metadata["script"]["runtime"].asString());
}
else
{
setRuntime(std::string());
}
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

In LLInventoryItem::importLegacyStream(), runtime is applied while processing the metadata line. However, the legacy exportLegacyStream() format writes metadata before the type line, so mType may still be unset when setRuntime() runs, and the runtime can be lost. A robust fix is to cache the parsed runtime value from metadata and apply it after the type field has been read (or make setRuntime() independent of current mType during import).

Copilot uses AI. Check for mistakes.
Comment on lines +303 to +310
if (metadata.has("script") && metadata["script"].has("runtime"))
{
setRuntime(metadata["script"]["runtime"].asString());
}
else
{
setRuntime(std::string());
}
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

Runtime is now imported from legacy metadata["script"]["runtime"], but LLInventoryItem::exportLegacyStream() currently only emits a metadata line when a thumbnail is present and does not serialize script.runtime at all. That means mRuntime will not round-trip through the viewer’s legacy inventory cache/export format. Consider extending legacy export metadata to include script.runtime (and emitting metadata when runtime is present even if no thumbnail is set).

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
{
setRuntime(std::string());
}

Copy link
Copy Markdown
Contributor

@akleshchev akleshchev Mar 26, 2026

Choose a reason for hiding this comment

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

You probably want this in LLInventoryItem::fromLLSD(), not in category.

importLegacyStream is for notecards, asset cache and udp messages, for ecerything else, it's fromLLSD

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually. I can remove that altogether here. runtime will never apply to a folder.

@Rider-Linden Rider-Linden merged commit f209aff into project/lua_editor Mar 30, 2026
17 checks passed
@Rider-Linden Rider-Linden deleted the rider/script_metadata branch March 30, 2026 21:12
@github-actions github-actions bot locked and limited conversation to collaborators Mar 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants