Skip to content

Fix terminal special character rendering#2152

Merged
charlesvien merged 1 commit into
PostHog:mainfrom
shusingh:fix-terminal-special-character-rendering
May 18, 2026
Merged

Fix terminal special character rendering#2152
charlesvien merged 1 commit into
PostHog:mainfrom
shusingh:fix-terminal-special-character-rendering

Conversation

@shusingh
Copy link
Copy Markdown
Contributor

Summary

  • decode PTY output as UTF-8 strings before sending terminal data to the renderer
  • use the app's code font stack for xterm instead of the browser default monospace font
  • cover the PTY encoding option in the shell service test

Fixes #1789.

Tests

  • pnpm exec biome check apps/code/src/main/services/shell/service.ts apps/code/src/main/services/shell/service.test.ts apps/code/src/renderer/features/terminal/services/TerminalManager.ts
  • pnpm --filter code test src/main/services/shell/service.test.ts
  • pnpm --filter code exec tsc -p tsconfig.node.json --noEmit --pretty false
  • pnpm --filter code exec tsc -p tsconfig.web.json --noEmit --pretty false

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 16, 2026

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/code/src/main/services/shell/service.test.ts:297-307
**Redundant test — encoding already asserted elsewhere**

The existing "creates a new shell session" test (line 189) was also updated in this PR to include `encoding: "utf8"` in its `objectContaining` assertion, making this standalone test a duplicate. Both tests call `service.create("session-1")` and assert the same `encoding` property on the same spawn call, violating OnceAndOnlyOnce. The new test can be removed; the encoding expectation is already covered.

Reviews (1): Last reviewed commit: "Fix terminal special character rendering" | Re-trigger Greptile

Comment on lines +297 to +307
it("decodes pty output as UTF-8 text", async () => {
await service.create("session-1");

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Redundant test — encoding already asserted elsewhere

The existing "creates a new shell session" test (line 189) was also updated in this PR to include encoding: "utf8" in its objectContaining assertion, making this standalone test a duplicate. Both tests call service.create("session-1") and assert the same encoding property on the same spawn call, violating OnceAndOnlyOnce. The new test can be removed; the encoding expectation is already covered.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/main/services/shell/service.test.ts
Line: 297-307

Comment:
**Redundant test — encoding already asserted elsewhere**

The existing "creates a new shell session" test (line 189) was also updated in this PR to include `encoding: "utf8"` in its `objectContaining` assertion, making this standalone test a duplicate. Both tests call `service.create("session-1")` and assert the same `encoding` property on the same spawn call, violating OnceAndOnlyOnce. The new test can be removed; the encoding expectation is already covered.

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks. I removed the redundant test and kept the encoding assertion in the existing session creation test. Checks are passing.

@shusingh shusingh force-pushed the fix-terminal-special-character-rendering branch from ca27a98 to a4d94cc Compare May 16, 2026 19:14
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 16, 2026

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/code/src/main/services/shell/service.test.ts:188-203
**`createCommandSession` encoding untested; parameterised test preferred**

The PR adds `encoding: PTY_ENCODING` to both `create` (interactive shell) and `createCommandSession` (line 219 of `service.ts`), but the test assertion only covers the `create` path — `createCommandSession` has no test coverage at all. Per the team's "Expresses every idea" rule and preference for parameterised tests, a single `it.each` over both spawn call sites would verify the encoding fix uniformly without duplicating setup.

Reviews (2): Last reviewed commit: "Fix terminal special character rendering" | Re-trigger Greptile

@shusingh shusingh force-pushed the fix-terminal-special-character-rendering branch from a4d94cc to 98a827a Compare May 17, 2026 14:49
@shusingh
Copy link
Copy Markdown
Contributor Author

Updated the test coverage to use a parameterized test for both create and createCommandSession, so the PTY UTF-8 encoding option is asserted on both spawn paths without duplicating the create-session test. Focused shell service test and Biome check are passing locally.

@shusingh
Copy link
Copy Markdown
Contributor Author

Updated to cover both PTY spawn paths with a single parameterized test, including createCommandSession. The focused shell service test and Biome check pass locally.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 17, 2026

Reviews (3): Last reviewed commit: "Fix terminal special character rendering" | Re-trigger Greptile

Copy link
Copy Markdown
Member

@charlesvien charlesvien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LFG

@charlesvien charlesvien merged commit a03f330 into PostHog:main May 18, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The terminal doesn’t seem to render special characters correctly.

2 participants