Files
aiturk-mobil/app/src/test/java/com/m57/hermescontrol
M57andhy4ri 100a82dd4f feat(chat): port desktop tool display engine (ToolResultSummary + ToolViewBuilder) (#763)
* feat(chat): port desktop heuristic JSON summarizer engine

New com.m57.hermescontrol.ui.chat.tool.ToolResultSummary — a faithful
Kotlin port of the desktop app's lib/tool-result-summary.ts (verified
against its vitest suite, ported 1:1 to JUnit):

- formatToolResultSummary: wrapper unwrap (data/result/output/response/
  payload, up to 4 levels), priority-key ordering, array/record block
  formatting with depth caps, noise filtering (success:true etc.)
- extractToolErrorMessage: cycle-safe nested hunt for real error text
  through wrappers, with placeholder filtering (error:'none' ignored)
  and stderr deliberately excluded as an error signal

Also handles stringified-JSON payloads (re-parse on demand) like the
desktop's tryJson/norm layer.

Ported contract tests: ToolResultSummaryTest (10 cases).

* feat(chat): port desktop per-tool display engine (ToolViewBuilder)

Second half of the desktop engine port, in the new ui.chat.tool package:

- ToolView: the render model the builder produces — status/title/subtitle/
  detail/count/duration/stdout/stderr/exitCode/diff/searchHits/imageUrl —
  no raw JSON in UI code
- ToolViewBuilder: port of the desktop buildToolView (fallback-model):
  status heuristics (explicit success wins; non-zero exit alone is NOT an
  error), dynamic titles (Read/Searched/Ran with summarized commands),
  per-tool subtitle/detail (browser snapshot stats, terminal output
  preview, memory message, cron job counts), count-label cascade,
  web_search hit parsing, inline diff + stats, stdout/stderr split,
  duration formatting, redundant-detail suppression
- Mobile-specific tool cases carried into the builder: todo, fact_store,
  session_search, skills_list/view, skill_manage, process, x_search,
  vision_analyze, tool_search, image_generate, project_*, read_terminal,
  computer_use
- CommandSummarizer: port of the desktop summarize-command.ts (quote-aware
  compound split, pipe-tail strip, redirect/env cleanup)
- Terminal stdout reads the gateway's canonical merged `output` key with
  stdout/stderr fallback (mobile terminal_tool contract differs from
  desktop)

Tests: ToolViewBuilderTest (18), CommandSummarizerTest (8), all ported
or derived from the desktop suite. Full suite green: 655 tests.

---------

Co-authored-by: hy4ri <hy4ri@users.noreply.github.com>
2026-08-01 22:01:13 +03:00
..