agentscope-ai / agentscope-ai/QwenPaw
[Feature]: Syntax highlighting for code files in the Files panel Preview mode
- Vorherrschende Sprache
- Python
- Sterne
- 34.9k
- Forks
- 3.1k
- Ø Merge
- 1 T. 15 Std.
- Gemergte PRs (30 T.)
- 225
Beschreibung
## Summary
Render code files in the Files panel **Preview** mode with syntax highlighting (read-only Monaco or a lightweight highlighter) instead of a single-colour `
` block, and ideally allow choosing a highlight theme.## Component(s) Affected
- [ ] Core / Backend (app, agents, config, providers, utils, local_models)
- [x] Console (frontend web UI)
- [ ] Channels (DingTalk, Feishu, QQ, Discord, iMessage, etc.)
- [ ] Skills
- [ ] CLI
- [ ] Documentation (website)
- [ ] Tests
- [ ] CI/CD
- [ ] Scripts / Deploy## Problem / Motivation
In the Files drawer, the **Preview** tab renders any `preview_kind === "text"` file as a plain `
{content}` — one flat foreground colour for keywords, strings, comments and identifiers alike. Reading a 200-line Python or JS file in that view is genuinely hard, and it looks broken next to the rest of the polished console. Meanwhile the **Edit** tab of the same drawer already mounts full Monaco with language detection, so the capability (and the ~4 MB `editor-vendor` bundle) is already shipped; only the Preview path misses out.## Proposed Solution
1. In the Preview branch (currently the `
` fallback next to the `preview_kind === "text"` check), render the content with the already-bundled Monaco in **read-only** mode (`readOnly: true`, no cursor/edits, minimap off), reusing the same language mapping the Edit tab uses from the file extension.
2. If a full Monaco mount per preview is considered too heavy, fall back to a lightweight tokenizer (e.g. shiki with a small grammar subset, or `highlight.js`) producing static highlighted HTML — no editor instance needed.
3. Optionally expose a highlight-theme setting (the Edit tab currently hardcodes `theme: darkMode ? "vs-dark" : "light"`); a small theme picker (or respecting a custom theme registered via `monaco.editor.defineTheme`) would let users match the editor to their console theme.
4. Keep the existing `` path as the fallback for very large files (e.g. > 1 MB) where tokenizing would be wasteful.## Alternatives Considered
- Telling users to click **Edit** to see colours: works today but Edit is an editor (risk of accidental edits, diff markers, save flow) — wrong tool for "just look at this file".
- CSS-only tricks: not viable without tokenization.
- Patching the bundled console JS locally: fragile, breaks every update (I currently do this privately and would love to delete the patch).## Additional Context
Observed on QwenPaw Desktop 2.2.1b1 (Windows). Relevant code: the preview renderer's `preview_kind === "text" ?
: …` branch and the Edit tab's Monaco mount with `theme: ? "vs-dark" : "light"` in the `TabbedEditor` component chunk. Screenshot of the flat Preview available on request.## Willing to Contribute
- [x] I am willing to open a PR for this feature (after discussion).
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.