diff --git a/CHANGELOG.md b/CHANGELOG.md
index d7fc45f8..e253a51e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,8 @@ Notable changes to Syncshell and its shell adapters are documented here.
## Unreleased
+- ask Syncthing to rescan a directory only once while that rescan is still
+ running, so repeated index updates during a pull cannot pile up requests
- keep the syncing file name visible during bulk syncs: the core no longer
stalls for up to minutes on lookups and rescans for files Syncthing already
reported, and the Omarchy folder card no longer rebuilds on each update
diff --git a/bin/aarch64/syncshell-core b/bin/aarch64/syncshell-core
index 1d4a3906..0cf2d9e7 100755
Binary files a/bin/aarch64/syncshell-core and b/bin/aarch64/syncshell-core differ
diff --git a/bin/x86_64/syncshell-core b/bin/x86_64/syncshell-core
index 2fa10b63..bf79d29f 100755
Binary files a/bin/x86_64/syncshell-core and b/bin/x86_64/syncshell-core differ
diff --git a/core/internal/session/activity.go b/core/internal/session/activity.go
index 007c8356..3af37c45 100644
--- a/core/internal/session/activity.go
+++ b/core/internal/session/activity.go
@@ -122,6 +122,37 @@ func (s *Session) rememberFinished(folderID, path string, now time.Time) {
s.finishedItems[folderID+"\x00"+path] = now.Add(finishedItemMemory)
}
+// rescanSubdirectory runs in the background: Syncthing answers only once the
+// scan ends, which waits for any pull. A directory already being rescanned is
+// not asked again, so repeated index events cannot pile up requests.
+func (s *Session) rescanSubdirectory(ctx context.Context, folderID, subdirectory string) {
+ key := folderID + "\x00" + subdirectory
+ s.rescansMu.Lock()
+ if s.rescansInFlight[key] {
+ s.rescansMu.Unlock()
+ return
+ }
+ if s.rescansInFlight == nil {
+ s.rescansInFlight = make(map[string]bool)
+ }
+ s.rescansInFlight[key] = true
+ s.rescansMu.Unlock()
+ go func() {
+ defer func() {
+ s.rescansMu.Lock()
+ delete(s.rescansInFlight, key)
+ s.rescansMu.Unlock()
+ }()
+ _ = s.client.RescanSubdirectory(ctx, folderID, subdirectory)
+ }()
+}
+
+func (s *Session) rescanInFlight(folderID, subdirectory string) bool {
+ s.rescansMu.Lock()
+ defer s.rescansMu.Unlock()
+ return s.rescansInFlight[folderID+"\x00"+subdirectory]
+}
+
func (s *Session) localIndex(ctx context.Context, event syncthing.Event, now time.Time) bool {
var data struct {
Folder string `json:"folder"`
@@ -151,10 +182,7 @@ func (s *Session) localIndex(ctx context.Context, event syncthing.Event, now tim
continue
}
if fileType(entry.Type) == "directory" && !entry.Deleted {
- // Syncthing answers only once the scan ends, which waits for any pull.
- go func(folderID, subdirectory string) {
- _ = s.client.RescanSubdirectory(ctx, folderID, subdirectory)
- }(data.Folder, name)
+ s.rescanSubdirectory(ctx, data.Folder, name)
continue
}
action := "syncing"
diff --git a/core/internal/session/events_test.go b/core/internal/session/events_test.go
index 094c9049..0c1e9814 100644
--- a/core/internal/session/events_test.go
+++ b/core/internal/session/events_test.go
@@ -617,3 +617,38 @@ func cancelEventUpdates(
t.Fatal("event loop did not cancel")
}
}
+
+func TestSubdirectoryRescanIsNotRepeatedWhileInFlight(t *testing.T) {
+ api := &actionAPI{folders: map[string]syncthing.Folder{},
+ devices: []syncthing.Device{{DeviceID: "LOCAL"}},
+ pending: syncthing.PendingFolders{}, theme: "default",
+ rescanStarted: make(chan struct{}, 1), rescanRelease: make(chan struct{})}
+ coreSession := newActionSession(t, api)
+ ctx := context.Background()
+ coreSession.rescanSubdirectory(ctx, "folder", "directory")
+ select {
+ case <-api.rescanStarted:
+ case <-time.After(2 * time.Second):
+ t.Fatal("first rescan never reached Syncthing")
+ }
+ // Still blocked in Syncthing: the same directory is not asked again.
+ coreSession.rescanSubdirectory(ctx, "folder", "directory")
+ close(api.rescanRelease)
+ for deadline := time.Now().Add(2 * time.Second); coreSession.rescanInFlight("folder", "directory"); {
+ if time.Now().After(deadline) {
+ t.Fatal("finished rescan stayed in flight")
+ }
+ time.Sleep(5 * time.Millisecond)
+ }
+ if count := api.rescanCount(); count != 1 {
+ t.Fatalf("rescans while one was in flight: %d", count)
+ }
+ // Once it has finished, the directory can be rescanned again.
+ coreSession.rescanSubdirectory(ctx, "folder", "directory")
+ for deadline := time.Now().Add(2 * time.Second); api.rescanCount() != 2; {
+ if time.Now().After(deadline) {
+ t.Fatalf("a later rescan was dropped: %d", api.rescanCount())
+ }
+ time.Sleep(5 * time.Millisecond)
+ }
+}
diff --git a/core/internal/session/session.go b/core/internal/session/session.go
index d2be8d4e..d6813bf9 100644
--- a/core/internal/session/session.go
+++ b/core/internal/session/session.go
@@ -67,6 +67,8 @@ type Session struct {
activityMu sync.Mutex
activityRecords map[string]activityRecord
finishedItems map[string]time.Time
+ rescansMu sync.Mutex
+ rescansInFlight map[string]bool
lastFile *Activity
lastFileUntil time.Time
activityIndex int
diff --git a/hosts/omarchy/OmarchyPanel.qml b/hosts/omarchy/OmarchyPanel.qml
index 7c2d85d4..914dd301 100644
--- a/hosts/omarchy/OmarchyPanel.qml
+++ b/hosts/omarchy/OmarchyPanel.qml
@@ -1,6 +1,7 @@
pragma ComponentBehavior: Bound
import QtQuick
+import QtQuick.Window
import Quickshell
import Quickshell.Io
import qs.Commons
@@ -826,31 +827,67 @@ Panel {
onTriggered: root.showBarTooltip()
}
- BarIconButton {
+ // WidgetButton, not BarIconButton: the host fits the mark's width, which
+ // includes the side nodes, so its ring would draw smaller than round glyphs.
+ // Sizing the ring to the theme's icon size keeps it optically level.
+ WidgetButton {
id: button
anchors.fill: parent
bar: root.bar
- iconComponent: Component {
- Item {
- opacity: root.syncthing && root.syncthing.online ? 1.0 : 0.55
-
- // Keep the effect warm under the brand icon for reliable live switches.
- SharedWidgetMonoIcon {
- anchors.fill: parent
- source: root.themedIconSource
- tint: button.foreground
- }
+ labelVisible: false
+ hasVisualContent: true
+ fixedWidth: vertical ? -1 : Style.bar.iconSlot
+ fixedHeight: vertical ? Style.bar.iconSlot : -1
+
+ Item {
+ id: iconBox
+ // A raster drawn at fractional device pixels is resampled and blurs,
+ // so size and place it on whole pixels. Qt's Screen ratio is
+ // integral; the window carries the fractional one.
+ readonly property real dpr: Window.window ? Window.window.devicePixelRatio : 1
+ // The mono view box is 14.5 units; the ring spans 13.31 of them. The
+ // branded disc shares the box so both styles read the same size.
+ readonly property real logicalSize: Style.bar.iconSize * 14.5 / 13.31
+ property real snapX: 0
+ property real snapY: 0
+
+ function align() {
+ var p = button.mapToItem(null, (button.width - width) / 2, (button.height - height) / 2);
+ snapX = Math.round(p.x * dpr) / dpr - p.x;
+ snapY = Math.round(p.y * dpr) / dpr - p.y;
+ }
- Image {
- anchors.fill: parent
- source: root.syncthingIconSource
- sourceSize.width: width
- sourceSize.height: height
- fillMode: Image.PreserveAspectFit
- smooth: true
- visible: !root.themedIcon
+ width: Math.round(logicalSize * dpr) / dpr
+ height: width
+ x: (button.width - width) / 2 + snapX
+ y: (button.height - height) / 2 + snapY
+ scale: button.pressScale
+ opacity: root.syncthing && root.syncthing.online ? 1.0 : 0.55
+
+ // The bar moves widgets as neighbours resize; re-snap before each frame.
+ Connections {
+ target: iconBox.Window.window
+ function onAfterAnimating() {
+ iconBox.align();
}
}
+
+ // Keep the effect warm under the brand icon for reliable live switches.
+ SharedWidgetMonoIcon {
+ anchors.fill: parent
+ source: root.themedIconSource
+ tint: button.foreground
+ }
+
+ Image {
+ anchors.fill: parent
+ source: root.syncthingIconSource
+ sourceSize.width: width
+ sourceSize.height: height
+ fillMode: Image.PreserveAspectFit
+ smooth: true
+ visible: !root.themedIcon
+ }
}
active: root.hasProblems
tooltipText: ""
diff --git a/hosts/omarchy/ui/SharedDialogConfirm.qml b/hosts/omarchy/ui/SharedDialogConfirm.qml
index 74a65762..6306c264 100644
--- a/hosts/omarchy/ui/SharedDialogConfirm.qml
+++ b/hosts/omarchy/ui/SharedDialogConfirm.qml
@@ -10,6 +10,8 @@ Item {
property bool opened: false
property string message: ""
+ // StyledText callers must escape any user data they embed.
+ property int messageFormat: Text.PlainText
property string cancelText: "Cancel"
property string confirmText: "Confirm"
property int selectedIndex: 1
@@ -68,7 +70,7 @@ Item {
anchors.right: parent.right
anchors.top: parent.top
text: root.message
- textFormat: Text.PlainText
+ textFormat: root.messageFormat
color: root.foreground
font.family: root.fontFamily
font.pixelSize: Style.font.body
diff --git a/hosts/omarchy/ui/SyncshellPanelPopup.qml b/hosts/omarchy/ui/SyncshellPanelPopup.qml
index 2d0e32dd..a94ed263 100644
--- a/hosts/omarchy/ui/SyncshellPanelPopup.qml
+++ b/hosts/omarchy/ui/SyncshellPanelPopup.qml
@@ -35,6 +35,10 @@ KeyboardPanel {
return rows;
}
+ function escapeStyled(value) {
+ return String(value || "").replace(/&/g, "&").replace(//g, ">");
+ }
+
function resetKeyboardCursor() {
cursorActive = false;
cursorAction = null;
@@ -521,11 +525,12 @@ KeyboardPanel {
if (!folder)
return "Change this folder?";
if (root.controller.folderConfirmAction === "link")
- return "Link " + folder.label + " (" + folder.id + ")?\n\nSyncthing will resume synchronization for this folder.";
+ return "Link folder: " + root.escapeStyled(folder.label) + " (folder ID: " + root.escapeStyled(folder.id) + ")?
Syncthing will resume synchronization for this folder.";
if (root.controller.folderConfirmAction === "unlink")
- return "Unlink " + folder.label + " (" + folder.id + ")?\n\nSyncthing will pause synchronization. Its configuration " + "and local files remain.";
- return "Forget " + folder.label + " (" + folder.id + ")?\n\n" + "This removes only its Syncthing configuration. The " + "directory and data files will not be deleted. " + (folder.markerName === ".stfolder" ? "Syncthing will also attempt to remove its internal " + ".stfolder marker. " : "") + "Rejoining the same remote folder requires this exact " + "Folder ID.";
+ return "Unlink folder: " + root.escapeStyled(folder.label) + " (folder ID: " + root.escapeStyled(folder.id) + ")?
Syncthing will pause synchronization. Its configuration " + "and local files remain.";
+ return "Forget folder: " + root.escapeStyled(folder.label) + " (folder ID: " + root.escapeStyled(folder.id) + ")?
" + "This removes only its Syncthing configuration. The " + "directory and data files will not be deleted. " + (folder.markerName === ".stfolder" ? "Syncthing will also attempt to remove its internal " + ".stfolder marker. " : "") + "Rejoining the same remote folder requires this exact " + "Folder ID.";
}
+ messageFormat: ["link", "unlink", "forget"].indexOf(root.controller.folderConfirmAction) >= 0 ? Text.StyledText : Text.PlainText
confirmText: root.controller.folderConfirmAction === "create" ? "Create and add" : "Yes"
cancelText: root.controller.folderConfirmAction === "create" ? "Cancel" : "No"
background: Commons.Color.popups.background
diff --git a/packaging/bundled/SHA256SUMS b/packaging/bundled/SHA256SUMS
index a81fddad..71a7a018 100644
--- a/packaging/bundled/SHA256SUMS
+++ b/packaging/bundled/SHA256SUMS
@@ -1,3 +1,3 @@
314a89c32525c5b746f50a52b65967ed301e11f12bbbf5f3d44e387a10d540fc bin/syncshell-core
-583506f451c0d0b5d090b43e4e7a6a3a760e256b1342fe08bd88a37831b6c25e bin/x86_64/syncshell-core
-1b9b1efa912ed1b96420d5c2c6ab70bb6d4b194d5f0930d6916e6d23cf9edf02 bin/aarch64/syncshell-core
+2b441a4caa43466eef0153dfd4b47a5fb19c21909a6a1fed37ba614cd2bf49c0 bin/x86_64/syncshell-core
+15b98c1a07cbf67b7e634d117d698425dc89ba6d51f8663b31864eb3550bb4ce bin/aarch64/syncshell-core