Repository navigation
Finish UTF-8 console on Delphi and add serve --debug request logging - #23
Merged
Merged
Conversation
EnableUTF8Console already set the Win32 console code pages but Delphi
still showed mojibake (▄▒▓) where FPC rendered the banner cleanly.
Root cause: Delphi's RTL caches a per-Text-file code page independently
of SetConsoleOutputCP. The UnicodeString -> bytes conversion in
WriteLn(Output, ...) used the cached value (the system ANSI CP), so
the bytes the console received were never UTF-8 even though it was
told to interpret them that way. Adding SetTextCodePage(Output,
CP_UTF8) and the same for ErrOutput finishes the fix. FPC's WriteLn
already emits the AnsiString-as-UTF-8 bytes verbatim, so the new
calls are guarded {\$IFNDEF FPC}.
Separately, give `pasclaw serve` a --debug / -d flag for diagnosing
clients that aren't getting expected responses through
/v1/chat/completions:
pasclaw serve --debug
flips the log level to debug and turns on a new DebugIO property on
TGatewayServer. With it on, the chat-completions handler logs the
full incoming body (with remote IP), the parsed (model, stream,
temperature, max_tokens), tool-loop result summary (iterations,
input/output tokens, finish reason, final content), and the response
body (or status code + reason on every early-return). The existing
'gateway: METHOD PATH' debug line lights up automatically.
https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two fixes:
1. UTF-8 console output under Delphi
EnableUTF8Consolealready calledSetConsoleCP/SetConsoleOutputCP(CP_UTF8)but the Delphi build still rendered banner / panel glyphs as mojibake while FPC printed them cleanly. Root cause: Delphi's RTL caches a per-Text-file code page independently of the Win32 console output CP. TheUnicodeString → bytesconversion inWriteLn(Output, ...)used the cached value (the system ANSI CP), so the bytes the console received were never UTF-8 even though it had been told to interpret them as such.Add the missing pair under
{$IFNDEF FPC}:FPC's
WriteLnemits the AnsiString-as-UTF-8 bytes verbatim, so the guards skip the Delphi-only step. Console banner, panel borders, and any other Unicode strings now render correctly incmd.exe/PowerShell.2.
pasclaw serve --debugfor diagnosing client integrationAdds a
--debug/-dflag toserve:DebugIOproperty onTGatewayServer.With
DebugIOon,/v1/chat/completionslogs:model,stream,temperature,max_tokens.iterations,input_tokens,output_tokens,finish_reason, finalcontent.The existing
gateway: METHOD PATHdebug line inOnCommandGetalso lights up automatically once the level is at debug.Test plan
█/╔/╚glyphs (not mojibake) incmd.exe, PowerShell, Windows Terminalpasclaw serve --debugboots; sending an OpenAI request prints body in/outpasclaw servewithout--debugkeeps the current quiet stdoutchat/completions -> 400 (invalid JSON))https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
Generated by Claude Code