DankMaterialShell icon indicating copy to clipboard operation
DankMaterialShell copied to clipboard

Clipboard: Saved tab shows stale History rows after scrolling (reuseItems + model switch)

Open hbrscte3 opened this issue 3 weeks ago • 2 comments

Compositor

Niri

Distribution

Arch Linux

Select your Installation Method

Distro Packaging (Arch Linux extra)

Was this your original Installation method?

Yes

dms doctor -vC

Click to expand
## DMS Doctor Report

**System**
- [ok] Operating System: Arch Linux
  - ID: arch, Version: rolling, Arch: amd64
- [ok] Architecture: amd64
- [ok] Display Server: Wayland
  - WAYLAND_DISPLAY=wayland-1

**Versions**
- [ok] DMS CLI: dms v2.1.1
  - /usr/bin/dms
- [ok] Quickshell: Quickshell 0.3.2 (revision , distributed by Arch Linux)
  - /usr/bin/qs
- [ok] DMS Shell: v2.1.1
  - /run/user/1000/dms-shell/012e92bf576c959e

**Installation**
- [ok] DMS Configuration: Found
  - /run/user/1000/dms-shell/012e92bf576c959e
- [ok] shell.qml: Present
  - /run/user/1000/dms-shell/012e92bf576c959e/shell.qml
- [info] Install Type: Unknown
  - /run/user/1000/dms-shell/012e92bf576c959e

**Compositor**
- [ok] Hyprland: 0.57.1
  - /usr/bin/hyprland
- [ok] niri: 26.04
  - /usr/bin/niri
- [info] Active: niri
- [ok] Background Blur: Supported
  - Compositor supports ext-background-effect-v1

**Quickshell Features**
- [ok] Polkit: Available
  - Authentication prompts
- [ok] IdleMonitor: Available
  - Idle detection
- [ok] IdleInhibitor: Available
  - Prevent idle/sleep
- [ok] ShortcutInhibitor: Available
  - Allow shortcut management (niri)
- [ok] BackgroundBlur: Available
  - Background blur API support in Quickshell

**Optional Features**
- [ok] accountsservice: Available
  - User accounts
- [ok] power-profiles-daemon: Available
  - Power profile management
- [ok] logind: Available
  - Session management
- [ok] cups-pk-helper: Available
  - Printer management
- [info] I2C/DDC: No monitors detected
  - External monitor brightness control
- [ok] qt6-imageformats: Installed (4 formats)
  - Formats: WebP, TIFF, GIF, ICNS (/usr/lib/qt6/plugins/imageformats:/usr/lib/qt/plugins/imageformats:/usr/lib64/qt6/plugins/imageformats)
- [ok] kimageformats: Installed (4 formats)
  - Formats: AVIF, HEIF, JXL, EXR (/usr/lib/qt6/plugins/imageformats:/usr/lib64/qt6/plugins/imageformats)
- [ok] Terminal: ghostty, kitty
- [ok] Network: NetworkManager
  - NetworkManager present. Using NM API.
- [ok] matugen: Installed
  - Dynamic theming
- [ok] cava: Installed
  - Audio visualizer
- [info] khal: Not installed
  - Calendar events
- [info] dux-search: Not installed
  - File search
- [info] dux-calendar: Not installed
  - Calendar app
- [info] dux-files: Not installed
  - File manager
- [info] fprintd: Not installed
  - Fingerprint auth
- [ok] adw-gtk3: Installed
  - GTK3 dynamic theming (system copy, applied on next theme apply)

**Config Files**
- [ok] settings.json: Present
  - /home/<user>/.config/dms/settings.json
- [info] clsettings.json: Not yet created
  - /home/<user>/.config/dms/clsettings.json
- [ok] plugin_settings.json: Present
  - /home/<user>/.config/dms/plugin_settings.json
- [ok] session.json: Present
  - /home/<user>/.local/state/dms/session.json
- [ok] dms-colors.json: Present
  - /home/<user>/.cache/dms/dms-colors.json

**Services**
- [ok] dms.service: enabled, active
- [ok] greetd: enabled
- [ok] xdg-desktop-portal: Settings portal reachable

**Environment**
- [info] QT_QPA_PLATFORMTHEME: qt5ct
- [ok] qt5ct plugin (Qt5): Installed
  - /usr/lib/qt/plugins/platformthemes/libqt5ct.so
- [info] QT_QPA_PLATFORMTHEME_QT6: Not set, Qt6 uses QT_QPA_PLATFORMTHEME
- [info] QS_ICON_THEME: Not set
- [info] XDG_MENU_PREFIX: Not set

**Fonts**
- [ok] Normal Font: IBM Plex Sans
  - Available via fontconfig
- [ok] Monospace Font: Fira Code
  - /run/user/1000/dms-shell/012e92bf576c959e/DCommon/assets/fonts/nerd-fonts/FiraCodeNerdFont-Regular.ttf
- [ok] Display Font: DM Serif Display
  - /run/user/1000/dms-shell/012e92bf576c959e/DCommon/assets/fonts/dm-serif-display/DMSerifDisplay-Regular.ttf

---
**Summary:** 0 error(s), 0 warning(s), 38 ok

Description

The Saved tab can display entries from the History/Recents list instead of the pinned entries. The header count is still correct and the pinned entries are not lost, so this is a UI/model-rebinding problem rather than data loss.

Reproduced on a freshly restarted shell with 2 pinned entries and 102 history entries:

  1. Open the clipboard.
  2. Stay on History/Recents and scroll down about 20 entries.
  3. Press Ctrl+Tab to switch to Saved (clicking the pin button does the same).
  4. The header says Clipboard Saved (2), but the two rows show unrelated History entries. In my capture they were a forum BBCode snippet and a line containing only [.
  5. Switch back to History and then to Saved again. The Saved tab keeps showing stale History rows.
  6. Close and reopen the clipboard. The stale rows are still there.
  7. systemctl --user restart dms.service fixes it: Saved then shows the two real pinned entries. The glitch returns after scrolling History and switching tabs again.

This is not only cosmetic. The copy, paste, delete, edit and context-menu handlers all use modelData (ClipboardContent.qml lines 294-309), so acting on a stale row targets the History entry that is still bound to the reused delegate, not the pinned entry.

I also checked v2.1.2 (released 2026-11-08): quickshell/Modals/Clipboard/ClipboardContent.qml is byte-for-byte identical to v2.1.1, so the latest release is affected too. The live reproduction above was on v2.1.1.

Expected Behavior

The Saved tab lists the pinned entries regardless of where the History tab was scrolled before switching.

Steps to Reproduce

  1. Have at least 2 pinned clipboard entries and enough history entries to scroll (I had 2 pins and 102 history entries).
  2. Open the clipboard modal.
  3. On the History/Recents tab, scroll down roughly 20 entries with the mouse wheel, or press Ctrl+J about 20 times.
  4. Press Ctrl+Tab (or click the pin button) to switch to Saved.
  5. Compare the rows under Clipboard Saved (N) with the actual pinned entries. The count matches, but the rows show History entries.
  6. Restart the shell (systemctl --user restart dms.service) and open Saved again. The correct pinned rows return until the next scroll + tab switch.

Error Messages/Logs

No clipboard-related errors or warnings appear in journalctl --user -u dms.service at the time. The only nearby warnings are unrelated qt.qpa.wayland.textinput focus messages.

Screenshots/Recordings

I can attach a recording or screenshot, but it would expose private clipboard contents. The visible mismatch is Clipboard Saved (2) with two unrelated History rows beneath it. I am happy to provide a redacted capture if that helps.

Root cause / analysis

The list uses delegate recycling and swaps between two models:

  • quickshell/Modals/Clipboard/ClipboardContent.qml:235 — reuseItems: true
  • quickshell/Modals/Clipboard/ClipboardContent.qml:239 — model: ... activeTab === "saved" ? savedModel : recentsModel
  • quickshell/Modals/Clipboard/ClipboardContent.qml:283-289 — the delegate binds entry: modelData
  • quickshell/Modals/Clipboard/ClipboardHeader.qml:22 — the header count reads pinnedEntries.length directly

After the History list has been scrolled, Qt Quick has delegates in its reuse pool. When the model switches to savedModel, those delegates are reused but their model data is not rebound: index changes to 0/1, while modelData still points at the old History entries. The delegate therefore paints the old entry, and its actions operate on it. The header is correct because it does not go through the delegate/model binding.

I reproduced this outside Dux with stock Qt Quick 6.12.0, no Quickshell or Dux code involved, which suggests an upstream Qt Quick reuseItems regression. However, Dux ships the affected QML and can work around it.

Minimal Qt Quick reproduction (qml6)
import QtQuick
import QtQuick.Window

Window {
    width: 400
    height: 300
    visible: true

    ListModel {
        id: history
        Component.onCompleted: {
            for (let i = 0; i < 100; i++)
                append({ name: "H" + i });
        }
    }

    ListModel {
        id: saved
        Component.onCompleted: {
            append({ name: "S0" });
            append({ name: "S1" });
        }
    }

    ListView {
        id: view
        anchors.fill: parent
        reuseItems: true
        model: history
        delegate: Text {
            required property string name
            required property int index
            width: view.width
            height: 40
            text: name + " (idx " + index + ")"
        }
    }

    Timer {
        interval: 400
        running: true
        onTriggered: {
            view.contentY = 800;
            switchTimer.start();
        }
    }

    Timer {
        id: switchTimer
        interval: 400
        onTriggered: {
            view.model = saved;
            dumpTimer.start();
        }
    }

    Timer {
        id: dumpTimer
        interval: 100
        onTriggered: {
            console.error("0:", view.itemAtIndex(0)?.text);
            console.error("1:", view.itemAtIndex(1)?.text);
            Qt.quit();
        }
    }
}

Result with reuseItems: true:

0: H1 (idx 0)
1: H2 (idx 1)

Result with reuseItems: false:

0: S0 (idx 0)
1: S1 (idx 1)

Verified workaround

Setting reuseItems = false immediately before the model switch, then restoring it on the next event-loop turn, makes the Saved tab render the correct rows in the reproduction above. Keeping reuseItems: false permanently also fixes it. A possible minimal change in ClipboardContent.qml would be to disable reuse while changing tabs, for example:

clipboardListView.reuseItems = false;
// let the tab/model binding update
Qt.callLater(() => clipboardListView.reuseItems = true);

I have not tested that exact patch in the live shell, only the equivalent behavior in the minimal reproduction.

Related reports

I searched the existing clipboard issues and PRs and did not find a report for this exact symptom. The closest older reports are about pinned entries and wrong copied items (#1634, #2474), but those were fixed earlier and describe a different keyboard-selection path. This looks like a separate delegate-reuse issue: reuseItems: true is absent in v1.6.3 and first appears in v2.0.0, so the 2.x series is affected.

hbrscte3 avatar Nov 10 '26 13:11 hbrscte3

I'd like to take this one, could one of you assign me? @bbedward @purian23 I'd stop the delegates from carrying the old entry over when the list switches between History and Saved, so the rows and their actions always match the pinned entries.

Mario-Mohar avatar Nov 12 '26 18:11 Mario-Mohar

Thanks @Mario-Mohar !

purian23 avatar Nov 12 '26 18:11 purian23