Skip to content

04: Add live terminal resize handling with SIGWINCH - #163

Merged
shouze merged 1 commit into
feat/bun14-terminal/03-team-pickfrom
feat/bun14-terminal/04-sigwinch
Aug 23, 2026
Merged

04: Add live terminal resize handling with SIGWINCH#163
shouze merged 1 commit into
feat/bun14-terminal/03-team-pickfrom
feat/bun14-terminal/04-sigwinch

Conversation

@shouze

@shouze shouze commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

How did you verify your code works?

@shouze
shouze force-pushed the feat/bun14-terminal/04-sigwinch branch from 9fdab01 to 9590bb7 Compare August 23, 2026 15:45
@github-actions

Copy link
Copy Markdown

Coverage after merging feat/bun14-terminal/04-sigwinch into feat/bun14-terminal/03-team-pick will be

96.06%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.74%100%100%94.07%340–344, 405, 422, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.50%100%97.44%100%
   output.ts99.29%100%95.65%99.61%80
   regex.ts99.39%100%100%99.34%329
   render.ts89.78%100%88.24%89.84%166, 190–195, 197–199, 201–202, 223, 410–411, 434–436, 502–506, 518–519, 524–531, 533–541, 543–544
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%
   terminal.ts100%100%100%100%

1 similar comment
@github-actions

Copy link
Copy Markdown

Coverage after merging feat/bun14-terminal/04-sigwinch into feat/bun14-terminal/03-team-pick will be

96.06%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.74%100%100%94.07%340–344, 405, 422, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.50%100%97.44%100%
   output.ts99.29%100%95.65%99.61%80
   regex.ts99.39%100%100%99.34%329
   render.ts89.78%100%88.24%89.84%166, 190–195, 197–199, 201–202, 223, 410–411, 434–436, 502–506, 518–519, 524–531, 533–541, 543–544
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%
   terminal.ts100%100%100%100%

@shouze
shouze marked this pull request as ready for review August 23, 2026 15:56
Copilot AI lite review requested due to automatic review settings August 23, 2026 15:56

Copilot AI left a comment

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.

Pull request overview

Adds live terminal resize support to the interactive TUI by tracking terminal dimensions and triggering redraws on resize events, while centralizing exit cleanup logic.

Changes:

  • Track termHeight / termWidth and update them on SIGWINCH to trigger redraws on live terminal resizes.
  • Introduce an exit() helper to consolidate cleanup and use it across multiple Ctrl+C / quit paths.
  • Ensure the SIGWINCH handler is removed on the “confirm selection” exit path.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/tui.ts
Comment on lines +133 to +134
let termHeight = process.stdout.rows ?? 40;
let termWidth = process.stdout.columns ?? 120;
Comment thread src/tui.ts
Comment on lines +281 to 284
process.on("SIGWINCH", onResize);

for await (const chunk of process.stdin) {
const key = chunk.toString();
- Change const termHeight to let termHeight for runtime updates
- Add let termWidth for runtime updates
- Install SIGWINCH signal handler before event loop
- Handler updates dimensions and triggers redraw on terminal resize
- Create local exit() helper function for proper cleanup
- Call process.off(SIGWINCH) in all exit paths
- Ensure raw mode is disabled and terminal is cleared on exit
- User can now resize window during interactive session and see immediate redraw

Fixes: #144
@shouze
shouze force-pushed the feat/bun14-terminal/04-sigwinch branch from 9590bb7 to 8c7858b Compare August 23, 2026 16:05
@github-actions

Copy link
Copy Markdown

Coverage after merging feat/bun14-terminal/04-sigwinch into feat/bun14-terminal/03-team-pick will be

96.07%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.74%100%100%94.07%340–344, 405, 422, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.50%100%97.44%100%
   output.ts99.29%100%95.65%99.61%80
   regex.ts99.39%100%100%99.34%329
   render.ts89.80%100%88.24%89.86%166, 190–195, 197–199, 201–202, 223, 411–412, 436–438, 504–508, 520–521, 526–533, 535–543, 545–546
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%
   terminal.ts100%100%100%100%

1 similar comment
@github-actions

Copy link
Copy Markdown

Coverage after merging feat/bun14-terminal/04-sigwinch into feat/bun14-terminal/03-team-pick will be

96.07%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.74%100%100%94.07%340–344, 405, 422, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.42%100%100%99.37%270
   group.ts99.50%100%97.44%100%
   output.ts99.29%100%95.65%99.61%80
   regex.ts99.39%100%100%99.34%329
   render.ts89.80%100%88.24%89.86%166, 190–195, 197–199, 201–202, 223, 411–412, 436–438, 504–508, 520–521, 526–533, 535–543, 545–546
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%
   terminal.ts100%100%100%100%

@shouze
shouze merged commit 831f92b into main Aug 23, 2026
7 checks passed
@shouze
shouze deleted the feat/bun14-terminal/04-sigwinch branch August 23, 2026 16:10
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.

2 participants