Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 28 additions & 20 deletions apps/desktop/src/components/ModeSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { cx } from "cva";
import type { JSX } from "solid-js";
import { type JSX, Show } from "solid-js";
import { createOptionsQuery } from "~/utils/queries";
import type { RecordingMode } from "~/utils/tauri";

interface ModeOptionProps {
mode: RecordingMode;
title: string;
description: string;
icon: (props: { class: string; style: JSX.CSSProperties }) => JSX.Element;
standalone?: boolean;
icon: (props: { class: string; style?: JSX.CSSProperties }) => JSX.Element;
isSelected: boolean;
onSelect: (mode: RecordingMode) => void;
}
Expand All @@ -17,26 +18,12 @@ const ModeOption = (props: ModeOptionProps) => {
<div
onClick={() => props.onSelect(props.mode)}
class={cx(
`p-4 space-y-3 rounded-lg bg-gray-2 transition-all duration-200`,
{
"ring-2 ring-offset-2 hover:bg-gray-2 cursor-default ring-blue-9 ring-offset-gray-100":
props.isSelected,
"ring-2 ring-transparent ring-offset-transparent hover:bg-gray-3 cursor-pointer":
!props.isSelected,
},
`p-5 space-y-3 rounded-lg border transition-all duration-200 border-gray-4 dark:border-gray-3 h-fit bg-gray-3 dark:bg-gray-2`,
)}
>
<div class="flex flex-col items-center mb-2 text-center">
{props.icon({
class: cx(
"size-12 mb-3",
props.isSelected ? "opacity-100" : "opacity-30",
),
style: {
filter: props.isSelected
? "drop-shadow(0 0 0.5rem rgba(255, 255, 255, 0.5))"
: "none",
},
class: "size-12 mb-5 invert dark:invert-0",
})}
Comment on lines 20 to 27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Selected state no longer reflected; either style it or remove isSelected.
UX regression: current card styles don’t indicate selection. Add a selected style or drop the prop.

-      class={cx(
-        `p-5 space-y-3 rounded-lg border transition-all duration-200 border-gray-4 dark:border-gray-3 h-fit bg-gray-3 dark:bg-gray-2`,
-      )}
+      data-selected={props.isSelected ? "true" : "false"}
+      class={cx(
+        "p-5 space-y-3 rounded-lg border transition-all duration-200 h-fit bg-gray-3 dark:bg-gray-2",
+        "border-gray-4 dark:border-gray-3 ring-1 ring-transparent",
+        // highlight when selected
+        props.isSelected && "border-blue-8 ring-blue-7"
+      )}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
class={cx(
`p-4 space-y-3 rounded-lg bg-gray-2 transition-all duration-200`,
{
"ring-2 ring-offset-2 hover:bg-gray-2 cursor-default ring-blue-9 ring-offset-gray-100":
props.isSelected,
"ring-2 ring-transparent ring-offset-transparent hover:bg-gray-3 cursor-pointer":
!props.isSelected,
},
`p-5 space-y-3 rounded-lg border transition-all duration-200 border-gray-4 dark:border-gray-3 h-fit bg-gray-3 dark:bg-gray-2`,
)}
>
<div class="flex flex-col items-center mb-2 text-center">
{props.icon({
class: cx(
"size-12 mb-3",
props.isSelected ? "opacity-100" : "opacity-30",
),
style: {
filter: props.isSelected
? "drop-shadow(0 0 0.5rem rgba(255, 255, 255, 0.5))"
: "none",
},
class: "size-12 mb-5 invert dark:invert-0",
})}
<div
// reflect selection state for styling/testing
data-selected={props.isSelected ? "true" : "false"}
class={cx(
"p-5 space-y-3 rounded-lg border transition-all duration-200 h-fit bg-gray-3 dark:bg-gray-2",
"border-gray-4 dark:border-gray-3 ring-1 ring-transparent",
// highlight when selected
props.isSelected && "border-blue-8 ring-blue-7"
)}
>
<div class="flex flex-col items-center mb-2 text-center">
{props.icon({
class: "size-12 mb-5 invert dark:invert-0",
})}
🤖 Prompt for AI Agents
In apps/desktop/src/components/ModeSelect.tsx around lines 20 to 27, the card no
longer visually reflects the selection state; either apply a selected style when
props.isSelected is true or remove the isSelected prop usage. Update the
className construction (using cx) to conditionally include a "selected" set of
classes (e.g., stronger border color, background highlight, ring or shadow) when
props.isSelected is true, ensuring you reference props.isSelected and keep
existing classes otherwise; if selection state is truly unused, remove the
isSelected prop and any conditional logic that expects it. Ensure the
conditional uses the same cx helper pattern as the surrounding code and that
styles work in both light and dark modes.

<h3 class="text-lg font-medium text-gray-12">{props.title}</h3>
</div>
Expand All @@ -48,7 +35,7 @@ const ModeOption = (props: ModeOptionProps) => {
);
};

const ModeSelect = () => {
const ModeSelect = (props: { onClose?: () => void; standalone?: boolean }) => {
const { rawOptions, setOptions } = createOptionsQuery();

const handleModeChange = (mode: RecordingMode) => {
Expand All @@ -73,7 +60,28 @@ const ModeSelect = () => {
];

return (
<div class="grid grid-cols-2 gap-8 text-center">
<div
class={cx(
"grid grid-cols-2 gap-8 items-center text-center bg-gray-1",
props.standalone
? "absolute z-10 border border-gray-3 p-16 rounded-xl"
: "",
)}
onClick={(e) => e.stopPropagation()}
>
Comment on lines +63 to +71
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Center and label the overlay (dialog semantics).
Absolute without offsets may not center; also add a11y attributes.

-    <div
-      class={cx(
-        "grid grid-cols-2 gap-8 items-center text-center bg-gray-1",
-        props.standalone
-          ? "absolute z-10 border border-gray-3 p-16 rounded-xl"
-          : "",
-      )}
-      onClick={(e) => e.stopPropagation()}
-    >
+    <div
+      role={props.standalone ? "dialog" : undefined}
+      aria-modal={props.standalone ? "true" : undefined}
+      aria-labelledby={props.standalone ? "mode-select-title" : undefined}
+      class={cx(
+        "grid grid-cols-2 gap-8 items-center text-center bg-gray-1",
+        props.standalone
+          ? "fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 z-20 border border-gray-3 p-16 rounded-xl shadow-2xl"
+          : ""
+      )}
+      onClick={(e) => e.stopPropagation()}
+    >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div
class={cx(
"grid grid-cols-2 gap-8 items-center text-center bg-gray-1",
props.standalone
? "absolute z-10 border border-gray-3 p-16 rounded-xl"
: "",
)}
onClick={(e) => e.stopPropagation()}
>
<div
role={props.standalone ? "dialog" : undefined}
aria-modal={props.standalone ? "true" : undefined}
aria-labelledby={props.standalone ? "mode-select-title" : undefined}
class={cx(
"grid grid-cols-2 gap-8 items-center text-center bg-gray-1",
props.standalone
? "fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 z-20 border border-gray-3 p-16 rounded-xl shadow-2xl"
: ""
)}
onClick={(e) => e.stopPropagation()}
>
🤖 Prompt for AI Agents
In apps/desktop/src/components/ModeSelect.tsx around lines 63 to 71, the overlay
uses absolute positioning without offsets and lacks dialog semantics; update the
standalone class to center the overlay (e.g., apply utility offsets/transform
such as top-1/2 left-1/2 and -translate-x-1/2 -translate-y-1/2 or equivalent
centering classes) and add proper accessibility attributes by giving the
container role="dialog", aria-modal="true" and either aria-labelledby pointing
to a visible heading id inside the overlay or an aria-label describing the
dialog; keep the existing onClick stopPropagation behavior.

<Show when={props.onClose}>
<div
onClick={() => props.onClose?.()}
class="absolute -top-2.5 -right-2.5 p-2 rounded-full border duration-200 bg-gray-2 border-gray-3 hover:bg-gray-3 transition-duration"
>
<IconCapX class="invert-1 size-2 dark:invert" />
</div>
</Show>
Comment on lines +72 to +79
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use a button for the close control and fix Tailwind classes.
Divs aren’t keyboard-accessible; also transition-duration isn’t a Tailwind class and invert-1 is invalid.

-      <Show when={props.onClose}>
-        <div
-          onClick={() => props.onClose?.()}
-          class="absolute -top-2.5 -right-2.5 p-2 rounded-full border duration-200 bg-gray-2 border-gray-3 hover:bg-gray-3 transition-duration"
-        >
-          <IconCapX class="invert-1 size-2 dark:invert" />
-        </div>
-      </Show>
+      <Show when={props.onClose}>
+        <button
+          type="button"
+          aria-label="Close"
+          onClick={() => props.onClose?.()}
+          class="absolute -top-2.5 -right-2.5 p-2 rounded-full border bg-gray-2 border-gray-3 hover:bg-gray-3 transition-colors duration-200"
+        >
+          <IconCapX class="invert size-2 dark:invert-0" />
+        </button>
+      </Show>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Show when={props.onClose}>
<div
onClick={() => props.onClose?.()}
class="absolute -top-2.5 -right-2.5 p-2 rounded-full border duration-200 bg-gray-2 border-gray-3 hover:bg-gray-3 transition-duration"
>
<IconCapX class="invert-1 size-2 dark:invert" />
</div>
</Show>
<Show when={props.onClose}>
<button
type="button"
aria-label="Close"
onClick={() => props.onClose?.()}
class="absolute -top-2.5 -right-2.5 p-2 rounded-full border bg-gray-2 border-gray-3 hover:bg-gray-3 transition-colors duration-200"
>
<IconCapX class="invert size-2 dark:invert-0" />
</button>
</Show>
🤖 Prompt for AI Agents
In apps/desktop/src/components/ModeSelect.tsx around lines 72 to 79, replace the
interactive div with a semantic button to make the close control
keyboard-accessible (use type="button"), add an aria-label (e.g., "Close"), and
keep calling props.onClose() on click; remove any custom key handlers since
button handles Enter/Space. Fix the Tailwind utility class names by replacing
transition-duration with transition and invert-1 with invert (or remove invert
if not needed), preserve layout classes (absolute -top-2.5 -right-2.5 p-2
rounded-full border bg-gray-2 border-gray-3 hover:bg-gray-3) and add
focus-visible ring/focus:outline-none utilities so the button shows focus when
tabbed. Ensure IconCapX class usage remains but update any invalid size class if
necessary.

{props.standalone && (
<h2 class="text-[24px] col-span-2 font-medium text-center text-gray-12">
Recording Modes
</h2>
)}
{modeOptions.map((option) => (
<ModeOption
mode={option.mode}
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/routes/mode-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const ModeSelectWindow = () => {
>
<div class="relative z-10 space-y-10 w-full max-w-3xl">
<h2 class="text-[24px] font-medium text-center text-gray-12">
Select your recording mode
Recording Modes
</h2>
<ModeSelect />
</div>
Expand Down
144 changes: 88 additions & 56 deletions apps/desktop/src/routes/target-select-overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
Switch,
} from "solid-js";
import { createStore, reconcile } from "solid-js/store";
import ModeSelect from "~/components/ModeSelect";
import { authStore, generalSettingsStore } from "~/store";
import { createOptionsQuery } from "~/utils/queries";
import {
Expand All @@ -31,9 +32,14 @@ import {
type TargetUnderCursor,
} from "~/utils/tauri";

const capitalize = (str: string) => {
return str.charAt(0).toUpperCase() + str.slice(1);
};

export default function () {
const [params] = useSearchParams<{ displayId: DisplayId }>();
const { rawOptions, setOptions } = createOptionsQuery();
const [toggleModeSelect, setToggleModeSelect] = createSignal(false);

const [targetUnderCursor, setTargetUnderCursor] =
createStore<TargetUnderCursor>({
Expand Down Expand Up @@ -125,15 +131,16 @@ export default function () {
class="relative w-screen h-screen flex flex-col items-center justify-center data-[over='true']:bg-blue-600/40 transition-colors"
>
<div class="absolute inset-0 bg-black/50 -z-10" />

<Show when={displayInformation.data} keyed>
{(display) => (
<>
<span class="text-3xl font-semibold mb-2 text-white">
<span class="mb-2 text-3xl font-semibold text-white">
{display.name || "Monitor"}
</span>
<Show when={display.physical_size}>
{(size) => (
<span class="text-xs mb-2 text-white">
<span class="mb-2 text-xs text-white">
{`${size().width}x${size().height} · ${display.refresh_rate}FPS`}
</span>
)}
Expand All @@ -142,7 +149,20 @@ export default function () {
)}
</Show>

<Show when={toggleModeSelect()}>
{/* Transparent overlay to capture outside clicks */}
<div
class="absolute inset-0 z-10"
onClick={() => setToggleModeSelect(false)}
/>
<ModeSelect
standalone
onClose={() => setToggleModeSelect(false)}
/>
</Show>

Comment on lines +152 to +163
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Overlay layering and dismissal UX.

  • Ensure the dialog is above the click-catcher; bump dialog z-index if needed.
  • Add Escape-to-close handling while overlay is open.
         <Show when={toggleModeSelect()}>
           {/* Transparent overlay to capture outside clicks */}
           <div
-            class="absolute inset-0 z-10"
+            class="absolute inset-0 z-10"
             onClick={() => setToggleModeSelect(false)}
           />
           <ModeSelect
             standalone
             onClose={() => setToggleModeSelect(false)}
           />
         </Show>

Add this listener near your other listeners to close on Escape (outside the changed hunk, included here for completeness):

createEventListener(document, "keydown", (e) => {
  if (e.key === "Escape" && toggleModeSelect()) setToggleModeSelect(false);
});
🤖 Prompt for AI Agents
In apps/desktop/src/routes/target-select-overlay.tsx around lines 152 to 163,
the transparent click-catcher div may be layered above the ModeSelect dialog and
there is no Escape-to-close handling; bump the ModeSelect/dialog z-index so it
is rendered above the click-catcher (ensure ModeSelect receives a higher
z-index/class or pass a prop to set z-index > 10) and add a document keydown
listener alongside your other listeners that closes the overlay when Escape is
pressed (check toggleModeSelect() before calling setToggleModeSelect(false) to
avoid unnecessary state changes).

<RecordingControls
setToggleModeSelect={setToggleModeSelect}
target={{ variant: "display", id: params.displayId! }}
/>
</div>
Expand Down Expand Up @@ -191,14 +211,15 @@ export default function () {
</span>
</div>
<RecordingControls
setToggleModeSelect={setToggleModeSelect}
target={{
variant: "window",
id: windowUnderCursor.id,
}}
/>

<Button
variant="primary"
variant="dark"
size="sm"
onClick={() => {
setBounds(windowUnderCursor.bounds);
Expand Down Expand Up @@ -657,16 +678,15 @@ export default function () {
);
}

function RecordingControls(props: { target: ScreenCaptureTarget }) {
function RecordingControls(props: {
target: ScreenCaptureTarget;
setToggleModeSelect?: (value: boolean) => void;
}) {
const auth = authStore.createQuery();
const { rawOptions, setOptions } = createOptionsQuery();

const generalSetings = generalSettingsStore.createQuery();

const capitalize = (str: string) => {
return str.charAt(0).toUpperCase() + str.slice(1);
};

const menuModes = async () =>
await Menu.new({
items: [
Expand Down Expand Up @@ -721,66 +741,78 @@ function RecordingControls(props: { target: ScreenCaptureTarget }) {
};

return (
<div class="flex gap-2.5 items-center p-2.5 my-2.5 rounded-xl border min-w-fit w-fit bg-gray-2 border-gray-4">
<div
onClick={() => setOptions("targetMode", null)}
class="flex justify-center items-center bg-white rounded-full transition-opacity size-9 hover:opacity-80"
>
<IconCapX class="will-change-transform size-3" />
</div>
<div
data-inactive={rawOptions.mode === "instant" && !auth.data}
class="flex flex-row rounded-full bg-blue-9 overflow-hidden group h-11"
onClick={() => {
if (rawOptions.mode === "instant" && !auth.data) {
emit("start-sign-in");
return;
}

commands.startRecording({
capture_target: props.target,
mode: rawOptions.mode,
capture_system_audio: rawOptions.captureSystemAudio,
});
}}
>
<div class="flex items-center pl-4 py-1 hover:bg-blue-10 transition-colors">
{rawOptions.mode === "studio" ? (
<IconCapFilmCut class="size-4" />
) : (
<IconCapInstant class="size-4" />
)}
<div class="flex flex-col ml-3 mr-2">
<span class="text-sm text-white font-medium text-nowrap">
{rawOptions.mode === "instant" && !auth.data
? "Sign In To Use"
: "Start Recording"}
</span>
<span class="text-xs text-nowrap text-white font-light -mt-0.5 opacity-90">
{`${capitalize(rawOptions.mode)} Mode`}
</span>
<>
<div class="flex gap-2.5 items-center p-2.5 my-2.5 rounded-xl border min-w-fit w-fit bg-gray-2 border-gray-4">
<div
onClick={() => setOptions("targetMode", null)}
class="flex justify-center items-center rounded-full transition-opacity bg-gray-12 size-9 hover:opacity-80"
>
<IconCapX class="invert will-change-transform size-3 dark:invert-0" />
</div>
Comment on lines +744 to +751
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use a button for the close control.
Keyboard/a11y and semantics; consistent with the dialog close.

-      <div class="flex gap-2.5 items-center p-2.5 my-2.5 rounded-xl border min-w-fit w-fit bg-gray-2 border-gray-4">
-        <div
-          onClick={() => setOptions("targetMode", null)}
-          class="flex justify-center items-center rounded-full transition-opacity bg-gray-12 size-9 hover:opacity-80"
-        >
-          <IconCapX class="invert will-change-transform size-3 dark:invert-0" />
-        </div>
+      <div class="flex gap-2.5 items-center p-2.5 my-2.5 rounded-xl border min-w-fit w-fit bg-gray-2 border-gray-4">
+        <button
+          type="button"
+          aria-label="Close target selection"
+          onClick={() => setOptions("targetMode", null)}
+          class="flex justify-center items-center rounded-full transition-opacity bg-gray-12 size-9 hover:opacity-80"
+        >
+          <IconCapX class="invert will-change-transform size-3 dark:invert-0" />
+        </button>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<>
<div class="flex gap-2.5 items-center p-2.5 my-2.5 rounded-xl border min-w-fit w-fit bg-gray-2 border-gray-4">
<div
onClick={() => setOptions("targetMode", null)}
class="flex justify-center items-center rounded-full transition-opacity bg-gray-12 size-9 hover:opacity-80"
>
<IconCapX class="invert will-change-transform size-3 dark:invert-0" />
</div>
<>
<div class="flex gap-2.5 items-center p-2.5 my-2.5 rounded-xl border min-w-fit w-fit bg-gray-2 border-gray-4">
<button
type="button"
aria-label="Close target selection"
onClick={() => setOptions("targetMode", null)}
class="flex justify-center items-center rounded-full transition-opacity bg-gray-12 size-9 hover:opacity-80"
>
<IconCapX class="invert will-change-transform size-3 dark:invert-0" />
</button>
🤖 Prompt for AI Agents
In apps/desktop/src/routes/target-select-overlay.tsx around lines 744 to 751,
the close control is implemented as a clickable div which is non-semantic and
not keyboard-accessible; replace the div with a <button> element, give it
type="button", preserve the existing class names, move the onClick handler to
the button, and add an accessible label (e.g. aria-label="Close" or visually
hidden text) so it behaves like the dialog close control and supports
keyboard/a11y semantics.

<div
data-inactive={rawOptions.mode === "instant" && !auth.data}
class="flex overflow-hidden flex-row h-11 rounded-full bg-blue-9 group"
onClick={() => {
if (rawOptions.mode === "instant" && !auth.data) {
emit("start-sign-in");
return;
}

commands.startRecording({
capture_target: props.target,
mode: rawOptions.mode,
capture_system_audio: rawOptions.captureSystemAudio,
});
}}
>
<div class="flex items-center py-1 pl-4 transition-colors hover:bg-blue-10">
{rawOptions.mode === "studio" ? (
<IconCapFilmCut class="size-4" />
) : (
<IconCapInstant class="size-4" />
)}
<div class="flex flex-col mr-2 ml-3">
<span class="text-sm font-medium text-white text-nowrap">
{rawOptions.mode === "instant" && !auth.data
? "Sign In To Use"
: "Start Recording"}
</span>
<span class="text-xs flex items-center text-nowrap gap-1 transition-opacity duration-200 text-white font-light -mt-0.5 opacity-90">
{`${capitalize(rawOptions.mode)} Mode`}
</span>
</div>
</div>
<div
class="pl-2.5 group-hover:bg-blue-10 transition-colors pr-3 py-1.5 flex items-center"
onClick={(e) => {
e.stopPropagation();
menuModes().then((menu) => menu.popup());
}}
>
<IconCapCaretDown class="focus:rotate-90" />
</div>
</div>
<div
class="pl-2.5 group-hover:bg-blue-10 transition-colors pr-3 py-1.5 flex items-center"
onClick={(e) => {
e.stopPropagation();
menuModes().then((menu) => menu.popup());
preRecordingMenu().then((menu) => menu.popup());
}}
class="flex justify-center items-center rounded-full border transition-opacity bg-gray-6 text-gray-12 size-9 hover:opacity-80"
>
<IconCapCaretDown class="focus:rotate-90" />
<IconCapGear class="will-change-transform size-5" />
</div>
</div>
<div
onClick={(e) => {
e.stopPropagation();
preRecordingMenu().then((menu) => menu.popup());
}}
class="flex justify-center items-center rounded-full border transition-opacity bg-gray-6 text-gray-12 size-9 hover:opacity-80"
onClick={() => props.setToggleModeSelect?.(true)}
class="flex gap-1 items-center mb-5 transition-opacity duration-200 hover:opacity-60"
>
<IconCapGear class="will-change-transform size-5" />
<IconCapInfo class="opacity-70 will-change-transform size-3" />
<p class="text-sm text-white">
<span class="opacity-70">What is </span>
<span class="font-medium">{capitalize(rawOptions.mode)} Mode</span>?
</p>
</div>
</div>
</>
);
}

Expand Down
Loading