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
7 changes: 3 additions & 4 deletions web/src/features/chat/components/chat-conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
SparklesIcon,
} from "lucide-react";
import { useCallback, useEffect, useRef, useState } from "react";
import { isMacOS } from "@/hooks/utils";
import { hasPlatformModifier, isMacOS } from "@/hooks/utils";
import {
VirtualizedMessageList,
type VirtualizedMessageListHandle,
Expand Down Expand Up @@ -61,7 +61,7 @@ export function ChatConversation({
// Handle Cmd+F / Ctrl+F
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if ((e.metaKey || e.ctrlKey) && e.key === "f") {
if (hasPlatformModifier(e) && e.key === "f") {
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
e.preventDefault();
onSearchOpenChange(true);
}
Expand Down Expand Up @@ -138,8 +138,7 @@ export function ChatConversation({
className="mt-1"
type="button"
onClick={(e) => {
const isNewTab = isMacOS() ? e.metaKey : e.ctrlKey;
if (isNewTab) {
if (hasPlatformModifier(e)) {
const url = new URL(window.location.origin + window.location.pathname);
url.searchParams.set("action", "create");
window.open(url.toString(), "_blank");
Expand Down
8 changes: 3 additions & 5 deletions web/src/features/sessions/sessions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import {
CollapsibleTrigger,
CollapsibleContent,
} from "@/components/ui/collapsible";
import { isMacOS } from "@/hooks/utils";
import { hasPlatformModifier, isMacOS } from "@/hooks/utils";
import { cn, } from "@/lib/utils";

// Top-level regex constants for performance
Expand Down Expand Up @@ -647,8 +647,7 @@ export const SessionsSidebar = memo(function SessionsSidebarComponent({
aria-label="New Session"
className="cursor-pointer rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
onClick={(e) => {
const isNewTab = isMacOS() ? e.metaKey : e.ctrlKey;
if (isNewTab) {
if (hasPlatformModifier(e)) {
const url = new URL(window.location.origin + window.location.pathname);
url.searchParams.set("action", "create");
window.open(url.toString(), "_blank");
Expand Down Expand Up @@ -865,8 +864,7 @@ export const SessionsSidebar = memo(function SessionsSidebarComponent({
className="shrink-0 cursor-pointer rounded-md p-1 text-muted-foreground opacity-0 group-hover/dir:opacity-100 hover:bg-accent hover:text-foreground transition-all"
onClick={(e) => {
e.stopPropagation();
const isNewTab = isMacOS() ? e.metaKey : e.ctrlKey;
if (isNewTab) {
if (hasPlatformModifier(e)) {
const url = new URL(window.location.origin + window.location.pathname);
url.searchParams.set("action", "create-in-dir");
url.searchParams.set("workDir", group.workDir);
Expand Down
13 changes: 13 additions & 0 deletions web/src/hooks/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ export function isMacOS(): boolean {
return navigator.platform.toLowerCase().includes("mac");
}

const _isMac =
typeof navigator !== "undefined" &&
navigator.platform.toLowerCase().includes("mac");

/**
* Check if the platform-specific modifier key is pressed (Cmd on macOS, Ctrl elsewhere).
*/
export function hasPlatformModifier(
e: Pick<KeyboardEvent | MouseEvent, "metaKey" | "ctrlKey">,
): boolean {
return _isMac ? e.metaKey : e.ctrlKey;
}

/**
* Get the API base URL for connecting to the Kimi backend.
* - Vite dev: uses Vite proxy, so empty string (relative URLs like /api/...)
Expand Down
Loading