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
26 changes: 26 additions & 0 deletions apps/code/src/main/services/shell/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,32 @@ describe("ShellService", () => {
vi.clearAllMocks();
});

it.each([
[
"interactive shell session",
() => service.create("session-1", "/home/user/project"),
],
[
"command session",
() =>
service.createCommandSession({
sessionId: "session-1",
command: "echo hello",
cwd: "/home/user/project",
}),
],
])("spawns %s with UTF-8 output decoding", async (_name, createSession) => {
await createSession();

expect(mockPty.spawn).toHaveBeenCalledWith(
expect.any(String),
expect.any(Array),
expect.objectContaining({
encoding: "utf8",
}),
);
});

describe("create", () => {
it("creates a new shell session", async () => {
await service.create("session-1", "/home/user/project");
Expand Down
5 changes: 3 additions & 2 deletions apps/code/src/main/services/shell/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ declare module "node-pty" {
}

const log = logger.scope("shell");
const PTY_ENCODING = "utf8";

export interface ShellSession {
pty: pty.IPty;
Expand Down Expand Up @@ -135,7 +136,7 @@ export class ShellService extends TypedEventEmitter<ShellEvents> {
rows: 24,
cwd: workingDir,
env: buildShellEnv(mergedEnv),
encoding: null,
encoding: PTY_ENCODING,
});

this.processTracking.register(
Expand Down Expand Up @@ -215,7 +216,7 @@ export class ShellService extends TypedEventEmitter<ShellEvents> {
rows: 24,
cwd: workingDir,
env: buildShellEnv(taskEnv),
encoding: null,
encoding: PTY_ENCODING,
});

this.processTracking.register(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { WebLinksAddon } from "@xterm/addon-web-links";
import { Terminal as XTerm } from "@xterm/xterm";

const log = logger.scope("terminal-manager");
const TERMINAL_FONT_FAMILY =
'var(--code-font-family, "Berkeley Mono", "JetBrains Mono", "Consolas", "Monaco", monospace)';

let parkingContainer: HTMLElement | null = null;

Expand Down Expand Up @@ -161,7 +163,7 @@ class TerminalManagerImpl {
const term = new XTerm({
cursorBlink: true,
fontSize: 12,
fontFamily: "monospace",
fontFamily: TERMINAL_FONT_FAMILY,
theme: getTerminalTheme(this.isDarkMode),
cursorStyle: "block",
cursorWidth: 8,
Expand Down
Loading