Skip to content
Open
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
128 changes: 128 additions & 0 deletions apps/desktop/src/test/electronMock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import { EventEmitter } from "node:events";

const appEmitter = new EventEmitter();

export const app = Object.assign(appEmitter, {
commandLine: {
appendSwitch: () => undefined,
},
dock: {
setIcon: () => undefined,
},
exit: () => undefined,
focus: () => undefined,
getAppPath: () => "/app",
getPath: () => "/tmp/t3code-desktop-test",
getVersion: () => "0.0.0-test",
isPackaged: false,
name: "T3 Code",
quit: () => undefined,
relaunch: () => undefined,
removeListener: appEmitter.removeListener.bind(appEmitter),
runningUnderARM64Translation: false,
setAboutPanelOptions: () => undefined,
setAppUserModelId: () => undefined,
setDesktopName: () => undefined,
setName: () => undefined,
setPath: () => undefined,
whenReady: () => Promise.resolve(),
});

export class BrowserWindow {
static getAllWindows() {
return [];
}

static getFocusedWindow() {
return null;
}

readonly webContents = {
copyImageAt: () => undefined,
isLoadingMainFrame: () => false,
on: () => undefined,
once: () => undefined,
openDevTools: () => undefined,
replaceMisspelling: () => undefined,
send: () => undefined,
setWindowOpenHandler: () => undefined,
};

destroy() {}
focus() {}
isDestroyed() {
return false;
}
isMinimized() {
return false;
}
isVisible() {
return true;
}
loadURL() {
return Promise.resolve();
}
on() {}
once() {}
restore() {}
setBackgroundColor() {}
setTitle() {}
setTitleBarOverlay() {}
show() {}
}

export const clipboard = {
writeText: () => undefined,
};

export const dialog = {
showErrorBox: () => undefined,
showMessageBox: () => Promise.resolve({ response: 0, checkboxChecked: false }),
showOpenDialog: () => Promise.resolve({ canceled: true, filePaths: [] }),
};

export const Menu = {
buildFromTemplate: () => ({
popup: () => undefined,
}),
setApplicationMenu: () => undefined,
};

export const nativeImage = {
createFromNamedImage: () => ({
isEmpty: () => true,
resize: () => ({
isEmpty: () => true,
}),
}),
};

const nativeThemeEmitter = new EventEmitter();

export const nativeTheme = Object.assign(nativeThemeEmitter, {
removeListener: nativeThemeEmitter.removeListener.bind(nativeThemeEmitter),
shouldUseDarkColors: false,
themeSource: "system",
});

export const protocol = {
handle: () => undefined,
registerFileProtocol: () => true,
registerSchemesAsPrivileged: () => undefined,
unhandle: () => undefined,
};

export const safeStorage = {
decryptString: () => "",
encryptString: () => Buffer.from(""),
isEncryptionAvailable: () => true,
};

export const shell = {
openExternal: () => Promise.resolve(),
};

export const ipcMain = {
handle: () => undefined,
removeHandler: () => undefined,
};
18 changes: 18 additions & 0 deletions apps/desktop/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as path from "node:path";
import { defineConfig, mergeConfig } from "vitest/config";

import baseConfig from "../../vitest.config.ts";

export default mergeConfig(
baseConfig,
defineConfig({
resolve: {
alias: [
{
find: /^electron$/,
replacement: path.resolve(import.meta.dirname, "./src/test/electronMock.ts"),
},
],
},
}),
);
26 changes: 15 additions & 11 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
} from "~/rpc/serverState";
import { sanitizeThreadErrorMessage } from "~/rpc/transportError";
import { retainThreadDetailSubscription } from "../environments/runtime/service";
import { ResizableRightPanel } from "./ResizableRightPanel";
import { RightPanelSheet } from "./RightPanelSheet";
import { Button } from "./ui/button";
import {
Expand All @@ -200,6 +201,7 @@
const EMPTY_PROVIDERS: ServerProvider[] = [];
const EMPTY_PROVIDER_SKILLS: ServerProvider["skills"] = [];
const EMPTY_PENDING_USER_INPUT_ANSWERS: Record<string, PendingUserInputDraftAnswer> = {};
const PLAN_INLINE_SIDEBAR_WIDTH_STORAGE_KEY = "chat_plan_sidebar_width_ratio";
type EnvironmentUnavailableState = {
readonly environmentId: EnvironmentId;
readonly label: string;
Expand Down Expand Up @@ -1780,7 +1782,7 @@
);

const focusComposer = useCallback(() => {
composerRef.current?.focusAtEnd();

Check warning on line 1785 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
}, []);
const scheduleComposerFocus = useCallback(() => {
window.requestAnimationFrame(() => {
Expand All @@ -1788,7 +1790,7 @@
});
}, [focusComposer]);
const addTerminalContextToDraft = useCallback((selection: TerminalContextSelection) => {
composerRef.current?.addTerminalContext(selection);

Check warning on line 1793 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
}, []);
const setTerminalOpen = useCallback(
(open: boolean) => {
Expand Down Expand Up @@ -2467,7 +2469,7 @@
const shortcutContext = {
terminalFocus: isTerminalFocused(),
terminalOpen: Boolean(terminalState.terminalOpen),
modelPickerOpen: composerRef.current?.isModelPickerOpen() ?? false,

Check warning on line 2472 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

react-hooks(exhaustive-deps)

React Hook useEffect has a missing dependency: 'composerRef.current'
};

const command = resolveShortcutCommand(event, keybindings, {
Expand Down Expand Up @@ -3019,7 +3021,7 @@
};
});
promptRef.current = "";
composerRef.current?.resetCursorState({ cursor: 0 });

Check warning on line 3024 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
},
[activePendingProgress?.activeQuestion, activePendingUserInput],
);
Expand All @@ -3046,7 +3048,7 @@
),
},
}));
const snapshot = composerRef.current?.readSnapshot();

Check warning on line 3051 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
if (
snapshot?.value !== value ||
snapshot.cursor !== nextCursor ||
Expand Down Expand Up @@ -3109,7 +3111,7 @@
return;
}

const sendCtx = composerRef.current?.getSendContext();

Check warning on line 3114 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
if (!sendCtx) {
return;
}
Expand Down Expand Up @@ -3246,7 +3248,7 @@
return;
}

const sendCtx = composerRef.current?.getSendContext();

Check warning on line 3251 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
if (!sendCtx) {
return;
}
Expand Down Expand Up @@ -3724,17 +3726,19 @@

{/* Plan sidebar */}
{planSidebarOpen && !shouldUsePlanSidebarSheet ? (
<PlanSidebar
activePlan={activePlan}
activeProposedPlan={sidebarProposedPlan}
label={planSidebarLabel}
environmentId={environmentId}
markdownCwd={gitCwd ?? undefined}
workspaceRoot={activeWorkspaceRoot}
timestampFormat={timestampFormat}
mode="sidebar"
onClose={closePlanSidebar}
/>
<ResizableRightPanel storageKey={PLAN_INLINE_SIDEBAR_WIDTH_STORAGE_KEY}>
<PlanSidebar
activePlan={activePlan}
activeProposedPlan={sidebarProposedPlan}
label={planSidebarLabel}
environmentId={environmentId}
markdownCwd={gitCwd ?? undefined}
workspaceRoot={activeWorkspaceRoot}
timestampFormat={timestampFormat}
mode="sidebar"
onClose={closePlanSidebar}
/>
</ResizableRightPanel>
) : null}
</div>
{/* end horizontal flex container */}
Expand Down
4 changes: 1 addition & 3 deletions apps/web/src/components/PlanSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ const PlanSidebar = memo(function PlanSidebar({
<div
className={cn(
"flex min-h-0 flex-col bg-card/50",
mode === "sidebar"
? "h-full w-[340px] shrink-0 border-l border-border/70"
: "h-full w-full",
mode === "sidebar" ? "h-full w-full border-l border-border/70" : "h-full w-full",
)}
>
{/* Header */}
Expand Down
Loading
Loading