omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Bar: every inline command module logs TypeError: Cannot assign to read-only property "moduleName"

Open jeremy opened this issue 3 months ago • 5 comments

Every instantiation of an inline type: "command" bar module logs this warning twice (as of 94554969):

Aug 20 10:19:12 thelio omarchy-shell[2779]:   WARN scene: @plugins/bar/Bar.qml[1751:-1]: TypeError: Cannot assign to read-only property "moduleName"
Aug 20 10:19:12 thelio omarchy-shell[2779]:   WARN scene: @plugins/bar/Bar.qml[1751:-1]: TypeError: Cannot assign to read-only property "moduleName" (exception occurred during delayed function evaluation)

One-line diagnosis: injectProps() (shell/plugins/bar/Bar.qml:1754) does target.moduleName = moduleName guarded only by "moduleName" in target, but CustomCommandModule declares readonly property string moduleName (Bar.qml:1768) — the in check passes for readonly properties, so the assignment throws on every inline command-module slot.

Harmless in practice — the readonly property already computes the same value from entry — but it fires on every command module the user configures, and the thrown TypeError also aborts injectProps() before the settings assignment on the next line, which would matter if a command module ever grew a writable settings dependency.

Reproduce: add any inline command module to bar.layout in ~/.config/omarchy/shell.json and watch journalctl --user -f.

jeremy avatar Aug 20 '26 20:08 jeremy

Confirmed, and reproduced on a worker VM running quattro at ed7bae4a: two inline type: "command" modules in bar.layout.right produce four WARN scene: @plugins/bar/Bar.qml[1754:-1]: TypeError: Cannot assign to read-only property "moduleName" lines per shell start, two per module, exactly as you describe.

Your diagnosis holds, with two additions. settings is readonly as well (Bar.qml:1769), so the next line (Bar.qml:1755) would throw too if it were ever reached — a command module could not grow a writable settings dependency without changing that declaration first. And the two lines come from different call sites: the direct call in componentLoader.onLoaded (Bar.qml:1596) and the deferred one from onActiveItemChanged (Bar.qml:1747). The first throw is what stops Qt.callLater(slot.injectProps) on Bar.qml:1597 from ever being queued.

Severity is log noise only, as you suspected: CustomCommandModule binds bar, moduleName and settings itself from the same entry the slot holds, and on the worker both modules ran their exec normally with the TypeError sitting in the journal.

It shipped in 4.0.0 but is not tied to 94554969. injectProps() used to target registryLoader.item || qmlLoader.item, so command modules were never injected into at all; 3b970068 ("Split out indicators", 20 May) switched it to activeItem and added the componentLoader.onLoaded hook, which is what put command modules on this path. Only they are affected today — registry widgets (Ui/BarWidget.qml:16-17) and indicators (Ui/BarIndicator.qml:7-8) declare all three writable — though nothing enforces that for third-party plugin widgets or for a user's own type: "qml" module, which would throw the same way.

There is already an open PR for this: #6503, which wraps the assignments in try/catch. Two things about it are worth knowing before it lands, both measured on the same worker. Its approach doubles the journal noise instead of removing it: the four TypeErrors became eight WARN qml: module slot inject: skipping non-writable property moduleName/settings lines, because settings now warns too and the direct call no longer aborts before queueing the deferred one. And its Node-side regression test cannot fail — BarModel.js is non-strict, so assignment to an Object.defineProperty(..., writable: false) key silently no-ops there whether or not the try/catch is present. The narrower alternative, returning early from injectProps() for command-custom slots because they need no injection, was tried on the same worker: journal clean, both modules still running their exec, and bar-test.sh, bar-widget-contract-test.sh, bar-icon-geometry-test.sh and bar-text-color-test.sh green.

I have not opened a PR, to avoid competing with #6503; which of the two shapes to take is the maintainer's call. A second opinion from codex at xhigh agreed on the mechanism and the severity, and contributed the 3b970068 attribution and the non-strict-mode point above.

omarchybot avatar Aug 21 '26 12:08 omarchybot

Confirming on omarchy 4.0.2-1 / quickshell 0.3.1-1, with two details that make the scope wider than the title suggests. Same defect and same injectProps() — adding it here rather than filing separately.

It is two properties, not one. injectProps() assigns three, and two of them are readonly:

Bar.qml:1769    if ("bar" in target) target.bar = root
Bar.qml:1770    if ("moduleName" in target) target.moduleName = moduleName
Bar.qml:1771    if ("settings" in target) target.settings = moduleSettings
Bar.qml:1784    readonly property string moduleName: root.entryId(entry)
Bar.qml:1785    readonly property var settings: root.entrySettings(entry)

bar is fine — WidgetButton.qml:7 declares it property var bar: null, writable. So each pass throws twice, for moduleName and for settings. A fix that addresses only moduleName would leave half of it in place.

It fires more often than "every reload." Five call sites, three of them double calls:

Bar.qml:1611-1613  onLoaded: { slot.injectProps(); Qt.callLater(slot.injectProps) }
Bar.qml:1623-1625  onLoaded: { slot.injectProps(); Qt.callLater(slot.injectProps) }
Bar.qml:1635-1637  onLoaded: { slot.injectProps(); Qt.callLater(slot.injectProps) }
Bar.qml:1763       onActiveItemChanged: Qt.callLater(injectProps)
Bar.qml:1764       onModuleSettingsChanged: injectProps()

Each loader slot calls injectProps() directly and then schedules it again via Qt.callLater, so a single load already yields two passes; active-item and module-settings changes add more on top.

On the in guards. They read as defensive but cannot help here: "moduleName" in target is true for a readonly property — the property exists, it just refuses assignment. The guard tests presence when what matters is writability, so it passes in precisely the case that throws.

nathankramm avatar Sep 05 '26 18:09 nathankramm

Rechecked against quattro at b83d3df0. The defect is still there: ModuleSlot.injectProps() (shell/plugins/bar/Bar.qml:2030-2037) still assigns moduleName and settings behind in guards, and CustomCommandModule still declares both readonly (Bar.qml:2049-2050). As @nathankramm noted above, both properties throw, not only moduleName.

The fix PR named in my earlier comment, #6503, has since been closed as a duplicate of #9972. That PR is now the open fix for this issue and already names it as closed by the merge, so nothing else needs to be filed. #9972 is being reviewed and tested on a worker as its own item. This issue waits on the maintainer's decision about that PR.

No second opinion ran on this pass. The configured reviewer (Codex Medium) answers a ping, but today's review budget was already spent, so this recheck is one model's reading of the source.

omarchybot avatar Oct 08 '26 12:10 omarchybot

Still happening on 4.0.6-1 with an inline type: "command" bar module. It logs once per bar (twice with two monitors):

WARN scene: @plugins/bar/Bar.qml[2021:-1]: TypeError: Cannot assign to read-only property "moduleName"
WARN scene: @plugins/bar/Bar.qml[2021:-1]: TypeError: Cannot assign to read-only property "moduleName" (exception occurred during delayed function evaluation)

The current quattro branch still has the same unguarded write (shell/plugins/bar/Bar.qml:2411, target.moduleName = moduleName) against CustomCommandModule's readonly property string moduleName. The fix PR #9972 now has merge conflicts.

mhmodmonim avatar Oct 22 '26 13:10 mhmodmonim

This is fixed on quattro, but the fix is not in a stable release yet, which is why 4.0.6-1 still logs it. b7e900ced (#15517, "Rework bar dragging, sections and widget orientation") turned CustomCommandModule's moduleName and settings into ordinary writable properties (shell/plugins/bar/Bar.qml:2716-2719 on quattro). WidgetHost.injectProps() still writes both at Bar.qml:2411-2412, as @mhmodmonim says, but the command widget now accepts the writes, so nothing throws. The first tag that contains it is v4.5.0-rc1. v4.0.6 is tagged before it and still declares both readonly (Bar.qml:2035-2036 there), so the error persists until 4.5.0.

I ran both versions on a worker VM with one inline command module (exec, interval) added to bar.layout.right. On v4.0.6 the journal showed exactly the two lines quoted above, Bar.qml[2021:-1]: TypeError: Cannot assign to read-only property "moduleName", once direct and once deferred. On quattro at 446361a5f there were none. The module's exec ran every interval, including after a live edit of shell.json that re-runs the injection.

So #9972 no longer has a bug to fix, and its conflicts come from the same rework. The note on that PR recommends closing it. One case is still open, and it is not specific to this issue: a user's own type: "qml" module or a third-party widget that declares bar, moduleName or settings as readonly would throw the same way, because the in guards check whether a property exists, not whether it can be written. Every shipped widget and indicator declares them writable, as the bar README's example does.

Who checked: I read both trees and reproduced on the worker. As a second opinion, Codex Medium and muse-spark-1.3-contributor (via pi, thinking high) checked the source independently. They agreed it is fixed on quattro and not in v4.0.6, and confirmed that every shipped target of the injection is writable. Codex also traced the change to b7e900ced and its first tag. Both raised the custom-QML case above. Independence is not guaranteed, since they were shown my conclusion to check.

Next: I recommend closing this issue as fixed by #15517, which ships in 4.5.0. Closing it is the maintainer's call, so the issue waits on them.

omarchybot avatar Oct 22 '26 14:10 omarchybot