The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 25, 18:30 UTC
tidy up
Julius Marminge committed
Feb 15, 2026 at 14:33 UTC
0a5aaf3e0e64fa70e90541c93842296e97d653a6
4 files changed
+30
-28
apps/web/src/components/ChatView.tsx
+7
-8
@@ -23,10 +23,7 @@ import {
23
useState,
24
} from "react";
25
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
26
-import {
27
- gitBranchesQueryOptions,
28
- gitCreateWorktreeMutationOptions,
29
-} from "~/lib/gitReactQuery";
26
+import { gitBranchesQueryOptions, gitCreateWorktreeMutationOptions } from "~/lib/gitReactQuery";
27
import { serverConfigQueryOptions } from "~/lib/serverReactQuery";
28
29
import { isElectron } from "../env";
@@ -79,7 +76,7 @@ import { Separator } from "./ui/separator";
76
import { Group, GroupSeparator } from "./ui/group";
77
import { Menu, MenuItem, MenuPopup, MenuShortcut, MenuTrigger } from "./ui/menu";
78
import { CursorIcon, Icon } from "./Icons";
82
-import { cn } from "~/lib/utils";
79
+import { cn, isMacPlatform, isWindowsPlatform } from "~/lib/utils";
80
import { Badge } from "./ui/badge";
81
82
function formatMessageMeta(createdAt: string, duration: string | null): string {
@@ -140,7 +137,9 @@ export default function ChatView() {
137
const { state, dispatch } = useStore();
138
const api = useNativeApi();
139
const queryClient = useQueryClient();
143
- const createWorktreeMutation = useMutation(gitCreateWorktreeMutationOptions({ api, queryClient }));
140
+ const createWorktreeMutation = useMutation(
141
+ gitCreateWorktreeMutationOptions({ api, queryClient }),
142
+ );
143
const [prompt, setPrompt] = useState("");
144
const [composerImages, setComposerImages] = useState<ComposerImageAttachment[]>([]);
145
const [isDragOverComposer, setIsDragOverComposer] = useState(false);
@@ -1533,9 +1532,9 @@ function OpenInPicker({ keybindings }: { keybindings: ResolvedKeybindingsConfig
1532
value: "cursor",
1533
},
1534
{
1536
- label: navigator.platform.includes("Mac")
1535
+ label: isMacPlatform(navigator.platform)
1536
? "Finder"
1538
- : navigator.platform.includes("Win")
1537
+ : isWindowsPlatform(navigator.platform)
1538
? "Explorer"
1539
: "Files",
1540
Icon: FolderClosedIcon,
apps/web/src/keybindings.ts
+14
-16
@@ -4,6 +4,7 @@ import {
4
type KeybindingWhenNode,
5
type ResolvedKeybindingsConfig,
6
} from "@t3tools/contracts";
7
+import { isMacPlatform } from "./lib/utils";
8
9
export interface ShortcutEventLike {
10
key: string;
@@ -19,17 +20,11 @@ export interface ShortcutMatchContext {
20
[key: string]: boolean;
21
}
22
22
-export type ResolvedKeybindings = ResolvedKeybindingsConfig;
23
-
23
interface ShortcutMatchOptions {
24
platform?: string;
25
context?: Partial<ShortcutMatchContext>;
26
}
27
29
-function isMacPlatform(platform: string): boolean {
30
- return /mac|iphone|ipad|ipod/i.test(platform);
31
-}
32
-
28
function normalizeEventKey(key: string): string {
29
const normalized = key.toLowerCase();
30
if (normalized === "esc") return "escape";
@@ -83,7 +78,7 @@ function evaluateWhenNode(node: KeybindingWhenNode, context: ShortcutMatchContex
78
}
79
80
function matchesWhenClause(
86
- whenAst: ResolvedKeybindings[number]["whenAst"],
81
+ whenAst: ResolvedKeybindingsConfig[number]["whenAst"],
82
context: ShortcutMatchContext,
83
): boolean {
84
if (!whenAst) return true;
@@ -92,7 +87,7 @@ function matchesWhenClause(
87
88
function matchesCommandShortcut(
89
event: ShortcutEventLike,
95
- keybindings: ResolvedKeybindings,
90
+ keybindings: ResolvedKeybindingsConfig,
91
command: KeybindingCommand,
92
options?: ShortcutMatchOptions,
93
): boolean {
@@ -101,7 +96,7 @@ function matchesCommandShortcut(
96
97
function resolveShortcutCommand(
98
event: ShortcutEventLike,
104
- keybindings: ResolvedKeybindings,
99
+ keybindings: ResolvedKeybindingsConfig,
100
options?: ShortcutMatchOptions,
101
): KeybindingCommand | null {
102
const platform = resolvePlatform(options);
@@ -128,7 +123,10 @@ function formatShortcutKeyLabel(key: string): string {
123
return key.slice(0, 1).toUpperCase() + key.slice(1);
124
}
125
131
-export function formatShortcutLabel(shortcut: KeybindingShortcut, platform = navigator.platform): string {
126
+export function formatShortcutLabel(
127
+ shortcut: KeybindingShortcut,
128
+ platform = navigator.platform,
129
+): string {
130
const keyLabel = formatShortcutKeyLabel(shortcut.key);
131
const useMetaForMod = isMacPlatform(platform);
132
const showMeta = shortcut.metaKey || (shortcut.modKey && useMetaForMod);
@@ -150,7 +148,7 @@ export function formatShortcutLabel(shortcut: KeybindingShortcut, platform = nav
148
}
149
150
export function shortcutLabelForCommand(
153
- keybindings: ResolvedKeybindings,
151
+ keybindings: ResolvedKeybindingsConfig,
152
command: KeybindingCommand,
153
platform = navigator.platform,
154
): string | null {
@@ -164,7 +162,7 @@ export function shortcutLabelForCommand(
162
163
export function isTerminalToggleShortcut(
164
event: ShortcutEventLike,
167
- keybindings: ResolvedKeybindings,
165
+ keybindings: ResolvedKeybindingsConfig,
166
options?: ShortcutMatchOptions,
167
): boolean {
168
return matchesCommandShortcut(event, keybindings, "terminal.toggle", options);
@@ -172,7 +170,7 @@ export function isTerminalToggleShortcut(
170
171
export function isTerminalSplitShortcut(
172
event: ShortcutEventLike,
175
- keybindings: ResolvedKeybindings,
173
+ keybindings: ResolvedKeybindingsConfig,
174
options?: ShortcutMatchOptions,
175
): boolean {
176
return matchesCommandShortcut(event, keybindings, "terminal.split", options);
@@ -180,7 +178,7 @@ export function isTerminalSplitShortcut(
178
179
export function isTerminalNewShortcut(
180
event: ShortcutEventLike,
183
- keybindings: ResolvedKeybindings,
181
+ keybindings: ResolvedKeybindingsConfig,
182
options?: ShortcutMatchOptions,
183
): boolean {
184
return matchesCommandShortcut(event, keybindings, "terminal.new", options);
@@ -188,7 +186,7 @@ export function isTerminalNewShortcut(
186
187
export function isChatNewShortcut(
188
event: ShortcutEventLike,
191
- keybindings: ResolvedKeybindings,
189
+ keybindings: ResolvedKeybindingsConfig,
190
options?: ShortcutMatchOptions,
191
): boolean {
192
return matchesCommandShortcut(event, keybindings, "chat.new", options);
@@ -196,7 +194,7 @@ export function isChatNewShortcut(
194
195
export function isOpenFavoriteEditorShortcut(
196
event: ShortcutEventLike,
199
- keybindings: ResolvedKeybindings,
197
+ keybindings: ResolvedKeybindingsConfig,
198
options?: ShortcutMatchOptions,
199
): boolean {
200
return matchesCommandShortcut(event, keybindings, "editor.openFavorite", options);
apps/web/src/lib/utils.ts
+8
@@ -4,3 +4,11 @@ import { twMerge } from "tailwind-merge";
4
export function cn(...inputs: CxOptions) {
5
return twMerge(cx(inputs));
6
}
7
+
8
+export function isMacPlatform(platform: string): boolean {
9
+ return /mac|iphone|ipad|ipod/i.test(platform);
10
+}
11
+
12
+export function isWindowsPlatform(platform: string): boolean {
13
+ return /win|windows/i.test(platform);
14
+}
apps/web/src/terminal-links.ts
+1
-4
@@ -1,4 +1,5 @@
1
import { EDITORS, type EditorId } from "@t3tools/contracts";
2
+import { isMacPlatform } from "./lib/utils";
3
4
export type TerminalLinkKind = "url" | "path";
5
@@ -15,10 +16,6 @@ const FILE_PATH_PATTERN =
16
const TRAILING_PUNCTUATION_PATTERN = /[.,;!?]+$/;
17
const LAST_EDITOR_KEY = "t3code:last-editor";
18
18
-function isMacPlatform(platform: string): boolean {
19
- return /mac|iphone|ipad|ipod/i.test(platform);
20
-}
21
-
19
function trimClosingDelimiters(value: string): string {
20
let output = value.replace(TRAILING_PUNCTUATION_PATTERN, "");
21
if (output.length === 0) return output;