Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions migrations/1788986100.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
echo "Patch cloned panel plugins that wrote centerHoverRevealSuppressed directly"

# When PluginBarApi made centerHoverRevealSuppressed readonly (4.0.3), any
# panel plugin cloned before that change kept the old pattern:
#
# if (root.bar && "centerHoverRevealSuppressed" in root.bar)
# root.bar.centerHoverRevealSuppressed = value
#
# which now fires a TypeError on every open/close, spamming the Quickshell log
# and stalling the event loop. Panel.qml base now owns the correct
# setCenterHoverRevealSuppressed() implementation, so clones that still carry a
# local copy of the broken pattern just need it stripped out to inherit from base.
#
# We only touch files that have the broken assignment and belong to a plugin
# cloned from omarchy.clock or omarchy.weather (the only first-party panels
# that use this call). Any plugin that already has the right form, or that has
# a genuinely different local override, is left alone.

PLUGINS_DIR="$HOME/.config/omarchy/plugins"

[[ -d $PLUGINS_DIR ]] || exit 0

broken_assignment='root.bar.centerHoverRevealSuppressed = value'
patched=0

while IFS= read -r -d '' manifest; do
plugin_dir="$(dirname "$manifest")"

# Only process clones of clock or weather panels
# A manifest jq cannot read is not a clone to patch, and must not abort the queue.
cloned_from="$(jq -r '.omarchy.clonedFrom // empty' "$manifest" 2>/dev/null || true)"
[[ $cloned_from == "omarchy.clock" || $cloned_from == "omarchy.weather" ]] || continue

# Find QML files that still contain the broken assignment
while IFS= read -r -d '' qml_file; do
grep -qF "$broken_assignment" "$qml_file" || continue

backup=$(mktemp "${qml_file}.bak.XXXXXX")
cp -p "$qml_file" "$backup"

# Remove only the stock 4.0.0-4.0.2 override and its directly preceding comment
# lines; an override the user has edited is left exactly as it is.
perl -0777 -i -pe '
s{(?:\n[ \t]*//[^\n]*)*\n[ \t]*function setCenterHoverRevealSuppressed\(value\) \{\n[ \t]*if \(root\.bar && "centerHoverRevealSuppressed" in root\.bar\)\n[ \t]*root\.bar\.centerHoverRevealSuppressed = value\n[ \t]*\}(?=\n)}{}g;
' "$qml_file"
Comment on lines +43 to +45

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 QML rewrite lacks regression tests This exact-match rewrite changes user-owned QML, but there is no test for a historical clone, an edited override, or a second run. A later change to the match could silently leave a panel broken or alter user code. Add fixture-based checks for what the migration patches, preserves, and backs up.

Knowledge Base Used: Migration framework

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


if cmp -s "$backup" "$qml_file"; then
rm -f "$backup"
Comment on lines +47 to +48

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Skipped clones go unreported If a clone's helper was edited but still contains the incompatible property write, the exact replacement leaves it unchanged. This branch removes the backup, and the migration reports that no clone needed patching before it is marked complete. The user gets no indication that the panel may still fail to close. Preserve the edited code, but report clones that still need a manual repair.

Knowledge Base Used: Migration framework

else
echo " Patched: $qml_file (backup: $backup)"
(( patched++ )) || true
fi
done < <(find "$plugin_dir" -name "*.qml" -print0)

done < <(find "$PLUGINS_DIR" -maxdepth 2 -name "manifest.json" -print0)

if (( patched > 0 )); then
echo " Patched $patched file(s)."
else
echo " No cloned panel plugins needed patching."
fi

11 changes: 11 additions & 0 deletions shell/Ui/Panel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ Item {
return value === undefined || value === null ? fallback : value
}

// Suppress or restore the center-section hover reveal while this panel is
// open. Delegates through the PluginBarApi function so the call works on
// any bar build; if the function is absent (pre-4.0.3 builds still in
// use by a cloned plugin) it falls back to a direct property write.
function setCenterHoverRevealSuppressed(value) {
if (bar && typeof bar.setCenterHoverRevealSuppressed === "function")
bar.setCenterHoverRevealSuppressed(value)
else if (bar && "centerHoverRevealSuppressed" in bar)
bar.centerHoverRevealSuppressed = value
}

PanelController {
id: panelController
}
Expand Down
8 changes: 0 additions & 8 deletions shell/plugins/panels/clock/Panel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,6 @@ Panel {
return false
}

// Summoning by hotkey moves no pointer, so a hover the bar was still
// holding must not keep the center indicators revealed behind the panel.
function setCenterHoverRevealSuppressed(value) {
if (root.bar && typeof root.bar.setCenterHoverRevealSuppressed === "function")
root.bar.setCenterHoverRevealSuppressed(value)
else if (root.bar && "centerHoverRevealSuppressed" in root.bar)
root.bar.centerHoverRevealSuppressed = value
}

function refresh() {
root.today = new Date()
Expand Down
7 changes: 0 additions & 7 deletions shell/plugins/panels/weather/Panel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@ Panel {
return false
}

function setCenterHoverRevealSuppressed(value) {
if (root.bar && typeof root.bar.setCenterHoverRevealSuppressed === "function")
root.bar.setCenterHoverRevealSuppressed(value)
else if (root.bar && "centerHoverRevealSuppressed" in root.bar)
root.bar.centerHoverRevealSuppressed = value
}

// Parsed wttr.in j1 response. Kept on failure so stale data stays visible.
property var report: null
property var dailyForecastReport: null
Expand Down