Repository navigation
Upgrade Delphi TUI with vendored MVCFramework.Console (Apache 2.0) - #24
Conversation
Adopts Daniele Teti's MVCFramework.Console as the rich rendering layer
for `pasclaw tui` on Delphi. FPC keeps the existing line-based ANSI
renderer untouched — both implementations live in PasClaw.TUI behind
{\$IFNDEF FPC} / {\$IFDEF FPC} guards and share the same TTUI class shape,
slash-command surface, and tool-loop wiring. Nothing about command
dispatch, config, providers, or tool registry changes.
Vendored under src/pkg/vendor/dmvcframework/ (Apache 2.0, attribution
preserved in NOTICE):
MVCFramework.Console.pas 2299 lines — themed boxes, tables,
menus, spinners, progress bars, color
primitives, cursor and console-size helpers
LoggerPro.AnsiColors.pas 252 lines — ANSI escape constants +
EnableANSIColorConsole (the one external
dep of MVCFramework.Console)
dmvcframework.inc 121 lines — compiler-version sentinels
(no IDE / FireDAC / DBX coupling at this
level — we use only the console unit)
The vendored files are added to PasClaw.dproj and the unit search path,
and the FPC Makefile's explicit UNIT_DIRS list does not include the
vendor directory, so FPC never tries to compile the Delphi-only sources
or resolve the WinApi.Windows / Posix.Termios uses they contain.
The .gitignore root rule `vendor/` (which exists to keep `make
get-indy`'s third-party Indy mirror out of the tree) is narrowed with
an `!src/pkg/vendor/` allow rule so this intentional bundle is tracked.
The Delphi TUI now uses:
WriteHeader('PasClaw provider/model tools:N', 80, Cyan)
Box('TUI commands', [...]) — boxed /help panel
Table(['#','tool'], rows, 'tools (N)') — boxed /tools listing
Spinner('thinking', ssDots, Cyan) — runs in a background thread
during RunToolLoop, hidden in a `finally` so exceptions don't
leave the spinner spinning
WriteSuccess / WriteWarning / WriteError / WriteInfo for status
WriteColoredText('you', Cyan) + ' > ' prompts
EnableUTF8Console + EnableANSIColorConsole at startup (the library
is idempotent; safe even after CliUI_Init already called the
Windows variant)
https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: edd9cac938
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| WriteWarning('no registry'); | ||
| Exit; | ||
| end; | ||
| Names := FRegistry.Names; |
There was a problem hiding this comment.
Qualify the registry array before assigning names
In the Delphi branch, adding MVCFramework.Console introduces a second TStringArray, so this unqualified local now binds to MVC's array type while TToolRegistry.Names still returns PasClaw.Tools.Registry.TStringArray. Delphi does not treat separately declared dynamic array types as assignment-compatible, so the Delphi TUI build fails as soon as this method is compiled; qualify the registry result or copy it into MVC's TStringArray before building the table.
Useful? React with 👍 / 👎.
| EnableUTF8Console; | ||
| EnableANSIColorConsole; | ||
| DrawHeader; | ||
| WriteColoredText('/help for commands, /quit to exit'#10, DarkGray); |
There was a problem hiding this comment.
Respect no-color mode in the Delphi TUI
For Delphi builds, this path bypasses PasClaw.CliUI.Ansi and unconditionally uses MVC color helpers, so pasclaw --no-color tui, NO_COLOR, or TERM=dumb still emits ANSI color sequences even though the root command advertises and initializes global no-color handling. Gate the MVC colored output/theme on CliUI_NoColor or use a non-color path for those environments.
Useful? React with 👍 / 👎.
Summary
Adopts Daniele Teti's
MVCFramework.Console(DMVCFramework) as the rich rendering layer forpasclaw tuion Delphi. FPC keeps the existing line-based ANSI renderer untouched — both implementations live inPasClaw.TUIbehind{$IFNDEF FPC}/{$IFDEF FPC}guards and share the sameTTUIclass shape, slash-command surface, and tool-loop wiring. Nothing about command dispatch, config, providers, or tool registry changes.Vendored (Apache 2.0)
src/pkg/vendor/dmvcframework/:MVCFramework.Console.pasLoggerPro.AnsiColors.pasEnableANSIColorConsole(the one external dep of MVCFramework.Console)dmvcframework.incNOTICEThe vendored files are wired into
PasClaw.dprojand the unit search path. FPC's Makefile has an explicitUNIT_DIRSlist that doesn't include the vendor directory, so it never tries to compile the Delphi-onlyWinApi.Windows/Posix.Termiosuses.The repo-root
.gitignorevendor/rule (formake get-indy's Indy mirror) is narrowed with!src/pkg/vendor/so this intentional bundle is tracked.Rich TUI uses
WriteHeader('PasClaw provider/model tools:N', 80, Cyan)Box('TUI commands', [...])— boxed/helppanelTable(['#','tool'], rows, 'tools (N)')— boxed/toolslistingSpinner('thinking', ssDots, Cyan)— runs in a background thread duringRunToolLoop, hidden in afinallyblock so exceptions don't leave it spinningWriteSuccess/WriteWarning/WriteError/WriteInfofor status messagesWriteColoredText('you', Cyan)+>promptsEnableUTF8Console+EnableANSIColorConsoleat startup — both idempotent and safe to call afterCliUI_Initalready did the Windows variantOn the
EnableUTF8Console/EnableANSIColorConsolenote from the articlePR #23 already added our own
EnableUTF8Console(with the extraSetTextCodePage(Output, CP_UTF8)Delphi needs). The vendored library's version is idempotent, so we call it again at TUI startup as belt-and-suspenders — the high-level functions (Box,Table,WriteHeader, etc.) also callEnableANSIColorConsoleinternally as the article promises, so we don't sprinkle that one through every call site.Test plan
pasclaw tuishows a boxed cyan header,/helpopens a styled box,/toolsrenders a bordered table, a dotted spinner animates during the LLM callMVCFramework.Console.pas(noWinApi.Windows/Posix.Termioserrors)https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
Generated by Claude Code