nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Feature] Add an option to limit the TUI frame rate (Ink maxFps) for slow terminals and weak CPUs

Open addyCooks opened this issue 1 month ago • 3 comments

Summary

Ink redraws up to 30 times a second while an answer streams. Nanocoder never passes maxFps to render(), so users cannot lower it. A lower rate sends far less output to the terminal (helpful over SSH or in slow terminal emulators) and uses less CPU.

Steps to reproduce

  1. grep -rn maxFps source finds nothing, while node_modules/ink/build/ink.js:128 reads options.maxFps ?? 30.
  2. Render the real App with a fake terminal and a mock model that streams a 270-token answer. Count terminal writes per turn with Ink's default and with maxFps: 10.

Expected behaviour

A documented setting (for example nanocoder.ui.maxFps or --max-fps) that is passed to Ink. The default stays 30.

Actual behaviour

No such setting exists. Measured on latest main, 3 streamed turns per run, alternating 30 and 10, medians:

maxFps 30: terminal writes/turn 222   KB/turn 96   cpuMs/turn 1359
maxFps 10: terminal writes/turn  81   KB/turn 34   cpuMs/turn 1157
maxFps 30: terminal writes/turn 246   KB/turn 104  cpuMs/turn 1515
maxFps 10: terminal writes/turn  81   KB/turn 34   cpuMs/turn 1156

Writes and bytes drop by about 65%. CPU per turn dropped 15-24% in these two rounds. A fake terminal was used, so real terminal render time is not included, and I did not judge how smooth 10 fps feels.

Environment

  • OS: Windows 11 (10.0.26300)
  • Node: 22.22.3, Ink 6.8.0
  • Nanocoder: 1.31.0 (main at be428fc7)

Suggested fix

  • source/cli.tsx:979-997: add maxFps to the options object passed to render(). If PR #1788 merges first, the call moves to source/app/render-tui.tsx.
  • Add the preference in source/config/preferences.ts and source/types/config.ts, validate it (1-60), document it in docs/configuration/preferences.md.
  • Tests: preference parsing spec.

addyCooks avatar Oct 18 '26 06:10 addyCooks

Hi! @addyCooks , I'd like to work on this issue. Could you please assign it to me?

DarshanCodes09 avatar Oct 18 '26 06:10 DarshanCodes09

Go for it @DarshanCodes09 !

addyCooks avatar Oct 18 '26 06:10 addyCooks

Thanks for assigning me issue #1825, @addyCooks ! Could you please review PR #1838?

DarshanCodes09 avatar Oct 18 '26 15:10 DarshanCodes09