♻️ refactor: unify tool content formatting with ComputerRuntime and shared UI#13470
♻️ refactor: unify tool content formatting with ComputerRuntime and shared UI#13470
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@canisminor1990 @ONLY-yours - This refactor unifies tool content formatting with new |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## canary #13470 +/- ##
==========================================
- Coverage 66.48% 66.48% -0.01%
==========================================
Files 1972 1973 +1
Lines 160184 160229 +45
Branches 18340 18342 +2
==========================================
+ Hits 106504 106530 +26
- Misses 53560 53579 +19
Partials 120 120
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 049e6144e4
ℹ️ 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".
…hared UI components Introduce `@lobechat/tool-runtime` with `ComputerRuntime` abstract class to ensure consistent content formatting (via `formatCommandResult`, `formatFileContent`, etc.) across local-system, cloud-sandbox, and skills packages. Create `@lobechat/shared-tool-ui` to share Render and Inspector components, eliminating duplicated UI code across tool packages. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…m denormalization - Add legacy state field mappings in local-system executor (listResults, fileContent, searchResults) for backward compatibility with existing render components - Add denormalizeParams in LocalSystemExecutionRuntime to map ComputerRuntime params back to IPC-expected field names (file_path, items, shell_id, etc.) - Fix i18n type casting for dynamic translation keys in shared-tool-ui inspectors Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
839c6f5 to
f6ba25b
Compare
…e for cross-package render reuse - Add ToolRenderContext with injectable capabilities (openFile, openFolder, isLoading, displayRelativePath) to shared-tool-ui - Update local-system render components (ReadLocalFile, ListFiles, SearchFiles, MoveLocalFiles, FileItem) to use context instead of direct Electron imports - Enrich ReadFileState with render-compatible fields (filename, fileType, charCount, loc, totalCharCount) - Cloud-sandbox now fully reuses local-system renders — renders degrade gracefully when capabilities are not provided (no open file buttons in sandbox) - Remove executor-level state mapping hacks Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… GlobFiles
- SearchFiles: ensure results is always an array (not object passthrough)
- GrepContent: update formatGrepResults to support object matches
`{path, content, lineNumber}` alongside string matches
- MoveFiles: render now handles both IPC format (items/oldPath/newPath) and
ComputerRuntime format (operations/source/destination)
- GlobFiles: fallback totalCount to files.length when API returns 0
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
SearchLocalFiles inspector now supports all keyword field variants (keyword, keywords, query) and reads from unified state (results/totalCount). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- EditLocalFile render: support both file_path (IPC) and path (sandbox) args - SearchFiles render: support keyword/keywords/query arg variants - FileItem: derive name from path when not provided Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🚀 Desktop App Build Completed!Version: 📦 Release Download · 📥 Actions Artifacts Build Artifacts
Warning Note: This is a temporary build for testing purposes only. |
|
❤️ Great PR @arvinxx ❤️ The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world. |
💻 Change Type
🔗 Related Issue
N/A
🔀 Description of Change
Problem: Tool content formatting was inconsistent across
local-system,cloud-sandbox, andskillspackages:local-systemusedformatCommandResult()forrunCommandcloud-sandboxusedJSON.stringify()forrunCommand,grepContent,getCommandOutput,killCommandskillsused plain text concatenation forrunCommandInspector and Render components were duplicated across all three packages with 90%+ identical code.
Solution:
New
@lobechat/tool-runtimepackage —ComputerRuntimeabstract class that unifies content formatting via@lobechat/promptsformat functions. Subclasses only implementcallService():CloudSandboxExecutionRuntime extends ComputerRuntimeLocalSystemExecutionRuntime extends ComputerRuntime(new)SkillsExecutionRuntimeusesformatCommandResult()directlyNew
@lobechat/shared-tool-uipackage — Shared Render and Inspector components:RunCommandRender— unified render used by all 3 packagescreateXxxInspector(translationKey)factories for RunCommand, EditLocalFile, ReadLocalFile, WriteLocalFile, ListLocalFiles, GlobLocalFiles, GrepContentFilePathDisplaycomponent and inspector stylesState types unified — Flat state types (
RunCommandState,GlobFilesState, etc.) defined once in@lobechat/tool-runtime, re-exported by each package🧪 How to Test
Verified via:
bun run type-check)runCommandtool renders correctly in both environments with consistent formatting📝 Additional Information
Breaking changes: State shape for local-system inspector components changed from nested (
pluginState.result.output) to flat (pluginState.output). This only affects the internal tool rendering — no public API changes.