diff --git a/docs/omarchy-shell.md b/docs/omarchy-shell.md index 6d1b0fd500d2..bcc85e08189c 100644 --- a/docs/omarchy-shell.md +++ b/docs/omarchy-shell.md @@ -180,6 +180,11 @@ Rules: 6. `barWidget.allowMultiple: true` in the manifest permits multiple instances. 7. `idle.screensaver` and `idle.lock` are seconds since user idle began. 8. `version: 1` is required. +9. A `bar.layout.
` entry may be a **group**: + `{ "type": "group", "collapsed": true, "items": [ ... ] }`. It wraps its + `items` behind a collapsible chevron (the tray-drawer gesture) and nests + ordinary entries. Groups are additive — older flat layouts stay valid without + a migration. See [`../shell/plugins/bar/README.md`](../shell/plugins/bar/README.md#widget-groups). `config/omarchy/shell.json` describes the fresh-install state. When no user `shell.json` exists, defaults are used verbatim. Once the user diff --git a/shell/Commons/Util.qml b/shell/Commons/Util.qml index 5ab02cb94a39..d7b7ed8fffed 100644 --- a/shell/Commons/Util.qml +++ b/shell/Commons/Util.qml @@ -130,6 +130,16 @@ QtObject { // input config; consumers can mutate without leaking back to shell.json. function normalizeLayoutEntry(entry) { if (typeof entry === "string") return { id: canonicalWidgetId(entry) } + // A group wraps child entries behind a collapsible chevron. It has no widget + // id of its own (one is optional, for addressing), so it must be recognized + // before the id branch below, which would otherwise drop it. Its children + // are normalized recursively so the same rules apply at every depth. + if (isPlainObject(entry) && String(entry.type || "") === "group") { + var group = cloneJson(entry) + if (group.id) group.id = canonicalWidgetId(group.id) + group.items = normalizeLayoutSection(group.items) + return group + } if (isPlainObject(entry) && entry.id) { var copy = cloneJson(entry) copy.id = canonicalWidgetId(copy.id) diff --git a/shell/Ui/BarCollapsible.qml b/shell/Ui/BarCollapsible.qml new file mode 100644 index 000000000000..e363d4df06bc --- /dev/null +++ b/shell/Ui/BarCollapsible.qml @@ -0,0 +1,97 @@ +import QtQuick +import qs.Commons + +// Collapsible bar container. Hides its content behind a chevron and reveals it +// with a hover-to-expand slide, the same gesture the system tray drawer uses. +// Collapsed, the container is only the chevron; it grows to fit its content as +// it opens, so a collapsed group costs no more bar space than its chevron. +// +// Content is supplied as a Component (not default children) so the chevron and +// clip below are not swallowed by a default-property alias, and so the loaded +// item is available to measure for the drawer extent. +Item { + id: root + + // Host bar, injected by the caller. Supplies vertical / barSize / theming for + // the chevron. Left null the component still lays out with Style fallbacks. + property var bar: null + readonly property bool vertical: bar ? bar.vertical : false + readonly property int barSize: bar ? bar.barSize : Style.bar.sizeHorizontal + + // The content to reveal. Its implicit size along the bar axis is the extent + // the drawer opens to. + property Component contentComponent: null + readonly property Item body: contentLoader.item + + property bool collapsedByDefault: true + property bool expandOnHover: true + // Chevron glyph. Escaped codepoint on purpose: raw Nerd Font glyphs can be + // mangled by file tooling, so the default stays stable this way. + property string icon: "" + property int animationDuration: 600 + + // A hover reveals transiently; a chevron click pins the drawer open so it + // survives the pointer leaving. pinnedOpen follows collapsedByDefault until the + // first chevron click breaks the binding and hands control to the user. It must + // stay a live binding: BarGroup sets the group's entry — and thus + // collapsedByDefault — right after load, so freezing on completion would lock in + // the pre-entry default and ignore a configured collapsed: false. + property bool pinnedOpen: !collapsedByDefault + property bool hovered: false + readonly property bool open: pinnedOpen || (expandOnHover && hovered) + + readonly property real drawerExtent: body ? (vertical ? body.implicitHeight : body.implicitWidth) : 0 + property real revealProgress: open ? 1 : 0 + readonly property real revealExtent: drawerExtent * revealProgress + + Behavior on revealProgress { + NumberAnimation { duration: Style.duration(root.animationDuration); easing.type: Easing.OutCubic } + } + + implicitWidth: vertical ? barSize : Math.round(chevron.implicitWidth + revealExtent) + implicitHeight: vertical ? Math.round(chevron.implicitHeight + revealExtent) : barSize + + // Whole-container hover drives the transient reveal. A HoverHandler on the + // root sees the chevron and the revealed content as one region, so sliding + // from the chevron onto the content does not collapse it mid-motion. + HoverHandler { + enabled: root.expandOnHover + onHoveredChanged: root.hovered = hovered + } + + BarIconButton { + id: chevron + bar: root.bar + width: implicitWidth + height: implicitHeight + text: root.icon + textRotation: root.vertical ? 90 : 0 + onPressed: function(button) { + if (button === Qt.LeftButton) root.pinnedOpen = !root.pinnedOpen + } + } + + // The revealed slice. Clipped so the content is wiped in from the chevron as + // the slice grows, and so a partially-open drawer never paints past its edge. + Item { + id: revealClip + x: root.vertical ? 0 : chevron.implicitWidth + y: root.vertical ? chevron.implicitHeight : 0 + width: root.vertical ? root.barSize : Math.round(root.revealExtent) + height: root.vertical ? Math.round(root.revealExtent) : root.barSize + clip: true + + // The content is laid out at its full extent regardless of how far the + // drawer has opened, so its widgets never reflow as it animates. On the + // cross axis it is sized to the content and centered, so content shorter + // than the bar sits centered rather than top/left-aligned. + Loader { + id: contentLoader + sourceComponent: root.contentComponent + x: root.vertical ? Math.round((root.barSize - implicitWidth) / 2) : 0 + y: root.vertical ? 0 : Math.round((root.barSize - implicitHeight) / 2) + width: root.vertical ? implicitWidth : root.drawerExtent + height: root.vertical ? root.drawerExtent : implicitHeight + } + } +} diff --git a/shell/Ui/qmldir b/shell/Ui/qmldir index dc9e0175eb5d..61436b491d98 100644 --- a/shell/Ui/qmldir +++ b/shell/Ui/qmldir @@ -1,5 +1,6 @@ module qs.Ui +BarCollapsible 1.0 BarCollapsible.qml BarIndicator 1.0 BarIndicator.qml BarIconButton 1.0 BarIconButton.qml BarIconContent 1.0 BarIconContent.qml diff --git a/shell/plugins/bar/Bar.qml b/shell/plugins/bar/Bar.qml index 4612547ad560..e882872ecbd9 100644 --- a/shell/plugins/bar/Bar.qml +++ b/shell/plugins/bar/Bar.qml @@ -904,6 +904,10 @@ Item { return BarModel.customModuleType(entry) } + function groupItems(entry) { + return BarModel.groupItems(entry) + } + function customModuleSource(entry) { var source = BarModel.customModulePath(entry, home, omarchyConfigDir) return source ? Util.fileUrl(source) : "" @@ -1023,6 +1027,10 @@ Item { for (var i = 0; i < moduleSlots.length; i++) { var slot = moduleSlots[i] if (!slot || slot === sourceSlot || !slot.visible || slot.width <= 0 || slot.height <= 0) continue + // A group and its children are not drop targets: their ids do not address + // the top-level layout a drop is persisted against. Drops snap to the + // nearest ordinary widget instead. + if (slot.isGroup || !slot.draggable) continue if (sourceWindow && !root.sameWindow(root.slotWindow(slot), sourceWindow)) continue if (slot.region === "tray" && !intoTraySection) continue @@ -1888,6 +1896,9 @@ Item { property var entries: [] property string region: "" + // Children of a group opt out of individual dragging: the drawer reorders + // as one block, and drop persistence addresses top-level entries by id. + property bool draggable: true visible: entries.length > 0 // A hidden list must not build its modules. The center section declares @@ -1913,6 +1924,7 @@ Item { required property var modelData entry: modelData region: moduleListRoot.region + draggable: moduleListRoot.draggable } } } @@ -1931,12 +1943,22 @@ Item { required property var modelData entry: modelData region: moduleListRoot.region + draggable: moduleListRoot.draggable } } } } } + // The child list for a group is a plain ModuleList, handed to BarGroup (a + // file type) as a Component. Passing it at runtime — rather than BarGroup + // naming ModuleList, or ModuleSlot naming an inline group component — is what + // keeps the bar's inline components from forming a resolution cycle. + Component { + id: groupListComponent + ModuleList {} + } + Component { id: traySectionComponent @@ -1951,9 +1973,13 @@ Item { required property var entry property string region: "" + // Slots inside a group opt out of individual dragging; the group reorders + // as one block. Top-level slots are draggable as before. + property bool draggable: true readonly property string moduleName: root.entryId(entry) readonly property var moduleSettings: root.entrySettings(entry) readonly property string customType: root.customModuleType(entry) + readonly property bool isGroup: customType === "group" readonly property var registryMetadata: root.barWidgetRegistry.metadataFor(root.canonicalWidgetId(moduleName)) readonly property bool firstParty: registryMetadata && registryMetadata.firstParty === true readonly property string pluginApiId: registered ? root.canonicalWidgetId(moduleName) : "bar-entry:" + moduleName @@ -1970,6 +1996,7 @@ Item { readonly property bool commandCustom: customType === "command" readonly property bool registered: registryComponent !== null readonly property var activeItem: { + if (isGroup) return groupLoader.item if (registered) return registryLoader.item if (qmlCustom) return qmlLoader.item return componentLoader.item @@ -2039,7 +2066,7 @@ Item { Loader { id: componentLoader - active: !slot.qmlCustom && !slot.registered + active: !slot.qmlCustom && !slot.registered && !slot.isGroup sourceComponent: slot.commandCustom ? customCommandModuleComponent : emptyModuleComponent anchors.fill: parent opacity: slot.dragSource ? 0.22 : 1.0 @@ -2049,6 +2076,26 @@ Item { } } + Loader { + id: groupLoader + active: slot.isGroup + // Loaded from a file (not an inline component) so the group -> slot -> group + // recursion does not make the bar's inline components form a cycle. + source: slot.isGroup ? Qt.resolvedUrl("BarGroup.qml") : "" + anchors.fill: parent + opacity: slot.dragSource ? 0.22 : 1.0 + onLoaded: { + if (item) { + item.bar = root + item.entry = slot.entry + item.region = slot.region + item.listComponent = groupListComponent + } + slot.injectProps() + Qt.callLater(slot.injectProps) + } + } + Loader { id: registryLoader active: slot.registered @@ -2121,7 +2168,11 @@ Item { property bool suppressClick: false property real pressedX: 0 property real pressedY: 0 + // A group and its children are not individually draggable: the group has + // no id to persist a move against, and its children reorder as one block. + // Clicks still route normally — only drag initiation is gated here. readonly property bool canReorder: root.shell && typeof root.shell.mutateShellConfig === "function" + && slot.draggable && !slot.isGroup readonly property real dragThreshold: Style.space(4) anchors.fill: parent diff --git a/shell/plugins/bar/BarGroup.qml b/shell/plugins/bar/BarGroup.qml new file mode 100644 index 000000000000..072225cb49ca --- /dev/null +++ b/shell/plugins/bar/BarGroup.qml @@ -0,0 +1,53 @@ +import QtQuick +import qs.Ui +import "BarModel.js" as BarModel + +// A collapsible group of bar widgets. Kept in its own file rather than an inline +// component of Bar.qml on purpose: a group contains widget slots, and a widget +// slot may itself be a group, so an inline component would make Bar.qml's +// components form a resolution cycle — which QML forbids ("Inline components +// form a cycle!"). A file type can be referenced recursively, so the recursion +// lives here. +// +// The children are rendered by a ModuleList handed in as `listComponent` (a +// runtime Component created by Bar.qml), so this file never names the bar's +// inline ModuleList / ModuleSlot types and the cycle stays broken. +Item { + id: root + + property var bar: null + property var entry: null + property string region: "" + // A bare ModuleList component supplied by the bar; its entries/region are + // filled once it loads. + property Component listComponent: null + + readonly property var groupSettings: BarModel.entrySettings(entry) + + implicitWidth: collapsible.implicitWidth + implicitHeight: collapsible.implicitHeight + + BarCollapsible { + id: collapsible + anchors.fill: parent + bar: root.bar + collapsedByDefault: root.groupSettings.collapsed !== false + expandOnHover: root.groupSettings.expandOnHover !== false + // A distinct default glyph so a group next to the tray drawer does not read + // as a second tray; an entry may override it via "icon". + icon: root.groupSettings.icon !== undefined && root.groupSettings.icon !== null + ? String(root.groupSettings.icon) : "\uf141" + + contentComponent: Component { + Loader { + sourceComponent: root.listComponent + onLoaded: { + if (!item) return + item.entries = BarModel.groupItems(root.entry) + item.region = root.region + item.draggable = false + } + } + } + } +} diff --git a/shell/plugins/bar/BarModel.js b/shell/plugins/bar/BarModel.js index e420bdb5861a..7de6da9cb0e9 100644 --- a/shell/plugins/bar/BarModel.js +++ b/shell/plugins/bar/BarModel.js @@ -123,6 +123,33 @@ function customModuleType(entry) { return "" } +// A group is a structural entry that wraps child widgets behind a collapsible +// chevron. It carries type:"group" and an items[] array; an id is optional and +// only used for addressing. Because customModuleType() reports "group" for it, +// the inline-settings delta already treats any change inside a group as +// structural and rebuilds the section — groups are opaque to the live patch for +// now, which is correct if not yet optimal. +function isGroupEntry(entry) { + return isPlainObject(entry) && String(entry.type || "") === "group" +} + +function groupItems(entry) { + if (!isGroupEntry(entry)) return [] + var items = entry.items + // Always return a fresh local Array so callers get real Array semantics and + // can't mutate the config-derived layout in place. Array.isArray() also + // returns false for an array created in another QML JS realm (the entry is + // built in Bar.qml but read from BarGroup.qml), so accept array-like objects + // too rather than dropping the children. + if (Array.isArray(items)) return items.slice() + if (items && typeof items === "object" && typeof items.length === "number") { + var result = [] + for (var i = 0; i < items.length; ++i) result.push(items[i]) + return result + } + return [] +} + function customModulePath(entry, home, configDir) { var settings = entrySettings(entry) var name = entryId(entry) @@ -339,6 +366,8 @@ if (typeof module !== "undefined") { expandPath: expandPath, customModuleSafeName: customModuleSafeName, customModuleType: customModuleType, - customModulePath: customModulePath + customModulePath: customModulePath, + isGroupEntry: isGroupEntry, + groupItems: groupItems } } diff --git a/shell/plugins/bar/README.md b/shell/plugins/bar/README.md index 8d8546167510..cda55ba841f2 100644 --- a/shell/plugins/bar/README.md +++ b/shell/plugins/bar/README.md @@ -74,6 +74,54 @@ Example `shell.json` (bar subtree only shown): The `omarchy.indicators` widget loads individual bar indicators from `indicators/`. Omit `items` (or set it to an empty array) to show all indicators in the default order, or set `items` to a subset such as `["Dnd", "Reminder", "NightLight"]`. Set `alwaysShow` to `true` to keep inactive indicators visible instead of revealing them only on hover. Multiple `omarchy.indicators` instances are allowed, so different sections can show different subsets. +## Widget groups + +Wrap several widgets in a `type: "group"` entry to tuck them behind a collapsible +chevron that reveals them on hover — the same gesture the system tray drawer +uses. A group is just another entry in the same flat `bar.layout.
` array, +so existing layouts keep working unchanged and no migration is needed. + +```json +{ + "version": 1, + "bar": { + "layout": { + "right": [ + { + "type": "group", + "collapsed": true, + "items": [ + { "id": "omarchy.agents" }, + { "id": "omarchy.system-update" } + ] + }, + { "id": "omarchy.audio" } + ] + } + } +} +``` + +Group settings: + +- `items` — the child entries. Each child is an ordinary bar entry (a string id, + an `{ id, ...settings }` object, or a custom `command`/`qml` module), so + children keep their own settings, panels, and IPC ids. +- `collapsed` — start collapsed (default `true`). Set `false` to start open. +- `expandOnHover` — reveal on hover (default `true`). With it set to `false`, click + the chevron to toggle. +- `icon` — override the chevron glyph. +- `id` — optional; only needed if you want to address the group by id. + +Left-clicking the chevron pins the drawer open so it stays revealed after the +pointer leaves; clicking again unpins it. + +A group is repositioned as one block by editing `shell.json`; its widgets are not +individually draggable and dragging the group itself is not yet supported. +Widgets inside a group are reachable by id (`omarchy toggle `) but not by the +positional panel hotkeys, which count only top-level widgets. Do not nest +`omarchy.tray` inside a group. + ## Orientation All widgets work in `top`, `bottom`, `left`, and `right` positions. Popups anchor on the side opposite the bar edge, sliding into the workspace. Vertical bars use 28px width; widgets that show text fall back to compact icon-only forms (e.g. `media` hides its scrolling label). diff --git a/test/acceptance.d/bar-group-test.sh b/test/acceptance.d/bar-group-test.sh new file mode 100755 index 000000000000..2fc04fca3d5b --- /dev/null +++ b/test/acceptance.d/bar-group-test.sh @@ -0,0 +1,119 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +# Exercise the collapsible widget group: a `type: "group"` layout entry that +# wraps children behind a chevron and reveals them like the tray drawer. The +# regression this guards is that older code dropped id-less group entries during +# layout normalization, so the grouped widgets vanished. The bar must keep +# rendering with a group configured, and the group must actually hide its +# children when collapsed and reveal them when open. +# +# The acceptance harness syncs this checkout into ~/.local/share/omarchy but +# leaves the live shell running the stock system path, so first repoint the +# session at the synced checkout and restart, or the shell under test would be +# the stock one without the group code. + +abs_omarchy="$HOME/.local/share/omarchy" + +# Track whether OMARCHY_PATH is present in the session env by its line (not a +# non-empty value), so restore() puts it back exactly — including an empty value +# — and only unsets it when it was truly absent. +env_dump=$(systemctl --user show-environment 2>/dev/null) +had_omarchy_path=0 +grep -q '^OMARCHY_PATH=' <<<"$env_dump" && had_omarchy_path=1 +original_path=$(sed -n 's/^OMARCHY_PATH=//p' <<<"$env_dump" | tail -1) + +config_dir="$HOME/.config/omarchy" +config="$config_dir/shell.json" +backup="$(mktemp)" +had_config=0 + +mkdir -p "$config_dir" +if [[ -f $config ]]; then + cp "$config" "$backup" + had_config=1 +fi + +restore() { + if (( had_config )); then + cp "$backup" "$config" + else + rm -f "$config" + fi + rm -f "$backup" + if (( had_omarchy_path )); then + systemctl --user set-environment OMARCHY_PATH="$original_path" >/dev/null 2>&1 || true + else + systemctl --user unset-environment OMARCHY_PATH >/dev/null 2>&1 || true + fi + omarchy-restart-shell >/dev/null 2>&1 || true +} +trap restore EXIT + +# The group's children are custom `command` modules echoing fixed text rather +# than first-party widgets, because every hardware-backed widget hides itself +# when its backing state is missing: system-update has no pending update, +# bluetooth no adapter, network no connection, tray no apps, power no battery. +# A clean CI image has none of them, so a group built from those measures 0px in +# *both* states, the two captures come out byte-identical, and the test passes +# while proving nothing. Fixed command output renders on any machine, and it is +# what the assertions below read back off the screen. +child_a="GROUPALPHA" +child_b="GROUPBETA" + +write_group_config() { + local collapsed="$1" + + cat >"$config" </dev/null 2>&1 || true +wait_until "shell restarts on the synced checkout with a collapsed group" 40 layer_on_screen "omarchy-bar" +sleep 3 +# On its own this would still pass with the group dropped altogether — which is +# the very regression being guarded — so it is the expanded case below that +# proves the children exist at all. +wait_until "collapsed group hides its children" 20 screen_lacks "$child_a" +screenshot "success-bar-group-collapsed" + +# Expanded (collapsed:false starts the drawer open) so a screenshot captures the +# revealed widgets — the state a hover produces. Restart rather than reload: a +# config reload is not guaranteed to rebuild the section for this change, and a +# run that silently keeps rendering the previous state is how a bar group test +# ends up asserting nothing. +write_group_config false +omarchy-restart-shell >/dev/null 2>&1 || true +wait_until "bar renders with an expanded group" 40 layer_on_screen "omarchy-bar" +sleep 3 +wait_until "expanded group reveals its first child" 30 screen_contains "$child_a" +wait_until "expanded group reveals its second child" 20 screen_contains "$child_b" +screenshot "success-bar-group-expanded" diff --git a/test/acceptance.d/base-test.sh b/test/acceptance.d/base-test.sh index 23ca140234ef..084d4ec64717 100644 --- a/test/acceptance.d/base-test.sh +++ b/test/acceptance.d/base-test.sh @@ -48,6 +48,13 @@ screen_contains() { return $status } +# Negative counterpart to screen_contains, mirroring layer_absent/window_absent. +# Pair it with wait_until to assert something has gone (or never arrived) on +# screen rather than merely that the surface still exists. +screen_lacks() { + ! screen_contains "$1" +} + # Poll a command until it succeeds; screenshot and fail on timeout. wait_until() { local description="$1" timeout="$2" diff --git a/test/shell.d/bar-group-test.sh b/test/shell.d/bar-group-test.sh new file mode 100644 index 000000000000..d800732aff9b --- /dev/null +++ b/test/shell.d/bar-group-test.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +run_node_test <<'JS' +const fs = require('fs') +const bar = requireFromRoot('shell/plugins/bar/BarModel.js') +const barSource = fs.readFileSync(root + '/shell/plugins/bar/Bar.qml', 'utf8') +const utilSource = fs.readFileSync(root + '/shell/Commons/Util.qml', 'utf8') +const uiQmldir = fs.readFileSync(root + '/shell/Ui/qmldir', 'utf8') +const collapsibleSource = fs.readFileSync(root + '/shell/Ui/BarCollapsible.qml', 'utf8') +const barGroupSource = fs.readFileSync(root + '/shell/plugins/bar/BarGroup.qml', 'utf8') +const traySource = fs.readFileSync(root + '/shell/plugins/bar/widgets/Tray.qml', 'utf8') + +// A type:"group" entry is a structural wrapper the bar renders as a collapsible +// drawer of child widgets. BarModel recognises it and reads its children. +const group = { type: 'group', collapsed: true, items: [{ id: 'omarchy.agents' }, { id: 'omarchy.system-update' }] } +assert(bar.isGroupEntry(group), 'bar recognises a group entry') +assert(!bar.isGroupEntry({ id: 'omarchy.clock' }), 'a plain widget entry is not a group') +assert(!bar.isGroupEntry('omarchy.clock'), 'a string entry is not a group') +assert(!bar.isGroupEntry(null), 'a missing entry is not a group') +assertDeepEqual( + bar.groupItems(group).map(bar.entryId), + ['omarchy.agents', 'omarchy.system-update'], + 'bar reads a group child ids' +) +assert(bar.groupItems(group) !== group.items, 'bar returns a fresh group items array, not the config reference') +assertDeepEqual(bar.groupItems({ id: 'omarchy.clock' }), [], 'a non-group has no group items') +assertDeepEqual(bar.groupItems({ type: 'group' }), [], 'a group with no items reads as empty') +assertEqual(bar.entryId(group), '', 'an id-less group has no entry id') +assertEqual(bar.customModuleType(group), 'group', 'a group reports its type') + +// A change anywhere inside a group is structural for the live patch: the delta +// is null so the section rebuilds rather than patching a nested entry in place. +assertEqual( + bar.inlineSettingsDelta( + { left: [group], center: [], right: [] }, + { left: [{ type: 'group', collapsed: false, items: group.items }], center: [], right: [] } + ), + null, + 'bar rebuilds when a group changes rather than patching in place' +) + +// The assertions above run BarModel's exported helpers to validate behavior. +// The source-text regex checks below are deliberate: they guard QML *structure* +// the node harness cannot execute — e.g. that a group renders through the +// BarGroup file rather than an inline component (the fix for a load-time +// "inline components form a cycle" crash). Each is scoped to a specific +// regression with no runtime equivalent in this suite. + +// Layout normalization must keep group entries (they have no id of their own) +// and normalize their children recursively, or the group would be dropped. +assert(/entry\.type[\s\S]*?=== "group"/.test(utilSource), 'layout normalization preserves group entries') +assert( + /group\.items = normalizeLayoutSection\(group\.items\)/.test(utilSource), + 'layout normalization recurses into group items' +) + +// The bar renders a group through the shared collapsible container, not the +// registry or custom-module loaders. +assert(/readonly property bool isGroup: customType === "group"/.test(barSource), 'bar marks a group slot') +assert(/if \(isGroup\) return groupLoader\.item/.test(barSource), 'bar routes a group slot to the group loader') + +// A group is rendered from the BarGroup *file* and handed a plain ModuleList as a +// runtime Component. This is what keeps the group -> slot -> group recursion from +// making the bar's inline components form a cycle (QML forbids that, and it is a +// load-time crash, not something qmllint catches). +assert(/source: slot\.isGroup \? Qt\.resolvedUrl\("BarGroup\.qml"\)/.test(barSource), 'bar loads a group from the BarGroup file, not an inline component') +assert(/id: groupListComponent[\s\S]{0,40}ModuleList \{\}/.test(barSource), 'bar hands the group a plain ModuleList component') +assert(/BarCollapsible \{/.test(barGroupSource), 'the group renders inside the shared collapsible') +// Guard the cycle fix: the group file must not name the bar's inline types. +const barGroupCode = barGroupSource.replace(/\/\/.*$/gm, '') +assert(!/\bModuleList\b|\bModuleSlot\b/.test(barGroupCode), 'the group file names no inline bar types, so the recursion stays file-based') +assert( + /active: !slot\.qmlCustom && !slot\.registered && !slot\.isGroup/.test(barSource), + 'a group slot is kept out of the empty-module fallback' +) + +// A group and its children are not draggable, and are excluded as drop targets, +// so a reorder never tries to persist an id-less or nested entry. +assert(/&& slot\.draggable && !slot\.isGroup/.test(barSource), 'a group is not a drag source') +assert(/if \(slot\.isGroup \|\| !slot\.draggable\) continue/.test(barSource), 'a group is not a drop target') + +// The shared collapsible is registered and reuses the tray drawer motion. +assert(/BarCollapsible 1\.0 BarCollapsible\.qml/.test(uiQmldir), 'the shared collapsible is registered in the Ui module') +assert( + /easing\.type:\s*Easing\.OutCubic/.test(collapsibleSource), + 'the collapsible animates its reveal with an OutCubic curve' +) +// Style.duration() collapses to 0 under reduceMotion, which is on by default in +// VMs. The tray drawer routed its own animation through it before the motion +// moved here, so the shared collapsible has to keep honoring it. +assert( + /duration:\s*Style\.duration\(root\.animationDuration\)/.test(collapsibleSource), + 'the collapsible honors the shell no-animations mode' +) +assert(/animationDuration:\s*600/.test(collapsibleSource), 'the collapsible matches the tray drawer duration it mirrors') + +// The collapsible is the group's own container and carries no tray-only modes: +// the tray keeps its own drawer, which has since grown tray-specific behavior +// (drop sections, hold-open during a bar drag) this component does not model. +assert(!/reserveSpace/.test(collapsibleSource), 'the collapsible carries no leftover tray reserve-space mode') +assert(!/BarCollapsible/.test(traySource), 'the tray keeps its own drawer rather than being refactored here') +JS