Commit 3abee77b20ea

Vincent Demeester <vincent@sbr.pm>
2026-10-21 13:54:36
fix(raffi): target collapsed Herdr agents
Preserved agent pane identities in collapsed workspace rows so previewing and secondary message actions address the selected agent instead of its tab. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 2f38780
Changed files (3)
dots/config/raffi/scripts/herdr/herdr_filter.py
@@ -216,13 +216,16 @@ def tab_item(tab, panes):
     occupants = ", ".join(
         text_field(pane, "agent") or "shell" for pane in panes
     ) or "empty"
+    kind, focus = "tab", tab_id
+    if len(panes) == 1 and text_field(panes[0], "agent"):
+        kind, focus = "agent", text_field(panes[0], "pane_id")
     return {
         "title": f"{label} {status_span(status)}",
         "subtitle": focused_prefix(tab) + occupants,
-        "arg": tab_id,
+        "arg": focus,
         "indent": 1,
         "icon": {"path": tab_icon(panes)},
-        "variables": {KIND_VARIABLE: "tab", FOCUS_VARIABLE: tab_id},
+        "variables": {KIND_VARIABLE: kind, FOCUS_VARIABLE: focus},
     }
 
 
dots/config/raffi/scripts/herdr/test_herdr_filter.py
@@ -169,7 +169,7 @@ class HerdrFilterTests(unittest.TestCase):
                 ("w1:p2", 2),
                 ("w1:t2", 1),
                 ("w2", 0),
-                ("w2:t9", 1),
+                ("w2:p9", 1),
             ],
         )
         self.assertEqual(items[0]["title"], "alpha \x1b[32m[working]\x1b[0m")
@@ -200,7 +200,7 @@ class HerdrFilterTests(unittest.TestCase):
             items["w1:t2"]["variables"], {"HERDR_KIND": "tab", "HERDR_FOCUS": "w1:t2"}
         )
         self.assertEqual(
-            items["w2:t9"]["variables"], {"HERDR_KIND": "tab", "HERDR_FOCUS": "w2:t9"}
+            items["w2:p9"]["variables"], {"HERDR_KIND": "agent", "HERDR_FOCUS": "w2:p9"}
         )
 
     def test_tree_query_keeps_ancestors_and_prunes_siblings(self):
@@ -212,7 +212,7 @@ class HerdrFilterTests(unittest.TestCase):
         items = tree_items("beta")
 
         self.assertEqual(
-            [item["arg"] for item in items], ["w2", "w2:t9"]
+            [item["arg"] for item in items], ["w2", "w2:p9"]
         )
 
     def test_tree_query_matching_single_pane_tab_keeps_only_tab(self):
@@ -224,8 +224,8 @@ class HerdrFilterTests(unittest.TestCase):
 
     def test_single_pane_details_still_match_the_tab(self):
         cases = {
-            "codex": ["w2", "w2:t9"],
-            "/home/user/project-d": ["w2", "w2:t9"],
+            "codex": ["w2", "w2:p9"],
+            "/home/user/project-d": ["w2", "w2:p9"],
             "shell": ["w1", "w1:t2"],
             "project-c": ["w1", "w1:t2"],
             "chmouel@host": ["w1", "w1:t2"],
@@ -242,7 +242,7 @@ class HerdrFilterTests(unittest.TestCase):
         )
         self.assertEqual(
             [item["arg"] for item in items],
-            ["w1", "w1:t1", "w1:p2", "w2", "w2:t9"],
+            ["w1", "w1:t1", "w1:p2", "w2", "w2:p9"],
         )
 
     def test_multi_pane_tab_keeps_shell_children_and_tab_matches_keep_all(self):
@@ -269,7 +269,7 @@ class HerdrFilterTests(unittest.TestCase):
         )
         self.assertEqual(
             [item["arg"] for item in items],
-            ["w1", "w1:t1", "w1:p1", "w1:p2", "w1:t2", "w2", "w2:t9"],
+            ["w1", "w1:t1", "w1:p1", "w1:p2", "w1:t2", "w2", "w2:p9"],
         )
         self.assertEqual(items[4]["subtitle"], "empty")
 
@@ -386,7 +386,7 @@ class HerdrIconTests(unittest.TestCase):
                     "w1:p1": "agent-claude.svg",
                     "w1:p2": "agent-pi.svg",
                     "w1:t2": "shell.svg",
-                    "w2:t9": "agent-codex.svg",
+                    "w2:p9": "agent-codex.svg",
                 }
                 for item_id, name in expected.items():
                     self.assertEqual(
@@ -684,7 +684,7 @@ class HerdrPreviewTests(unittest.TestCase):
                 patch.object(herdr_filter, "run_herdr", side_effect=self.fake_herdr),
             ):
                 items = {item["arg"]: item for item in tree_items()}
-                for item_id in ("w1", "w1:t1", "w1:t2", "w2:t9", "w1:p1"):
+                for item_id in ("w1", "w1:t1", "w1:t2", "w2:p9", "w1:p1"):
                     self.assertEqual(
                         herdr_filter.build_preview(item_id, "400")["icon"],
                         items[item_id]["icon"]["path"],
dots/config/raffi/raffi.yaml
@@ -76,14 +76,10 @@ addons:
         agent) herdr agent focus "$HERDR_FOCUS" ;;
         *) herdr tab focus "$HERDR_FOCUS" ;;
       esac
-  - name: Message Herdr Agent
-    keyword: hrmsg
-    command: ~/.config/raffi/scripts/herdr-raffi
-    args:
-    - --message
-    icon: utilities-terminal
-    action: ~/.config/raffi/scripts/herdr-raffi action message {value}
-    dynamic_preview: true
+    secondary_action: >-
+      case "$HERDR_KIND" in
+        agent) ~/.config/raffi/scripts/herdr-raffi action message "$HERDR_FOCUS" ;;
+      esac
   - name: Open in Emacs
     keyword: ed
     command: ~/.config/raffi/scripts/emacs-recentf-raffi