Repository navigation
Conversation
Automated AI review
Outcome: A rejected new shell leaves the old reservation mapped beside its own. A rejected new shell keeps the old reservation
Suggested change: release in Reproducer (fails at 7b0df32)Reproducer: a rejected new shell keeps the previous shell's reservation and retries foreverReviewed head:
Today the rejected snapshot needs a bar thicker than 256 px ( The script runs the PR's host and the PR's unchanged Run: #!/usr/bin/env python3
"""Reproducer for omacom/omarchy#11887 at 7b0df32.
Runs the PR's reservation host (shell/bar-reservation/shell.qml) and the PR's
BarReservation.qml client under Quickshell's offscreen platform, each with a
private HOME and XDG_RUNTIME_DIR. Offscreen has no layer shell, so the host
copy swaps PanelWindow for FloatingWindow and drops the three layer-shell-only
properties (anchors, exclusiveZone, WlrLayershell); the socket, ownership,
parsing and visibility code is the PR's text.
1. Shell A connects and reserves the bar (26 px, as the running shell would).
2. omarchy-restart-shell announces the restart; A's connection closes.
3. Shell B (BarReservation.qml, unchanged) connects with a snapshot the host
rejects: a 300 px bar (State.parse caps size at 256).
4. A raw client sends a future protocol version (version 2).
Usage: python3 repro_reject_after_restart.py <omarchy checkout>
"""
import json
import os
from pathlib import Path
import resource
import shutil
import signal
import socket
import subprocess
import sys
import tempfile
import time
repo = Path(sys.argv[1]).resolve()
resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
work = Path(tempfile.mkdtemp(prefix='bar-repro-'))
(work / 'run').mkdir(mode=0o700)
(work / 'home/.local/state/omarchy/toggles').mkdir(parents=True)
sock = work / 'bar.sock'
env = dict(PATH=os.environ['PATH'], HOME=str(work / 'home'), XDG_RUNTIME_DIR=str(work / 'run'),
QT_QPA_PLATFORM='offscreen', QS_DISABLE_CRASH_HANDLER='1', QS_DISABLE_FILE_WATCHER='1',
QS_NO_RELOAD_POPUP='1', OMARCHY_BAR_SOCKET=str(sock), LANG='C.UTF-8')
procs = []
host = work / 'host'
host.mkdir()
qml = (repo / 'shell/bar-reservation/shell.qml').read_text()
qml = qml.replace('import Quickshell.Wayland\n', '')
qml = qml.replace(' model: Quickshell.screens\n delegate: PanelWindow {',
' id: surfaces\n model: Quickshell.screens\n delegate: FloatingWindow {')
start = qml.index(' anchors {')
qml = qml[:start] + qml[qml.index(' }\n', start) + 8:]
for line in (' exclusiveZone: root.snapshot.size\n', ' WlrLayershell.layer: WlrLayer.Bottom\n',
' WlrLayershell.namespace: "omarchy-bar-reservation"\n'):
assert line in qml
qml = qml.replace(line, '')
qml = qml.rstrip()[:-1] + ''' IpcHandler {
target: "repro"
function mapped(): bool { return surfaces.instances[0].visible }
}
}
'''
(host / 'shell.qml').write_text(qml)
shutil.copy(repo / 'shell/bar-reservation/State.js', host / 'State.js')
client = work / 'client'
client.mkdir()
shutil.copy(repo / 'shell/services/BarReservation.qml', client / 'BarReservation.qml')
(client / 'shell.qml').write_text('''import QtQuick
import Quickshell
import Quickshell.Io
ShellRoot {
id: repro
property var flips: []
property QtObject fakeBar: QtObject {
property string position: "top"
property int barSize: 300
property bool barHidden: false
property bool hiddenStateKnown: true
property color background: "#202020"
property color foreground: "#ffffff"
}
property BarReservation reservation: BarReservation {
bar: repro.fakeBar; supported: true; contentReady: true
onManagedChanged: repro.flips = repro.flips.concat([managed])
}
IpcHandler {
target: "repro"
function state(): string { return JSON.stringify({ managed: repro.reservation.managed, flips: repro.flips }) }
}
}
''')
def launch(directory):
process = subprocess.Popen(['quickshell', '-p', str(directory)], env=env,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True)
procs.append(process)
return process
def ipc(directory, target, function):
for _ in range(100):
result = subprocess.run(['quickshell', 'ipc', '-p', str(directory), 'call', target, function],
env=env, capture_output=True, text=True)
if result.returncode == 0:
return result.stdout.strip()
time.sleep(.05)
raise RuntimeError(result.stderr)
def connect():
connection = socket.socket(socket.AF_UNIX)
connection.settimeout(3)
connection.connect(str(sock))
return connection
def frame(**changes):
value = {'version': 1, 'screens': [''], 'position': 'top', 'size': 26, 'hidden': False,
'ready': True, 'background': '#111111', 'foreground': '#eeeeee'} # offscreen screen name is ''
value.update(changes)
return (json.dumps(value) + '\n').encode()
def report(step):
status = json.loads(ipc(host, 'reservation', 'status'))
print(f'{step}: host ready={status["ready"]} message={status["message"]!r} '
f'reserved size={status["snapshot"]["size"]} from background={status["snapshot"]["background"]} '
f'surface mapped={ipc(host, "repro", "mapped")}')
try:
launch(host)
ipc(host, 'reservation', 'ping')
shell_a = connect()
shell_a.sendall(frame())
shell_a.recv(8)
report('1. shell A connected')
ipc(host, 'reservation', 'restarting')
shell_a.close()
time.sleep(.5)
report('2. restart announced, shell A gone')
launch(client)
time.sleep(6)
state = json.loads(ipc(client, 'repro', 'state'))
print(f'3. shell B (300 px bar) after 6 s: managed={state["managed"]} managed transitions={state["flips"]}')
report('3. shell B (300 px bar) after 6 s')
future = connect()
future.sendall(frame(version=2))
reply = future.recv(8)
future.close()
time.sleep(.3)
report(f'4. version 2 client (reply {reply!r})')
finally:
for process in procs:
process.send_signal(signal.SIGTERM)
process.wait(5)
shutil.rmtree(work, ignore_errors=True)Actual output: For comparison, the same flow with a 26 px shell B is accepted at once: Without a host, the bar waits 2 s per start
Suggested change: use Reproducer: unset variable (fails at 7b0df32)Reproducer: with OMARCHY_BAR_SOCKET unset, the bar still waits 2 s for a reservation hostReviewed head:
Before this PR, Run:
"""Shared helpers for the #11887 follow-up reproducers (offscreen Quickshell).
The host copy swaps PanelWindow for FloatingWindow (offscreen has no layer
shell) and drops anchors, exclusiveZone and the WlrLayershell properties; the
socket, ownership, parsing and visibility code is the PR's text. The client is
the PR's BarReservation.qml, unchanged, next to a stand-in for the built-in bar.
The bar's visible and exclusionMode expressions are copied from the PR's
Bar.qml at run time, with `remapGuard.remapping` taken as false and `root.`
pointing at the stand-in.
"""
import json
import os
from pathlib import Path
import re
import resource
import shutil
import signal
import socket
import subprocess
import tempfile
import time
resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
class Lab:
def __init__(self, repo):
self.repo = Path(repo).resolve()
self.work = Path(tempfile.mkdtemp(prefix='bar-repro-'))
(self.work / 'run').mkdir(mode=0o700)
(self.work / 'home/.local/state/omarchy/toggles').mkdir(parents=True)
self.sock = self.work / 'bar.sock'
self.procs = []
self.base = dict(PATH=os.environ['PATH'], HOME=str(self.work / 'home'),
XDG_RUNTIME_DIR=str(self.work / 'run'), QT_QPA_PLATFORM='offscreen',
QS_DISABLE_CRASH_HANDLER='1', QS_DISABLE_FILE_WATCHER='1', QS_NO_RELOAD_POPUP='1', LANG='C.UTF-8')
self.t0 = time.monotonic()
def env(self, socket_value='default'):
env = dict(self.base)
if socket_value == 'default':
env['OMARCHY_BAR_SOCKET'] = str(self.sock)
elif socket_value is not None:
env['OMARCHY_BAR_SOCKET'] = socket_value
return env
def stamp(self):
return f'[{time.monotonic() - self.t0:5.1f}s]'
# ------------------------------------------------------------ configs
def make_host(self, name):
directory = self.work / name
directory.mkdir()
qml = (self.repo / 'shell/bar-reservation/shell.qml').read_text()
qml = qml.replace('import Quickshell.Wayland\n', '')
qml = qml.replace(' model: Quickshell.screens\n delegate: PanelWindow {',
' id: surfaces\n model: Quickshell.screens\n delegate: FloatingWindow {')
start = qml.index(' anchors {')
qml = qml[:start] + qml[qml.index(' }\n', start) + 8:]
for line in (' exclusiveZone: root.snapshot.size\n', ' WlrLayershell.layer: WlrLayer.Bottom\n',
' WlrLayershell.namespace: "omarchy-bar-reservation"\n'):
assert line in qml
qml = qml.replace(line, '')
qml = qml.rstrip()[:-1] + ''' IpcHandler {
target: "repro"
function mapped(): bool { return surfaces.instances[0].visible }
}
}
'''
(directory / 'shell.qml').write_text(qml)
shutil.copy(self.repo / 'shell/bar-reservation/State.js', directory / 'State.js')
return directory
def make_client(self, name):
directory = self.work / name
directory.mkdir()
shutil.copy(self.repo / 'shell/services/BarReservation.qml', directory / 'BarReservation.qml')
bar = (self.repo / 'shell/plugins/bar/Bar.qml').read_text()
match = re.search(r'\n visible: (!remapGuard\.remapping && [^\n]*)\n'
r' exclusionMode: ([^\n]*\n\s*\? ExclusionMode\.Ignore : ExclusionMode\.Auto)\n', bar)
assert match, 'BarPanel bindings not found'
visible = match.group(1).replace('remapGuard.remapping', 'false').replace('root.', 'harness.barRoot.')
exclusion = match.group(2).replace('root.', 'harness.barRoot.')
(directory / 'shell.qml').write_text('''import QtQuick
import Quickshell
import Quickshell.Io
ShellRoot {
id: harness
property real startedAt: Date.now()
property real waitingEndedAt: -1
property int retryTicks: 0
property var retryTimer: null
property QtObject bar: QtObject {
property string position: "top"
property int barSize: 26
property bool barHidden: false
property bool hiddenStateKnown: true
property color background: "#202020"
property color foreground: "#ffffff"
}
// shell.qml's `barReservation`, with supported and contentReady true.
property BarReservation barReservation: BarReservation {
bar: harness.bar
supported: true
contentReady: true
onWaitingChanged: if (!waiting && harness.waitingEndedAt < 0) harness.waitingEndedAt = Date.now()
}
// Stand-in for Bar.qml's root: it reads root.barHidden and root.shell.barReservation.
property QtObject barRoot: QtObject { property bool barHidden: false; property var shell: harness }
readonly property bool barVisible: %s
readonly property int barExclusion: %s
Component.onCompleted: {
var r = harness.barReservation.resources
for (var i = 0; i < r.length; i++) {
if (("triggeredOnStart" in r[i]) && r[i].interval === 1000 && r[i].repeat) {
harness.retryTimer = r[i]
r[i].triggered.connect(function() { harness.retryTicks++ })
}
}
}
IpcHandler {
target: "repro"
function state(): string {
var s = harness.barReservation
return JSON.stringify({ elapsedMs: Date.now() - harness.startedAt,
env: Quickshell.env("OMARCHY_BAR_SOCKET"), configured: s.configured, managed: s.managed,
waiting: s.waiting, barVisible: harness.barVisible,
barExclusion: harness.barExclusion === ExclusionMode.Ignore ? "Ignore"
: harness.barExclusion === ExclusionMode.Auto ? "Auto" : String(harness.barExclusion),
retryTimerRunning: harness.retryTimer ? harness.retryTimer.running : null,
retryTicks: harness.retryTicks,
waitingEndedAfterMs: harness.waitingEndedAt < 0 ? null : harness.waitingEndedAt - harness.startedAt })
}
}
}
''' % (visible, exclusion))
return directory, visible, exclusion
# ------------------------------------------------------------ processes
def launch(self, directory, env):
process = subprocess.Popen(['quickshell', '-p', str(directory)], env=env,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True)
self.procs.append(process)
return process
def ipc(self, directory, target, function, env):
for _ in range(200):
result = subprocess.run(['quickshell', 'ipc', '-p', str(directory), 'call', target, function],
env=env, capture_output=True, text=True)
if result.returncode == 0:
return result.stdout.strip()
time.sleep(.05)
raise RuntimeError(result.stderr)
def state(self, client, env):
return json.loads(self.ipc(client, 'repro', 'state', env))
def host_view(self, host):
status = json.loads(self.ipc(host, 'reservation', 'status', self.env()))
return (f'host ready={status["ready"]} message={status["message"]!r} '
f'snapshot screens={status["snapshot"]["screens"]} size={status["snapshot"]["size"]} '
f'surface mapped={self.ipc(host, "repro", "mapped", self.env())}')
def wait(self, predicate, timeout=10):
deadline = time.monotonic() + timeout
while time.monotonic() < deadline:
if predicate():
return True
time.sleep(.05)
return False
def close(self):
for process in self.procs:
if process.poll() is None:
process.send_signal(signal.SIGTERM)
process.wait(5)
shutil.rmtree(self.work, ignore_errors=True)
def short(state, keys):
return ' '.join(f'{k}={json.dumps(state[k])}' for k in keys)
#!/usr/bin/env python3
"""Q1: BarReservation.qml when OMARCHY_BAR_SOCKET is unset (omarchy#11887 @ 7b0df32).
Quickshell 0.3.1's Quickshell.env() returns null for an unset variable, and
BarReservation.qml computes `configured: Quickshell.env("OMARCHY_BAR_SOCKET") !== ""`.
Three main-shell environments: variable unset (what omarchy-launch-shell leaves
after its `unset OMARCHY_BAR_SOCKET` fallback), set to "", and set with a
reservation host listening.
Usage: python3 repro_unset_socket_env.py <omarchy checkout>
"""
import sys
import time
sys.path.insert(0, __file__.rsplit('/', 1)[0])
from common import Lab, short
KEYS = ['env', 'configured', 'managed', 'waiting', 'barVisible', 'barExclusion', 'retryTimerRunning', 'retryTicks']
lab = Lab(sys.argv[1])
try:
cases = [('unset', None), ('empty string', ''), ('set, host listening', 'default')]
printed = False
for index, (label, value) in enumerate(cases):
if value == 'default':
host = lab.make_host('host')
lab.launch(host, lab.env())
lab.ipc(host, 'reservation', 'ping', lab.env())
client, visible, exclusion = lab.make_client(f'client-{index}')
if not printed:
print('Bar.qml visible (as evaluated):', visible)
print('Bar.qml exclusionMode (as evaluated):', ' '.join(exclusion.split()))
printed = True
env = lab.env(value)
lab.launch(client, env)
print(f'== OMARCHY_BAR_SOCKET {label}')
for at in (0.5, 1.5, 2.5, 5.0):
lab.wait(lambda: lab.state(client, env)['elapsedMs'] >= at * 1000, timeout=10)
state = lab.state(client, env)
print(f' t={state["elapsedMs"] / 1000:.1f}s {short(state, KEYS)}')
state = lab.state(client, env)
ended = state['waitingEndedAfterMs']
print(' bar first visible after:', 'at start' if ended is None and not state['waiting'] else f'{ended / 1000:.2f}s')
finally:
lab.close()Actual output: The "set, host listening" row's Reproducer: exit status of a host that fails to loadReproducer:
|
7b0df32 to
bc68102
Compare
|
Restarting the shell drops the bar’s exclusive zone, expands tiled windows into that space, then shrinks them again when the bar returns. This PR keeps the built-in bar’s space reserved through shell restarts and crashes, with a status message in the strip until the shell returns.
A separate Quickshell configuration owns the reservation and loads no plugins or authentication services. The interactive bar occupies the same strip without reserving it twice. Bounded socket messages carry the current screens, edge, size, visibility, colors, and readiness. Explicit restarts, abnormal-exit retries, exhausted retries, and clean stops have distinct messages.
The launcher verifies host readiness before enabling reservation. An absent socket uses the normal bar immediately. Unsupported replacement snapshots release stale reservations without disturbing a live owner, and failed connections use fresh sockets with bounded exponential backoff, including on Quickshell 0.3.1.
September 30 review fixes
The production follow-up,
089420cd, addresses the four automated review findings: the main bar keeps its fallback reservation until the host acknowledges ownership; live visibility snapshots override missed flag-watcher events; restart notifications and shell shutdown target the selected compositor's display; and bar sizes above 256 pixels remain supported.A real
SIGSEGValso exposed an inherited-socket failure: Quickshell's crash helper can hold the previous connection open while the shell re-execs. A token shared by one launcher and its recovery attempts lets the replacement reclaim its reservation without allowing another launcher to displace a live owner. Closing the inherited socket cannot evict the replacement.Validation
quattroat8b4eae66, preserving notification readiness during restart and allowing the independent companion in the shell IPC test.0f9419e1, narrows acceptance cleanup to reporters carrying both Quickshell's crash-reporter marker and the launcher token from the test's deliberate crash. A focused check reproduces the previous cleanup killing an unrelated process; all nine checks pass after the fix, including preserving ordinary windows, unrelated/preexisting reporters, and the recovered shell. Python syntax and diff checks pass. This changes only the test harness; the graphical suite was not repeated for it.bc681021: seven of 288 shell test files failed, two files had skipped checks, and the CLI suite failed its VS Code theme assertion. The CLI failure and all seven shell failures reproduced on unchangedquattroat8b4eae66in the same VM. The shell failures arekernel-headers-migration,network-captive-portal,omarchy-kernel-migration,passwordless-grant-lifecycle,screenshot-sanity(missingomasnap),unowned-system-paths, andvideo-background. All changed-area tests passed. The full suite was not rerun for this follow-up.Scope and tradeoffs
This protects the built-in bar and its hosted plugins. Full replacement bars retain their existing exclusive-zone behavior. The companion itself or the compositor dying can still cause a layout change; the main bar falls back to owning its own zone and reconnects when the companion returns. The extra Qt Quick process measured roughly 80 MiB PSS in the original QA VM.
The companion survives main-shell restarts, so changes to its own QML take effect at the next session start. Architecture, lifecycle, and reproducible acceptance-test instructions are in
docs/bar-reservation.md.