Repository navigation
Group bar widgets on shared ovals - #13570
AbaddonTataken wants to merge 2 commits into
Conversation
Layout entries may carry a `group` name; consecutive visible entries sharing it sit on one oval, with padding inside and a gap to their neighbours (BarModel.groupInsets/groupSpans). The anchored center groups its before-list, anchor and after-list as one sequence, so a group can run across the center anchor. `omarchy bar set <id> group <name>` regroups live, widgets that hide drop out of their group, and themes colour the ovals with `[bar] group-background` in shell.toml. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Automated AI review
Outcome: Two live updates leave stale group layout; open PR #13139 reuses Anchor keeps a stale group
Suggested change: restore the binding in Reproducer (fails at 5c7cccb; a QML model built from Bar.qml lines)Center anchor keeps a stale group after a live group changeReproduces the anchor slot keeping the group set by applySettingsDelta after a later layout rebuild hands it an entry without a group. The anchor slot (centerAnchorModule) is not inside a Repeater, so it is the one slot object that survives rebuilds. Reviewed head: 5c7cccb. Qt 6.11.2, offscreen platform. Run from a scratch directory holding this file and a copy of QT_QPA_PLATFORM=offscreen /usr/lib/qt6/bin/qmltestrunner -input tst_anchor_group_stale.qml
// Stale group on the center anchor after a live `omarchy bar set <anchor> group ...`.
// Lines tagged "Bar.qml:N" are copied from shell/plugins/bar/Bar.qml at 5c7cccbf.
// Run from a directory holding this file and shell/plugins/bar/BarModel.js:
// QT_QPA_PLATFORM=offscreen /usr/lib/qt6/bin/qmltestrunner -input tst_anchor_group_stale.qml
import QtQuick
import QtTest
import "BarModel.js" as BarModel
Item {
id: root
function entrySettings(entry) { return BarModel.entrySettings(entry) }
function entryId(entry) { return BarModel.entryId(entry) }
// centerAnchorModule (Bar.qml:1633) is declared directly in the center section,
// not inside a Repeater, so a layout rebuild re-evaluates its `entry` binding on
// the same object instead of creating a new slot.
Item {
id: anchorSlot
property var entry: ({ id: "omarchy.clock", format: "dddd HH:mm" })
property string region: "center"
readonly property string moduleName: root.entryId(entry)
readonly property var moduleSettings: root.entrySettings(entry) // Bar.qml:2020
property string group: moduleSettings.group ? String(moduleSettings.group) : "" // Bar.qml:2024
}
// applySettingsDelta's new lines (Bar.qml:612-616), reached by
// `omarchy bar set omarchy.clock group time` through the inline settings delta.
function applySettingsDelta(entry) {
var settings = entrySettings(entry)
var slot = anchorSlot
var group = settings.group ? String(settings.group) : ""
if (slot.group !== group) {
slot.group = group
}
}
TestCase {
name: "AnchorGroup"
function test_anchor_group_follows_its_entry_after_a_rebuild() {
// 1. omarchy bar set omarchy.clock group time
applySettingsDelta({ id: "omarchy.clock", format: "dddd HH:mm", group: "time" })
compare(anchorSlot.group, "time")
// 2. A later change that rebuilds the layout (for example `omarchy bar defaults`
// after any reorder) hands the anchor slot a fresh entry without `group`.
anchorSlot.entry = { id: "omarchy.clock", format: "dddd HH:mm" }
compare(anchorSlot.moduleSettings.group, undefined, "the new entry has no group")
compare(anchorSlot.group, "", "the anchor's group follows the new entry")
}
}
}Actual output (exit 1): Padding ignores text sizeInsets ignore Suggested change: call Reproducer (fails at 5c7cccb; a QML model built from Bar.qml lines; shows the stale inset, while the 4 and 2 px figures come from a fuller model that also grows the widgets)Group padding does not follow a live text-size or spacing-scale changeReproduces groupPad/groupGap updating with Style.space() while the insets already written onto the slots keep the old values, because no handler reruns updateGroupInsets when the pad or gap changes. Reviewed head: 5c7cccb. Qt 6.11.2, offscreen platform. Run from a scratch directory holding this file and a copy of QT_QPA_PLATFORM=offscreen /usr/lib/qt6/bin/qmltestrunner -input tst_spacing_scale_insets.qml
// Group padding after a live text-size or spacing-scale change.
// Lines tagged "Bar.qml:N" are copied from shell/plugins/bar/Bar.qml at 5c7cccbf and
// Style.space from shell/Commons/Style.qml (Style.* replaced by root.*).
// Run from a directory holding this file and shell/plugins/bar/BarModel.js:
// QT_QPA_PLATFORM=offscreen /usr/lib/qt6/bin/qmltestrunner -input tst_spacing_scale_insets.qml
import QtQuick
import QtTest
import "BarModel.js" as BarModel
Item {
id: root
// Style.qml:211-223. `omarchy display text size 18` sets [font] base-size = 18,
// so fontScale and effectiveSpacingScale become 1.5 while the shell runs.
property real effectiveSpacingScale: 1.0
function spaceReal(px) { var n = Number(px); if (!isFinite(n) || n <= 0) return 0; return n * effectiveSpacingScale }
function space(px) { var n = spaceReal(px); if (n <= 0) return 0; return Math.max(1, Math.round(n)) }
Item {
id: moduleListRoot
readonly property real groupPad: root.space(7) // Bar.qml:1875
readonly property real groupGap: root.space(6) // Bar.qml:1876
// What updateGroupInsets (Bar.qml:1895-1905) writes onto the slots. It is scheduled
// from applySettingsDelta, onEntriesChanged, onLoaded, Repeater itemAdded/itemRemoved
// and ModuleSlot.onShownChanged (Bar.qml:615, 1935-1936, 1967-1968, 1999-2000, 2028);
// nothing reruns it when groupPad or groupGap change.
property var slotInsets: []
function updateGroupInsets() {
slotInsets = BarModel.groupInsets(["g1", "g1", "g2"], groupPad, groupGap)
}
Component.onCompleted: updateGroupInsets()
}
TestCase {
name: "SpacingScale"
function test_insets_follow_a_live_spacing_scale_change() {
compare(moduleListRoot.slotInsets[0].lead, 7)
root.effectiveSpacingScale = 1.5
wait(50)
console.log("groupPad", moduleListRoot.groupPad, "first slot lead inset", moduleListRoot.slotInsets[0].lead)
compare(moduleListRoot.groupPad, 11)
compare(moduleListRoot.slotInsets[0].lead, moduleListRoot.groupPad, "padding follows the new scale")
}
}
}Actual output (exit 1): Overlap with #13139#13139 ends pill runs where Suggested change: agree on More findingsOpen-panel mark is longer at group endsThe fallback mark length ( Suggested change: subtract Open-panel mark is longer on widgets at the ends of a groupReproduces the open-panel mark fallback length being computed from the padded slot width, so bluetooth and audio at the ends of the manual's example group get a 24px mark while network in the middle (and any ungrouped widget) gets 17px. Reviewed head: 5c7cccb. Qt 6.11.2, offscreen platform. Run from a scratch directory holding this file and a copy of QT_QPA_PLATFORM=offscreen /usr/lib/qt6/bin/qmltestrunner -input tst_panel_mark_extent.qml
// Open-panel mark length for widgets at the ends of a group.
// Lines tagged "Bar.qml:N" are copied from shell/plugins/bar/Bar.qml at 5c7cccbf
// (Style.space replaced by root.space at spacing scale 1, a shown 30px widget).
// Run from a directory holding this file and shell/plugins/bar/BarModel.js:
// QT_QPA_PLATFORM=offscreen /usr/lib/qt6/bin/qmltestrunner -input tst_panel_mark_extent.qml
import QtQuick
import QtTest
import "BarModel.js" as BarModel
Item {
id: root
property bool vertical: false
function space(px) { return Math.max(1, Math.round(px)) }
component Slot: Item {
id: slot
property real leadInset: 0
property real trailInset: 0
implicitWidth: 30 + leadInset + trailInset // Bar.qml:2063, horizontal and shown
width: implicitWidth
height: 26
// Bar.qml:2061, the fallback used by widgets without an openPanelIndicatorWidth hint
readonly property real panelIndicatorExtent: Math.max(root.space(10), Math.round((root.vertical ? slot.height : slot.width) * 0.55))
}
// Right section of the manual's example: agents, then bluetooth/network/audio in
// group "controls", then monitor. Insets come from the PR's BarModel.groupInsets
// with groupPad = Style.space(7) and groupGap = Style.space(6) (Bar.qml:1875-1876).
readonly property var insets: BarModel.groupInsets(["", "controls", "controls", "controls", ""], space(7), space(6))
Slot { id: agents; leadInset: root.insets[0].lead; trailInset: root.insets[0].trail }
Slot { id: bluetooth; leadInset: root.insets[1].lead; trailInset: root.insets[1].trail }
Slot { id: network; leadInset: root.insets[2].lead; trailInset: root.insets[2].trail }
Slot { id: audio; leadInset: root.insets[3].lead; trailInset: root.insets[3].trail }
TestCase {
name: "PanelMark"
function test_equal_widgets_get_equal_marks_inside_a_group() {
console.log("extents agents/bluetooth/network/audio:",
agents.panelIndicatorExtent, bluetooth.panelIndicatorExtent,
network.panelIndicatorExtent, audio.panelIndicatorExtent)
compare(network.panelIndicatorExtent, agents.panelIndicatorExtent, "middle of a group matches an ungrouped widget")
compare(bluetooth.panelIndicatorExtent, network.panelIndicatorExtent, "group start matches group middle")
compare(audio.panelIndicatorExtent, network.panelIndicatorExtent, "group end matches group middle")
}
}
}Actual output (exit 1): Anchored center ovals vanish while the anchor is hiddenCenter ovals take their thickness from the anchor slot, which is 0×0 while hidden, so they collapse to zero thickness while a self-hiding Suggested change: use the section's own cross size, as plain lists do. Anchored center ovals collapse to zero thickness when the anchor hidesReproduces the anchored center deriving every oval's cross-axis size from the anchor slot, which has zero size while the anchor widget hides itself. Reviewed head: 5c7cccb. Qt 6.11.2, offscreen platform. Run from a scratch directory holding this file and a copy of QT_QPA_PLATFORM=offscreen /usr/lib/qt6/bin/qmltestrunner -input tst_hidden_anchor_oval.qml
// Anchored center: oval thickness when the anchor widget hides itself.
// Lines tagged "Bar.qml:N" are copied from shell/plugins/bar/Bar.qml at 5c7cccbf
// (horizontal bar, barSize 26, Style.space at scale 1).
// Run from a directory holding this file and shell/plugins/bar/BarModel.js:
// QT_QPA_PLATFORM=offscreen /usr/lib/qt6/bin/qmltestrunner -input tst_hidden_anchor_oval.qml
import QtQuick
import QtTest
import "BarModel.js" as BarModel
Item {
id: root
property bool vertical: false
function space(px) { return Math.max(1, Math.round(px)) }
// The anchor slot's size: Bar.qml:2063-2064 with a 60x26 widget that can hide.
Item {
id: centerAnchorModule
property bool shown: true
implicitWidth: shown ? 60 : 0
implicitHeight: shown ? 26 : 0
width: implicitWidth
height: implicitHeight
}
// The center host's cross-axis size for every oval (Bar.qml:1594, 1596-1597).
function centerOvalThickness() {
var vertical = root.vertical
var slotCross = vertical ? centerAnchorModule.width : centerAnchorModule.height
var inset = root.space(4)
var thickness = Math.max(0, slotCross - inset * 2)
return thickness
}
TestCase {
name: "HiddenAnchor"
function test_neighbour_group_keeps_its_oval_when_the_anchor_hides() {
// Center layout [Q t, anchor t, R t]: with the anchor hidden, Q and R are
// still one visible run (groupSlots drops hidden slots), so one oval is drawn.
var spans = BarModel.groupSpans([
{ group: "t", start: 400, end: 437, lead: 7, trail: 0 },
{ group: "t", start: 437, end: 484, lead: 0, trail: 7 }
], root.space(7))
compare(spans.length, 1)
compare(centerOvalThickness(), 18, "thickness with the anchor shown")
centerAnchorModule.shown = false
console.log("thickness with the anchor hidden:", centerOvalThickness())
verify(centerOvalThickness() > 0, "Q and R keep a visible oval")
}
}
}Actual output (exit 1): Anchor at a group end sits off centre
Suggested change: offset the anchor by Anchored widget leaves the exact centre when it sits at a group endReproduces the anchor's content shifting by (lead inset - trail inset) / 2 because the padded slot, not the widget, is centred; the shift changes when the neighbour on the other side hides. Reviewed head: 5c7cccb. Qt 6.11.2, offscreen platform. Run from a scratch directory holding this file and a copy of QT_QPA_PLATFORM=offscreen /usr/lib/qt6/bin/qmltestrunner -input tst_anchor_offset.qml
// Anchored widget position when it sits at one end of a group.
// Lines tagged "Bar.qml:N" are copied from shell/plugins/bar/Bar.qml at 5c7cccbf
// (horizontal bar, Style.space at scale 1, a 60px anchor widget in a 1000px bar).
// Run from a directory holding this file and shell/plugins/bar/BarModel.js:
// QT_QPA_PLATFORM=offscreen /usr/lib/qt6/bin/qmltestrunner -input tst_anchor_offset.qml
import QtQuick
import QtTest
import "BarModel.js" as BarModel
Item {
id: root
width: 1000
height: 26
function space(px) { return Math.max(1, Math.round(px)) }
// Center layout [elsewhen, clock (anchor) in group "time", weather in group "time"]
// with elsewhen shown or hidden. Insets from the PR's BarModel.groupInsets.
property bool leftNeighbourShown: true
readonly property var insets: leftNeighbourShown
? BarModel.groupInsets(["", "time", "time"], space(7), space(6))
: BarModel.groupInsets(["time", "time"], space(7), space(6))
readonly property var clockInsets: leftNeighbourShown ? insets[1] : insets[0]
Item {
id: centerAnchorModule
property real leadInset: root.clockInsets.lead
property real trailInset: root.clockInsets.trail
implicitWidth: 60 + leadInset + trailInset // Bar.qml:2063
width: implicitWidth
height: 26
anchors.centerIn: parent // Bar.qml:1643
Item {
id: widget
anchors.fill: parent
anchors.leftMargin: centerAnchorModule.leadInset // Bar.qml:2108
anchors.rightMargin: centerAnchorModule.trailInset // Bar.qml:2109
}
}
TestCase {
name: "AnchorOffset"
when: windowShown
function offset() { return widget.mapToItem(root, widget.width / 2, 0).x - root.width / 2 }
function test_anchor_widget_stays_on_the_centre() {
var shownOffset = offset()
root.leftNeighbourShown = false
wait(20)
var hiddenOffset = offset()
console.log("clock centre offset, left neighbour shown/hidden:", shownOffset, hiddenOffset)
compare(shownOffset, 0, "clock centred with its left neighbour shown")
compare(hiddenOffset, 0, "clock centred with its left neighbour hidden")
}
}
}Actual output (exit 1): DetailsVerified (offscreen QML harness built from
Optional test improvement: 7 of 10 deliberate code mutations still pass The live-regroup assertion passes without the regroup callTest-validity reproducer. Reviewed head: 5c7cccb. Steps, in a disposable copy of the PR head:
Mutation applied ( diff -r a/shell/plugins/bar/Bar.qml b/shell/plugins/bar/Bar.qml
615d614
< if (slot.list) slot.list.scheduleGroups()Actual result: exit status In the mutated file the regex match runs from Same method, other behaviours the new tests do not cover (each change applied alone to a copy of the head; M1 (doubled gap between adjacent groups), M2 (oval misses its padding) and M8 (the live group assignment removed) fail. M3 (live regroup call removed), M4 (hidden-widget regroup handler removed), M5 (content insets removed), M6 (oval refresh after repositioning removed), M7 ( Overlap check: merged as text with Review informationTest scope: Source, PR tests, offscreen QML models at AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check. Opt out: To stop receiving these reviews, reply to this comment saying so. |
|
Hi @AbaddonTataken, llstrk's review points at the overlap with #13139, which uses |
- The center anchor slot survives rebuilds, so a live `group` change left it grouped; it now rebinds to its entry on entry change. - Group padding and gap follow a live text-size change. - The open-panel mark ignores the group padding when sizing itself. - Anchored center ovals take their thickness from the section, so they survive the anchor hiding itself. - The anchor is centred on its widget, not its padded slot, at a group end. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks @cristian-fleischer, and thanks @llstrk for the review. All six findings are fixed in fbe2812: the center anchor now follows its entry after a live On |
|
|
Thanks, agreed: |
What
Any bar layout entry can carry a
"group"name. Consecutive visible entries in a section with the same name sit on one soft oval, which makes a busy bar easier to scan:omarchy bar set <id> group <name>regroups live (no shell restart).centerAnchor) works too: widgets before the anchor, the anchor, and widgets after it group as one sequence, so e.g. clock + keyboard layout share one oval across the anchor.[bar] group-background/group-background-alphainshell.toml(default: theme foreground at 8%).Entries without
groupare laid out exactly as before; a bar with no groups is unchanged.How
BarModel.js:groupInsets(groups, pad, gap)gives each visible slot its lead/trail inset;groupSpans(slots, pad)turns laid-out slots into oval spans.ModuleSlotgetsgroup,leadInset,trailInsetandshown; its loaders and open-panel mark sit inside the insets, so widgets keep their own geometry.ModuleListrecomputes insets when its entries or a slot's visibility change and redraws ovals onpositioningComplete. In the anchored center, the before/after lists hand this to the section (groupHost), which maps all three pieces into one coordinate space and draws the ovals itself.applySettingsDeltaupdates a slot'sgroupand regroups its section, so livebar setchanges take effect without a reload.Color.bar.groupanddefault/themed/shell.toml.tpl.Docs
manual/05-the-top-bar.md(new "Grouping widgets" section),shell/plugins/bar/README.md,docs/omarchy-shell.md(layout key and theme token).Tests
test/shell.d/bar-test.sh:groupInsets/groupSpanscases (padding, gaps, adjacent groups, ungrouped, missing input), and source checks that lists lay groups out throughBarModel, ovals use the theme token, livegroupchanges regroup, the anchored center groups across the anchor, and the template defines the token../test/all: 4086 passing (11 new), no new failures. The 8 failures on my machine fail identically on unmodifiedquattro(environment:omasnapnot installed, noomarchy-isocheckout, kernel headers, browser launcher, VS Code theme, cache cleanup, network portal fixture, apre_removehook).Visual verification
Verified on a running session with the default layout plus groups (workspaces; clock + keyboard layout across the center anchor; bluetooth + network; audio + display; power), then
omarchy bar set omarchy.power group avlive: power joined the audio/display oval without a restart.Screenshots (initial grouping, and after the live
bar set) are attached below.🤖 Generated with Claude Code