Skip to content

ToolView: hex byte glyph constants per compiler (fixes TestArgTruncation) - #162

Merged
FMXExpress merged 1 commit into
mainfrom
claude/toolview-glyph-constants
Jun 6, 2026
Merged

FMXExpress merged 1 commit into
mainfrom
claude/toolview-glyph-constants

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

Summary

Closes the last remaining red test on make test. After PR #161 fixed JSON UTF-8 byte preservation at the parse boundary, the only failure left was toolview_tests.TestArgTruncation — the unrelated ellipsis-glyph mojibake noted in #161's PR body.

The fault: ToolView opens with {$CODEPAGE UTF8} so its '…' and '✗' literals are tagged CP_UTF8, but the JSON-parsed Summary strings they get concatenated with arrive tagged CP_0 (system default). FPC's mixed-codepage concat trap strips every UTF-8 lead byte the destination CP can't represent, leaving ? characters in the user-visible output. Same exact class as PR #157's box-drawing-glyph fix in PasClaw.Markdown.Render.

Fix

Same shape as PR #157 — replace each non-ASCII glyph literal with a per-compiler hex byte constant:

Codepoint Glyph FPC bytes Delphi
U+23FA ⏺ E2 8F BA #$23FA
U+23BF ⎿ E2 8E BF #$23BF
U+2026 … E2 80 A6 #$2026
U+2717 ✗ E2 9C 97 #$2717

Promoted the inline '…' and '✗' literals into named TV_ELLIPSIS / TV_ERROR_GLYPH constants alongside the existing TV_CALL_GLYPH / TV_RESULT_GLYPH so all four codepoints live in one place and the IFDEF guards aren't sprinkled through the call sites.

Tests pick their assertion literal the same way ({$IFDEF FPC} three-byte form, else single WideChar) so the assertions are codepage-tag-independent.

Test plan

  • make test-toolview — PASS (was FAIL: long argument is ellipsized)
  • Byte-dump confirms wire output on FPC: ⏺ → E2 8F BA, … → E2 80 A6, ⎿ → E2 8E BF, ✗ → E2 9C 97. No mojibake.
  • make test is now fully green for the first time — smoke + hashline + toolview + anthropic-server-tools + openai-server-tools + println-helper + utf8-codepage-tag + gemini-schema-strip + markdown-render + json-utf8-roundtrip all OK.
  • Delphi build — same per-compiler pattern PR Markdown render: use hex byte constants for box-drawing glyphs (fix ──── mojibake) #157 used; #$23FA etc. are single WideChars natively, WriteConsoleW and TEncoding.UTF8.GetBytes both handle them losslessly.

Generated by Claude Code

TestArgTruncation has been red since the unit landed: the `'…'`
literal in Ellipsize and the `'✗'` literal in FormatToolResultLine
get clipped to `?` when concatenated with strings carrying a
different codepage tag. ToolView opens with `{$CODEPAGE UTF8}` so
its literals are tagged CP_UTF8, but JSON-parsed Summary strings
arrive tagged CP_0 (system default); the mixed-codepage concat trap
strips every UTF-8 lead byte that the destination CP can't
represent.

Same class of bug PR #157 fixed for PasClaw.Markdown.Render's
box-drawing glyphs. Same fix shape: replace the literals with
per-compiler hex byte constants that are codepage-agnostic.

  FPC mode delphi (string = AnsiString, Char = AnsiChar)
    raw UTF-8 byte sequence — bytes go on the wire as-is, no
    transcode triggers.

  Delphi (string = UnicodeString, Char = WideChar)
    single WideChar at the Unicode codepoint — WriteConsoleW
    renders it directly, TEncoding.UTF8 encodes it to the same
    UTF-8 bytes for redirected stdout.

Glyph table:
  TV_CALL_GLYPH    U+23FA ⏺  E2 8F BA
  TV_RESULT_GLYPH  U+23BF ⎿  E2 8E BF
  TV_ELLIPSIS      U+2026 …  E2 80 A6
  TV_ERROR_GLYPH   U+2717 ✗  E2 9C 97

Promoted the inline `'…'` and `'✗'` literals to named constants
alongside the existing TV_CALL_GLYPH / TV_RESULT_GLYPH so the four
codepoints live in one place and the compiler-split guards aren't
sprinkled through the call sites.

toolview_tests.TestArgTruncation and TestResultError pick their
assertion literal the same way — IFDEF FPC chooses the 3-byte UTF-8
form, ELSE the single WideChar — so the test isn't tied to a
codepage tag either.

Byte-dump on Linux+FPC confirms the wire output is exactly
E2 8F BA / E2 80 A6 / E2 8E BF / E2 9C 97 — no mojibake.

Full make test on Linux/FPC is now ALL GREEN for the first time:
smoke, hashline, toolview, anthropic-server-tools,
openai-server-tools, println-helper, utf8-codepage-tag,
gemini-schema-strip, markdown-render, json-utf8-roundtrip.
@FMXExpress
FMXExpress merged commit 5ea7b2d into main Jun 6, 2026
khongten001 pushed a commit to khongten001/PasClaw that referenced this pull request Jul 13, 2026
Cross-referenced MakerAi's provider list against our 19-entry
catalog. The user-listed model families fall into three buckets:

  Already covered as MODEL names within an existing entry —
    Claude (anthropic), Gemini (gemini), Mistral (mistral),
    Groq (groq), Kimi (moonshot), DeepSeek (deepseek). Operator
    sets the specific model on the per-config line; no catalog
    change needed for these.

  Missing AS PROVIDERS (this commit) — xAI/Grok, Cohere.

  Already in the catalog with a stale default — Moonshot's default
    was moonshot-v1-32k (Kimi V1 generation, deprecated). Bumped
    to kimi-k2 which is what current MakerAi configs use and what
    the user listed first under Kimi.

xAI ships a strict OpenAI-compatible chat-completions endpoint at
https://api.x.ai/v1/chat/completions with Bearer auth. The existing
pfOpenAI provider talks to it unchanged — just a new catalog row.
Default model grok-4-fast; operator can override to grok-3 /
grok-code-fast-1 / grok-2 etc. via config or onboarding.

Cohere v2 ships its chat API at https://api.cohere.com/v2/chat —
same Bearer auth as OpenAI but a different URL path
(/v2/chat vs /v1/chat/completions). PasClaw.Providers.OpenAI
hard-codes the OpenAI path, so Cohere can't piggyback without
making the path configurable. Landed as pfPlaceholder so:

  - The kind validates in config.json,
  - It appears in `pasclaw onboard` like every other provider,
  - Selecting it surfaces the existing pfPlaceholder error
    ("Cohere is in the catalog but its protocol implementation is
    not yet bundled in this build") instead of a confusing 404 at
    request time.

Future PR can add a dedicated TCohereProvider that mirrors the v2
wire shape (messages array, tool_calls similar to OpenAI but with
the citations / search_queries surfaced on assistant turns).

Also tightened the catalog notes column on three rows where the
displayed model list was outdated next to the user's current
generation (Groq → Llama-4 / Kimi K2 / Qwen3 / compound-beta,
Mistral → Magistral / Devstral / Voxtral added, Gemini → Gemini 3
generation).

Verified:
  - Catalog size 21 (was 19).
  - LookupProvider('xai') / LookupProvider('cohere') resolve with
    the right Kind / Family / DefaultBase / DefaultModel.
  - NewProviderFromConfig('xai') constructs a working
    TOpenAIProvider with default model grok-4-fast.
  - NewProviderFromConfig('cohere') returns False with the clean
    pfPlaceholder ErrMsg.
  - All unrelated test suites still green (test-hashline,
    test-anthropic-server-tools, test-openai-server-tools,
    test-println-helper, test-utf8-codepage-tag,
    test-gemini-schema-strip, test-markdown-render,
    test-json-utf8-roundtrip). test-toolview is the pre-existing
    ellipsis-glyph mojibake (fixed in PR FMXExpress#162, not yet merged).
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