Skip to content

feat: paste detection in chat — collapsible code attachments#582

Merged
ShaerWare merged 1 commit intomainfrom
feat/paste-detection-chat
Mar 16, 2026
Merged

feat: paste detection in chat — collapsible code attachments#582
ShaerWare merged 1 commit intomainfrom
feat/paste-detection-chat

Conversation

@ShaerWare
Copy link
Owner

Summary

  • Paste detection: when pasting large text (≥5 lines or ≥500 chars) into chat textarea, it's intercepted and shown as a removable chip with auto-detected language (~17 languages: Python, TS, JS, PHP, Go, Rust, SQL, etc.)
  • Fenced code blocks on send: pasted blocks are wrapped as ```lang ... ``` in message content — no backend changes needed
  • Collapsible code blocks: user messages containing code blocks render with 200px max-height and gradient fade, click to expand
  • Admin + Mobile: identical pasteDetect utility in both apps, chips UI themed for each (admin: primary colors, mobile: night-eyes amber/stone)
  • Mobile message actions: edit, summarize branch, regenerate, delete — wired up to existing API endpoints
  • Mobile chat API: added editMessage, summarizeBranch, regenerateResponse methods
  • Systemd service: updated to use start_gpu.sh with proper kill/timeout signals
  • i18n: pastedLines + removePasted keys in ru/en/kk

NEWS

📎 Умная вставка кода в чат

Теперь при вставке большого текста (код, логи, конфиги) в чат — он
автоматически определяется как вложение с языком программирования
(Python, TypeScript, SQL и ещё ~15 языков). Вложение отображается
как компактный чип, который можно удалить до отправки. В истории
чата код показывается в сворачиваемом блоке — как в Claude.ai.
Работает и в админке, и в мобильном приложении.

Test plan

  • Admin chat: paste a Python snippet (>5 lines) → appears as chip with "Python" label, not in textarea
  • Admin chat: send with only paste, no typed text → message sent with fenced code block
  • Admin chat: paste small text (<5 lines) → normal paste behavior
  • Admin chat: multiple pastes → multiple chips, each removable
  • Admin chat: code block in user message → collapsible with gradient, click to expand
  • Admin CC mode: same paste behavior works
  • Mobile: paste large text → chip appears above textarea
  • Mobile: user message with code block renders with markdown
  • Mobile: message action buttons (edit, summarize, regenerate, delete) work
  • Build: cd admin && npm run build
  • Build: cd mobile && npm run build

🤖 Generated with Claude Code

When a user pastes a large text block (≥5 lines or ≥500 chars) into the
chat textarea, it's intercepted and shown as a removable chip with
auto-detected language. On send, pasted blocks are wrapped as fenced
markdown code blocks. User messages containing code blocks render with
collapsible preview (200px max-height with gradient fade).

Also: mobile message actions (edit, summarize, regenerate, delete),
mobile chat API methods, systemd service updated to use start_gpu.sh.

Admin: pasteDetect utility, ChatView paste handling + chips UI + CSS.
Mobile: ChatInput paste handling + chips, MessageBubble markdown render.
i18n: pastedLines + removePasted keys in ru/en/kk.

## NEWS

📎 **Умная вставка кода в чат**

Теперь при вставке большого текста (код, логи, конфиги) в чат — он
автоматически определяется как вложение с языком программирования
(Python, TypeScript, SQL и ещё ~15 языков). Вложение отображается
как компактный чип, который можно удалить до отправки. В истории
чата код показывается в сворачиваемом блоке — как в Claude.ai.
Работает и в админке, и в мобильном приложении.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ShaerWare ShaerWare merged commit 79205a0 into main Mar 16, 2026
3 checks passed
@ShaerWare ShaerWare deleted the feat/paste-detection-chat branch March 16, 2026 12:59
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.

1 participant