Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(appshot): keep a pinned card on screen after it is dragged into an app

rubenluetke10-beep2dffc035513c
diff --git a/jarvis/cu/indicator/renderer.py b/jarvis/cu/indicator/renderer.py
index e2b41ad37c..2bc35e4665 100644
--- a/jarvis/cu/indicator/renderer.py
+++ b/jarvis/cu/indicator/renderer.py
@@ -903,8 +903,9 @@ class _CardWindow(QWidget):
self.setWindowOpacity(0.35)
result = drag.exec(Qt.DropAction.CopyAction)
self.setWindowOpacity(1.0)
- if result == Qt.DropAction.IgnoreAction:
- # Dropped nowhere (or Esc): the card stays.
+ if result == Qt.DropAction.IgnoreAction or self._pinned:
+ # Dropped nowhere (or Esc), or pinned: the card stays. A pinned
+ # card leaves only through its own Close.
self._hover = False
self._hot = ""
self._arm_dismiss(_CARD_AFTER_HOVER_MS)
diff --git a/tests/unit/cu/indicator/test_card_drag_image.py b/tests/unit/cu/indicator/test_card_drag_image.py
index 518650402e..7ce947b517 100644
--- a/tests/unit/cu/indicator/test_card_drag_image.py
+++ b/tests/unit/cu/indicator/test_card_drag_image.py
@@ -77,3 +77,70 @@ def test_copy_cursor_draws_the_green_badge(qt) -> None:
assert (badge.red(), badge.green(), badge.blue()) == (52, 199, 89)
tip = image.pixelColor(2, 4) # inside the white arrow, by its tip
assert tip.alpha() > 0
+
+
+class _DropOwner:
+ """Just enough of the renderer for a card drag: where the drag file goes."""
+
+ def __init__(self, path) -> None:
+ self._path = path
+
+ def write_drag_file(self, _image):
+ return self._path
+
+ def card_gone(self, _card) -> None:
+ pass
+
+
+def _fake_drag(result):
+ class _Drag:
+ def __init__(self, _source) -> None:
+ pass
+
+ def setMimeData(self, _mime) -> None: # noqa: N802 - Qt name
+ pass
+
+ def setPixmap(self, _pixmap) -> None: # noqa: N802 - Qt name
+ pass
+
+ def setHotSpot(self, _hot) -> None: # noqa: N802 - Qt name
+ pass
+
+ def setDragCursor(self, _cursor, _action) -> None: # noqa: N802 - Qt name
+ pass
+
+ def exec(self, _action):
+ return result
+
+ return _Drag
+
+
+def _dropped_card(qt, monkeypatch, tmp_path, *, pinned: bool):
+ from PySide6.QtCore import QPointF, QRectF, Qt # noqa: PLC0415
+
+ monkeypatch.setattr(qt, "QDrag", _fake_drag(Qt.DropAction.CopyAction))
+ path = tmp_path / "appshot.png"
+ path.write_bytes(b"")
+ card = qt._CardWindow(
+ QRectF(0, 0, 320, 200),
+ _thumb(320, 200),
+ "",
+ _DropOwner(path),
+ image=_thumb(320, 200),
+ )
+ card._pinned = pinned
+ card._start_drag(QPointF(100, 100))
+ return card
+
+
+def test_dropped_card_leaves(qt, monkeypatch, tmp_path) -> None:
+ card = _dropped_card(qt, monkeypatch, tmp_path, pinned=False)
+ assert card.leaving
+ card.finish_now()
+
+
+def test_pinned_card_stays_after_a_drop(qt, monkeypatch, tmp_path) -> None:
+ card = _dropped_card(qt, monkeypatch, tmp_path, pinned=True)
+ assert not card.leaving
+ assert not card._dismiss.isActive()
+ card.finish_now()