fix: fixes for shell/Terminal issues and CPU burn

This commit is contained in:
2026-05-06 22:04:57 +02:00
parent 6b500ec7cb
commit 2523340d08
4 changed files with 89 additions and 17 deletions
+3 -2
View File
@@ -20,6 +20,7 @@ struct TermCell {
};
static constexpr int TERM_MAX_SCROLLBACK = 500;
static constexpr int TERM_MAX_READS_PER_POLL = 8;
struct TerminalState {
TermCell* cells;
@@ -716,8 +717,8 @@ static inline void terminal_handle_key(TerminalState* t, const Montauk::KeyEvent
static inline bool terminal_poll(TerminalState* t) {
if (t->child_pid <= 0) return false;
char buf[4096];
// Drain all available data so large output renders in one frame
for (;;) {
// Drain a bounded amount per frame so window close/input events stay responsive.
for (int reads = 0; reads < TERM_MAX_READS_PER_POLL; reads++) {
int n = montauk::childio_read(t->child_pid, buf, sizeof(buf));
if (n > 0) {
terminal_feed(t, buf, n);