[Feature] Add an option to limit the TUI frame rate (Ink maxFps) for slow terminals and weak CPUs
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
grep -rn maxFps sourcefinds nothing, whilenode_modules/ink/build/ink.js:128readsoptions.maxFps ?? 30.- Render the real
Appwith a fake terminal and a mock model that streams a 270-token answer. Count terminal writes per turn with Ink's default and withmaxFps: 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: addmaxFpsto the options object passed torender(). If PR #1788 merges first, the call moves tosource/app/render-tui.tsx.- Add the preference in
source/config/preferences.tsandsource/types/config.ts, validate it (1-60), document it indocs/configuration/preferences.md. - Tests: preference parsing spec.
Hi! @addyCooks , I'd like to work on this issue. Could you please assign it to me?
Go for it @DarshanCodes09 !
Thanks for assigning me issue #1825, @addyCooks ! Could you please review PR #1838?