@devries-cameron20 / t3code Mirror · read-only / commits / 1200f530bd
Fork 0

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 24, 09:00 UTC

refactor(web): keep app utilities private and remove dead helpers (#10227)

Julius Marminge committed Sep 5, 2026 at 22:07 UTC 1200f530bdc8be25ca1c85affa42b6d9c259601c
22 files changed +27 -52
apps/web/src/browser/browserViewportActions.ts
+1 -1
@@ -4,7 +4,7 @@ type BrowserViewportHandler = (setting: PreviewViewportSetting) => Promise<void>
4
5 export const BROWSER_VIEWPORT_COMMIT_TIMEOUT_MS = 15_000;
6
7 -export class BrowserViewportCommitTimeoutError extends Error {
7 +class BrowserViewportCommitTimeoutError extends Error {
8 override readonly name = "BrowserViewportCommitTimeoutError";
9
10 constructor(readonly tabId: string) {
apps/web/src/browser/webviewCrashRecovery.ts
+2 -2
@@ -1,6 +1,6 @@
1 export const WEBVIEW_CRASH_RECOVERY_WINDOW_MS = 30_000;
2 -export const WEBVIEW_CRASH_RECOVERY_MAX_ATTEMPTS = 3;
3 -export const WEBVIEW_CRASH_RECOVERY_BASE_DELAY_MS = 250;
2 +const WEBVIEW_CRASH_RECOVERY_MAX_ATTEMPTS = 3;
3 +const WEBVIEW_CRASH_RECOVERY_BASE_DELAY_MS = 250;
4
5 export interface WebviewCrashRecoveryState {
6 readonly attempts: number;
apps/web/src/browserFaviconLogic.ts
+1 -1
@@ -9,7 +9,7 @@ export type BrowserFaviconEntry = {
9 };
10
11 export const BROWSER_FAVICON_MAX_ENTRIES = 40;
12 -export const BROWSER_FAVICON_MAX_KEY_LENGTH = 4_096;
12 +const BROWSER_FAVICON_MAX_KEY_LENGTH = 4_096;
13 const BROWSER_FAVICON_MAX_FUTURE_SKEW_MS = 5 * 60 * 1_000;
14 export const BROWSER_FAVICON_MAX_ALIASES_PER_ENTRY = 4;
15 const BROWSER_FAVICON_MAX_ALIAS_LENGTH = 255;
apps/web/src/browserHistoryStore.ts
+2 -2
@@ -14,7 +14,7 @@ export type BrowserHistoryEntry = { url: string; lastVisitedAt: number; title?:
14
15 export const BROWSER_HISTORY_MAX_ENTRIES_PER_PROJECT = 50;
16 export const BROWSER_HISTORY_MAX_PROJECTS = 20;
17 -export const BROWSER_HISTORY_MAX_URL_LENGTH = 2048;
17 +const BROWSER_HISTORY_MAX_URL_LENGTH = 2048;
18 export const BROWSER_HISTORY_MAX_TITLE_LENGTH = 512;
19 const MAX_VALID_DATE_MS = 8_640_000_000_000_000;
20
@@ -35,7 +35,7 @@ export function normalizeHistoryUrl(raw: string): string | null {
35 return parsed.href.length > BROWSER_HISTORY_MAX_URL_LENGTH ? null : parsed.href;
36 }
37
38 -export function titleLookupKey(normalized: string, environmentHostname?: string | null): string {
38 +function titleLookupKey(normalized: string, environmentHostname?: string | null): string {
39 const parsed = new URL(visitLookupKey(normalized, environmentHostname));
40 if (parsed.pathname !== "/" && parsed.pathname.endsWith("/"))
41 parsed.pathname = parsed.pathname.slice(0, -1);
apps/web/src/clientPersistenceStorage.ts
+1 -1
@@ -2,7 +2,7 @@ import { ClientSettingsSchema, type ClientSettings } from "@t3tools/contracts";
2
3 import { getLocalStorageItem, setLocalStorageItem } from "./hooks/useLocalStorage";
4
5 -export const CLIENT_SETTINGS_STORAGE_KEY = "t3code:client-settings:v1";
5 +const CLIENT_SETTINGS_STORAGE_KEY = "t3code:client-settings:v1";
6
7 function hasWindow(): boolean {
8 return typeof window !== "undefined";
apps/web/src/composerDraftStore.ts
+2 -4
@@ -769,7 +769,7 @@ const EMPTY_THREAD_DRAFT = Object.freeze<ComposerThreadDraftState>({
769 * slice — adding a new field to the interface (e.g. `elementContexts`) only
770 * has to be reflected here, not in every stub.
771 */
772 -export function createEmptyThreadDraft(): ComposerThreadDraftState {
772 +function createEmptyThreadDraft(): ComposerThreadDraftState {
773 return {
774 prompt: "",
775 images: [],
@@ -4050,9 +4050,7 @@ export function useThreadHasUnsentDraft(threadRef: ScopedThreadRef): boolean {
4050 );
4051 }
4052
4053 -export function useComposerDraftModelState(
4054 - threadRef: ComposerThreadTarget,
4055 -): ComposerDraftModelState {
4053 +function useComposerDraftModelState(threadRef: ComposerThreadTarget): ComposerDraftModelState {
4054 return useComposerDraftStore(
4055 useShallow((state) => {
4056 const draft = getComposerDraftState(state, threadRef);
apps/web/src/desktopAppActivation.ts
+1 -1
@@ -44,7 +44,7 @@ function failure(
44 return { version: 1, requestId, ok: false, code, message };
45 }
46
47 -export function desktopPlatformToEnvironmentOs(
47 +function desktopPlatformToEnvironmentOs(
48 platform: DesktopAppActivationRequest["platform"],
49 ): ExecutionEnvironmentPlatformOs {
50 return platform === "win32" ? "windows" : platform;
apps/web/src/keybindings.ts
-8
@@ -377,14 +377,6 @@ export function isDiffToggleShortcut(
377 return matchesCommandShortcut(event, keybindings, "diff.toggle", options);
378 }
379
380 -export function isPreviewRefreshShortcut(
381 - event: ShortcutEventLike,
382 - keybindings: ResolvedKeybindingsConfig,
383 - options?: ShortcutMatchOptions,
384 -): boolean {
385 - return matchesCommandShortcut(event, keybindings, "preview.refresh", options);
386 -}
387 -
380 export function isOpenFavoriteEditorShortcut(
381 event: ShortcutEventLike,
382 keybindings: ResolvedKeybindingsConfig,
apps/web/src/lib/attachmentUploadQueue.ts
+1 -1
@@ -445,7 +445,7 @@ export function startAttachmentUpload(input: {
445 * persisted draft upload survives cancellation (an environment switch cancels
446 * the old job, and the draft still references that server copy).
447 */
448 -export function cancelAttachmentUpload(imageId: string): void {
448 +function cancelAttachmentUpload(imageId: string): void {
449 const job = jobsByImageId.get(imageId);
450 if (!job) {
451 return;
apps/web/src/lib/diffRendering.ts
+2 -2
@@ -1,7 +1,7 @@
1 import { parsePatchFiles } from "@pierre/diffs/utils/parsePatchFiles";
2 import type { FileDiffMetadata } from "@pierre/diffs/types";
3
4 -export const DIFF_THEME_NAMES = {
4 +const DIFF_THEME_NAMES = {
5 light: "pierre-light",
6 dark: "pierre-dark",
7 } as const;
@@ -81,7 +81,7 @@ interface RenderablePatchOptions {
81 compactPartialHunkOffsets?: boolean;
82 }
83
84 -export function compactPartialHunkOffsets(file: FileDiffMetadata): FileDiffMetadata {
84 +function compactPartialHunkOffsets(file: FileDiffMetadata): FileDiffMetadata {
85 if (!file.isPartial) return file;
86
87 let splitLineStart = 0;
apps/web/src/lib/previewAnnotation.ts
+1 -1
@@ -111,7 +111,7 @@ async function previewAnnotationScreenshotFile(
111 }
112
113 /** Upper bound on turning a picked element's crop into a composer attachment. */
114 -export const PREVIEW_ANNOTATION_CAPTURE_TIMEOUT_MS = 5_000;
114 +const PREVIEW_ANNOTATION_CAPTURE_TIMEOUT_MS = 5_000;
115
116 export type PreviewAnnotationCapture =
117 /** The crop is ready to attach. */
apps/web/src/lib/storage.ts
+1 -1
@@ -26,7 +26,7 @@ export function createMemoryStorage(): StateStorage {
26 };
27 }
28
29 -export function isStateStorage(
29 +function isStateStorage(
30 storage: Partial<StateStorage> | null | undefined,
31 ): storage is StateStorage {
32 return (
apps/web/src/lib/terminalContext.ts
+2 -5
@@ -65,7 +65,7 @@ export function filterTerminalContextsWithText<T extends { text: string }>(
65 return contexts.filter((context) => hasTerminalContextText(context));
66 }
67
68 -export function normalizeTerminalContextSelection(
68 +function normalizeTerminalContextSelection(
69 selection: TerminalContextSelection,
70 ): TerminalContextSelection | null {
71 const text = normalizeTerminalContextText(selection.text);
@@ -85,10 +85,7 @@ export function normalizeTerminalContextSelection(
85 };
86 }
87
88 -export function formatTerminalContextRange(selection: {
89 - lineStart: number;
90 - lineEnd: number;
91 -}): string {
88 +function formatTerminalContextRange(selection: { lineStart: number; lineEnd: number }): string {
89 return selection.lineStart === selection.lineEnd
90 ? `line ${selection.lineStart}`
91 : `lines ${selection.lineStart}-${selection.lineEnd}`;
apps/web/src/lib/windowControlsOverlay.ts
+1 -1
@@ -43,7 +43,7 @@ export function syncDocumentWindowControlsOverlayClass(): () => void {
43 };
44 }
45
46 -export function getElectronPlatformClassNames(
46 +function getElectronPlatformClassNames(
47 platform: string,
48 ):
49 | readonly [typeof ELECTRON_CLASS_NAME]
apps/web/src/logicalProject.ts
-1
@@ -4,7 +4,6 @@ export {
4 deriveLogicalProjectKeyFromSettings,
5 derivePhysicalProjectKey,
6 derivePhysicalProjectKeyFromPath,
7 - deriveProjectGroupLabel,
7 deriveProjectGroupingOverrideKey,
8 getProjectOrderKey,
9 resolveProjectGroupingMode,
apps/web/src/portDiscoveryState.ts
+1 -1
@@ -43,7 +43,7 @@ export function boundConfiguredLocalServerUrls(
43 return bounded;
44 }
45
46 -export function useDiscoveredPorts(
46 +function useDiscoveredPorts(
47 environmentId: EnvironmentId | null,
48 configuredUrls?: ReadonlyArray<string>,
49 ): ReadonlyArray<DiscoveredLocalServer> {
apps/web/src/projectIconOptions.ts
+1 -1
@@ -1,7 +1,7 @@
1 import { iconNames, type IconName } from "lucide-react/dynamic";
2 export { PROJECT_ICON_COLORS, projectIconColorClassName } from "./projectIconColors";
3
4 -export const POPULAR_PROJECT_ICONS = [
4 +const POPULAR_PROJECT_ICONS = [
5 "folder-code",
6 "code-2",
7 "terminal",
apps/web/src/reviewCommentContext.ts
-6
@@ -180,12 +180,6 @@ export function parseReviewCommentMessageSegments(
180 return segments;
181 }
182
183 -export function hasReviewCommentMessageSegments(value: string): boolean {
184 - return parseReviewCommentMessageSegments(value).some(
185 - (segment) => segment.kind === "review-comment",
186 - );
187 -}
188 -
183 export function formatReviewCommentFence(language: string, contents: string): string {
184 const longestBacktickRun = Math.max(
185 0,
apps/web/src/rightPanelStore.ts
+2 -2
@@ -14,7 +14,7 @@ import { createJSONStorage, persist } from "zustand/middleware";
14
15 import { resolveStorage } from "./lib/storage";
16
17 -export const RIGHT_PANEL_KINDS = [
17 +const RIGHT_PANEL_KINDS = [
18 "diff",
19 "files",
20 "file",
@@ -193,7 +193,7 @@ export function pullRequestSurfaceId(target: {
193 return `pull-request:${scope}${encodeURIComponent(target.projectId)}:${encodeURIComponent(target.repository)}:${target.number}`;
194 }
195
196 -export function pullRequestSurface(target: {
196 +function pullRequestSurface(target: {
197 environmentId?: string;
198 projectId: string;
199 repository: string;
apps/web/src/test/reactHookHarness.ts
+1 -1
@@ -34,7 +34,7 @@ import type { Dispatch, SetStateAction } from "react";
34 * Call `beginRender()` before each component invocation and `reset()` in
35 * `beforeEach` to drop persisted state between tests.
36 */
37 -export function createReactHookHarness() {
37 +function createReactHookHarness() {
38 let cursor = 0;
39 let slots: unknown[] = [];
40 const nextIndex = () => cursor++;
apps/web/src/themePalette.ts
+3 -8
@@ -22,15 +22,10 @@ export { EMBER_THEME, GROVE_THEME, IRIS_THEME, OCEAN_THEME, T3_CHAT_THEME, THEME
22 export type { ThemeAppearance, ThemeColorRole, ThemeColors, ThemeDefinition, ThemeVariants };
23
24 export const T3_CHAT_THEME_ID = "t3-chat" as const;
25 -export const T3_CHAT_THEME_LABEL = "T3 Chat";
26 -export const GROVE_THEME_ID = "grove" as const;
27 -export const GROVE_THEME_LABEL = "Grove";
25 +const GROVE_THEME_ID = "grove" as const;
26 export const OCEAN_THEME_ID = "ocean" as const;
29 -export const OCEAN_THEME_LABEL = "Ocean";
30 -export const EMBER_THEME_ID = "ember" as const;
31 -export const EMBER_THEME_LABEL = "Ember";
32 -export const IRIS_THEME_ID = "iris" as const;
33 -export const IRIS_THEME_LABEL = "Iris";
27 +const EMBER_THEME_ID = "ember" as const;
28 +const IRIS_THEME_ID = "iris" as const;
29 export const THEME_FILE_VERSION = 1 as const;
30 export const CUSTOM_THEMES_STORAGE_KEY = "t3code:themes:v1";
31 export const THEME_FOLLOW_SYSTEM_STORAGE_KEY = "t3code:theme-follow-system";
apps/web/src/versionSkew.ts
+1 -1
@@ -12,7 +12,7 @@ export interface VersionMismatch {
12 readonly hint: string;
13 }
14
15 -export const VERSION_MISMATCH_DISMISSALS_STORAGE_KEY = "t3code:version-mismatch-dismissals:v1";
15 +const VERSION_MISMATCH_DISMISSALS_STORAGE_KEY = "t3code:version-mismatch-dismissals:v1";
16
17 // Runtime failures retain their identity until the next attempt. Dismiss only
18 // that attempt, across chat remounts, without clearing the error in Settings.