Send the current tab to the main window in Glide
Replaces the Hammerspoon little-ff rehome workaround, which reopened the URL (losing scroll and history) and couldn't focus the target window.

Assisted-by: Claude Opus 4.8 via Claude Code
change lzpxkkowvspplxysxnlpztrtxzvomwpv
commit ea95484221babf8fc2064eb3a2b2cf739ce9f396
author Alpha Chen <alpha@kejadlen.dev>
date
parent ponqkwwn
diff --git a/.config/glide/glide.ts b/.config/glide/glide.ts
index 6d1f124e..a1eac6bf 100644
--- a/.config/glide/glide.ts
+++ b/.config/glide/glide.ts
@@ -248,6 +248,31 @@ glide.excmds.create(
   },
 );
 
+// mash+o (cmd+ctrl+alt+o): send the current tab to the "main" window — the
+// normal window with the most tabs — and drop it at the end of that strip.
+glide.keymaps.set("normal", "<C-A-D-o>", async ({ tab_id }) => {
+  const windows = await browser.windows.getAll({
+    populate: true,
+    windowTypes: ["normal"],
+  });
+  const mainWindow = windows.reduce((best, win) =>
+    (win.tabs?.length ?? 0) > (best.tabs?.length ?? 0) ? win : best
+  );
+  if (mainWindow.id == null) return;
+
+  // Glide's cross-window mutation promises never settle, so we can't await
+  // tabs.move. Fire it and wait for the tab to attach to the main window —
+  // Glide brings that window to the front as it lands, making it the current
+  // window, so activating the tab there (a same-window update) works.
+  const onAttached = (attachedId: number, info: { newWindowId: number }) => {
+    if (attachedId !== tab_id || info.newWindowId !== mainWindow.id) return;
+    browser.tabs.onAttached.removeListener(onAttached);
+    browser.tabs.update(tab_id, { active: true });
+  };
+  browser.tabs.onAttached.addListener(onAttached);
+  browser.tabs.move(tab_id, { windowId: mainWindow.id, index: -1 });
+});
+
 glide.keymaps.set("normal", "ZZ", async () => {
   await stashTabs();
   await glide.excmds.execute("quit");
diff --git a/.hammerspoon/little-ff.fnl b/.hammerspoon/little-ff.fnl
index a2de03e4..0db66892 100644
--- a/.hammerspoon/little-ff.fnl
+++ b/.hammerspoon/little-ff.fnl
@@ -1,4 +1,4 @@
-(local {: run : with-ax-hotfix} (require :utils))
+(local {: with-ax-hotfix} (require :utils))
 
 (local log (hs.logger.new :little-ff :info))
 
@@ -41,28 +41,4 @@
     (hs.execute cmd)
     (wait-for-little-ff resize-little-ff)))
 
-(λ rehome []
-  (let [win (is-ff-focused)
-        num-windows (-?> win
-                         (: :application)
-                         (: :allWindows)
-                         (length))]
-    (when (and num-windows (< 1 num-windows))
-      (hs.eventtap.keyStroke [] :escape)
-      (hs.eventtap.keyStrokes :yy)
-      (hs.pasteboard.callbackWhenChanged #(do
-                                            (win:close)
-                                            (run (table.concat [:open
-                                                                :-a
-                                                                (.. "\""
-                                                                    browser.name
-                                                                    "\"")
-                                                                (hs.pasteboard.readString)]
-                                                               " "))
-                                            ;; TODO figure out how to focus the main
-                                            ;; ff window - aerospace doesn't seem to
-                                            ;; handle the programmatic closing of the
-                                            ;; little ff window all that well
-                                            )))))
-
-{: open : rehome : is-ff-focused}
+{: open : is-ff-focused}