Skip to content

refactor: render chat code blocks via CodeEditSourceEditor#1077

Merged
datlechin merged 1 commit into
mainfrom
worktree-pr-c-chat-code-blocks
May 7, 2026
Merged

refactor: render chat code blocks via CodeEditSourceEditor#1077
datlechin merged 1 commit into
mainfrom
worktree-pr-c-chat-code-blocks

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

PR C of the AI chat redesign (docs/refactor/ai-chat-redesign.md, row C).

  • Replaces the 340-line regex highlighter in AIChatCodeBlockView with a read-only CodeEditSourceEditor mount.
  • SQL, JavaScript (MongoDB), and Bash (Redis) blocks now use the same tree-sitter highlighter and TableProEditorTheme as the main SQL editor, so colors track theme and font settings automatically.
  • Drops the swiftlint:disable force_try suppression and the manually built NSAttributedString pipeline.
  • Header buttons (Copy / Insert) and the CodeBlockGroupBoxStyle chrome are unchanged. detectLanguage(from:) keeps its public test surface.

Net change: 61 insertions, 194 deletions.

Test plan

  • Open AI chat, ask for a SQL query, confirm tree-sitter highlighting matches the main editor.
  • Ask for a MongoDB db.collection.find(...) snippet, confirm JavaScript highlighting.
  • Ask for a Redis command, confirm bash highlighting renders.
  • Code block height grows with content and caps at 400px for long snippets.
  • Copy and Insert buttons still work; Insert is hidden for non-runnable languages.
  • swiftlint lint --strict clean on the changed file.
  • Existing AIChatCodeBlockDetectionTests still pass.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@datlechin datlechin merged commit 8f21bc8 into main May 7, 2026
2 checks passed
@datlechin datlechin deleted the worktree-pr-c-chat-code-blocks branch May 7, 2026 12:31
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