Skip to content

Commit bd4bd1b

Browse files
committed
fix: Improve window selection from list view on Windows
1 parent 83f8db8 commit bd4bd1b

3 files changed

Lines changed: 50 additions & 10 deletions

File tree

.claude/settings.local.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(pnpm typecheck:*)",
5+
"Bash(pnpm lint:*)",
6+
"Bash(pnpm build:*)"
7+
],
8+
"deny": [],
9+
"ask": []
10+
}
11+
}

apps/desktop/src/routes/(window-chrome)/new-main/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,11 @@ function Page() {
368368
"captureTarget",
369369
reconcile({ variant: "window", id: target.id }),
370370
);
371+
setOptions("targetMode", "window");
371372
setWindowMenuOpen(false);
372373
windowTriggerRef?.focus();
373374

374375
await commands.focusWindow(target.id);
375-
376-
await new Promise((resolve) => setTimeout(resolve, 100));
377-
setOptions("targetMode", "window");
378376
};
379377

380378
createEffect(() => {

apps/desktop/src/routes/target-select-overlay.tsx

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,46 @@ function Inner() {
6464
});
6565
onCleanup(() => unsubTargetUnderCursor.then((unsub) => unsub()));
6666

67+
const selectedWindow = createQuery(() => ({
68+
queryKey: ["selectedWindow", rawOptions.captureTarget],
69+
queryFn: async () => {
70+
if (rawOptions.captureTarget.variant !== "window") return null;
71+
const windowId = rawOptions.captureTarget.id;
72+
73+
const windows = await commands.listCaptureWindows();
74+
const window = windows.find(w => w.id === windowId);
75+
76+
if (!window) return null;
77+
78+
return {
79+
id: window.id,
80+
app_name: window.owner_name || window.name || "Unknown",
81+
bounds: window.bounds,
82+
};
83+
},
84+
enabled: rawOptions.captureTarget.variant === "window" && rawOptions.targetMode === "window",
85+
staleTime: 5 * 1000,
86+
}));
87+
88+
const windowToShow = () => {
89+
if (rawOptions.captureTarget.variant === "window" && selectedWindow.data) {
90+
return selectedWindow.data;
91+
}
92+
// Otherwise use what's under the cursor
93+
return targetUnderCursor.window;
94+
};
95+
6796
const windowIcon = createQuery(() => ({
68-
queryKey: ["windowIcon", targetUnderCursor.window?.id],
97+
queryKey: ["windowIcon", windowToShow()?.id],
6998
queryFn: async () => {
70-
if (!targetUnderCursor.window?.id) return null;
99+
const window = windowToShow();
100+
if (!window?.id) return null;
71101
return await commands.getWindowIcon(
72-
targetUnderCursor.window.id.toString(),
102+
window.id.toString(),
73103
);
74104
},
75-
enabled: !!targetUnderCursor.window?.id,
76-
staleTime: 5 * 60 * 1000, // Cache for 5 minutes
105+
enabled: !!windowToShow()?.id,
106+
staleTime: 5 * 60 * 1000,
77107
}));
78108

79109
const displayInformation = createQuery(() => ({
@@ -184,10 +214,11 @@ function Inner() {
184214
<Match
185215
when={
186216
rawOptions.targetMode === "window" &&
187-
targetUnderCursor.display_id === params.displayId
217+
(targetUnderCursor.display_id === params.displayId ||
218+
(rawOptions.captureTarget.variant === "window" && selectedWindow.data))
188219
}
189220
>
190-
<Show when={targetUnderCursor.window} keyed>
221+
<Show when={windowToShow()} keyed>
191222
{(windowUnderCursor) => (
192223
<div
193224
data-over={targetUnderCursor.display_id === params.displayId}

0 commit comments

Comments
 (0)