-
Notifications
You must be signed in to change notification settings - Fork 1.2k
implement more font and xterm rendering improvements #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6b92a84
fix(desktop): add Nerd Font support for terminal
Kitenite 7cfad14
stuff
Kitenite 8c0d962
fix(desktop): add Oh My Posh font support to terminal
Kitenite 933c88b
fix(desktop): fix Oh My Zsh crash by resetting ZDOTDIR before sourcing
Kitenite 5c2b65a
feat(desktop): add Hyper-style terminal improvements
Kitenite d8f7fd5
remove comments
Kitenite aabd3ad
update config
Kitenite 3817a7c
fix(desktop): fix DataBatcher UTF-8 handling for split multi-byte chars
Kitenite c34612a
feat(desktop): add Hyper-style node-pty improvements
Kitenite d685a99
refactor(desktop): split terminal-manager into modular files
Kitenite 3fc5f69
clean up
Kitenite 35517b8
test(desktop): add unit tests for terminal env and session modules
Kitenite 5c6e379
clean up
Kitenite bdc57e1
clean up
Kitenite 2956219
clean up
Kitenite 01abd2c
update lock file
Kitenite 90600f0
fix locale test
Kitenite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import { StringDecoder } from "node:string_decoder"; | ||
|
|
||
| /** | ||
| * Batches terminal data to reduce IPC overhead between main and renderer processes. | ||
| * Based on Hyper terminal's DataBatcher implementation. | ||
| * | ||
| * This minimizes the number of IPC messages by: | ||
| * 1. Time-based batching: Flushes every BATCH_DURATION_MS (16ms = ~60fps) | ||
| * 2. Size-based batching: Flushes when batch exceeds BATCH_MAX_SIZE (200KB) | ||
| * 3. Proper UTF-8 handling: Uses StringDecoder to handle multi-byte characters | ||
| * that may be split across data chunks | ||
| */ | ||
|
|
||
| // Batch timing - 16ms provides smooth 60fps updates | ||
| const BATCH_DURATION_MS = 16; | ||
|
|
||
| // Maximum batch size before forcing a flush (200KB) | ||
| const BATCH_MAX_SIZE = 200 * 1024; | ||
|
|
||
| export class DataBatcher { | ||
| private decoder: StringDecoder; | ||
| private buffer: string = ""; | ||
| private timeout: ReturnType<typeof setTimeout> | null = null; | ||
| private onFlush: (data: string) => void; | ||
|
|
||
| constructor(onFlush: (data: string) => void) { | ||
| this.decoder = new StringDecoder("utf8"); | ||
| this.onFlush = onFlush; | ||
| } | ||
|
|
||
| /** | ||
| * Add data to the batch. Data will be flushed either when: | ||
| * - BATCH_DURATION_MS has elapsed since the first write | ||
| * - Buffer size exceeds BATCH_MAX_SIZE | ||
| */ | ||
| write(data: Buffer | string): void { | ||
| // Decode buffer data to handle multi-byte UTF-8 characters correctly | ||
| const decoded = typeof data === "string" ? data : this.decoder.write(data); | ||
| this.buffer += decoded; | ||
|
|
||
| // If buffer is getting large, flush immediately | ||
| if (this.buffer.length >= BATCH_MAX_SIZE) { | ||
| this.flush(); | ||
| return; | ||
| } | ||
|
|
||
| // Schedule flush if not already scheduled | ||
| if (this.timeout === null) { | ||
| this.timeout = setTimeout(() => this.flush(), BATCH_DURATION_MS); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Flush any buffered data immediately. | ||
| * Called automatically by timer or when buffer is full. | ||
| */ | ||
| flush(): void { | ||
| if (this.timeout !== null) { | ||
| clearTimeout(this.timeout); | ||
| this.timeout = null; | ||
| } | ||
|
|
||
| // Flush any remaining bytes from the decoder | ||
| const remaining = this.decoder.end(); | ||
| if (remaining) { | ||
| this.buffer += remaining; | ||
| } | ||
|
|
||
| if (this.buffer.length > 0) { | ||
| this.onFlush(this.buffer); | ||
| this.buffer = ""; | ||
| } | ||
|
|
||
| // Reset decoder for next batch | ||
| this.decoder = new StringDecoder("utf8"); | ||
| } | ||
|
|
||
| /** | ||
| * Dispose of the batcher, flushing any remaining data. | ||
| */ | ||
| dispose(): void { | ||
| this.flush(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.