Skip to content

Add syntax highlighting and anonymous telemetry to inline diffs#2

Merged
tyulyukov merged 1 commit intomainfrom
marcode/work-log-diff-preview
Mar 27, 2026
Merged

Add syntax highlighting and anonymous telemetry to inline diffs#2
tyulyukov merged 1 commit intomainfrom
marcode/work-log-diff-preview

Conversation

@tyulyukov
Copy link
Copy Markdown
Owner

Summary

  • Syntax highlighting for inline diffs: Integrated @pierre/diffs with Shiki-JS for language-aware code highlighting in diff previews
  • Context-aware line trimming: Intelligently truncates long lines while preserving readability and diff markers
  • Anonymous telemetry infrastructure: Added PostHog-based event collection with user identification (Codex/Claude account hash, or installation-scoped anonymous ID)
  • Telemetry instrumentation: Records provider lifecycle events (session start/recover, turns, interrupts) and server startup metrics (thread/project counts)
  • Responsive theme support: Diff highlighting respects app theme (light/dark mode)

Testing

  • bun run test — AnalyticsService layer test verifies batch flushing across multiple requests (45 events across 3 batches)
  • bun run test — ProviderService tests verify telemetry records fire on session/turn/interrupt/stop operations
  • bun run test — Main startup heartbeat test verifies thread/project count telemetry
  • bun fmt, bun lint, bun typecheck — All pass
  • Syntax highlighting tested manually with TypeScript, Python, and unsupported languages fallback to plaintext

- Add @pierre/diffs integration for language-aware syntax highlighting
- Support dark/light theme switching for highlighted code
- Implement smart context trimming: shows changed lines + 3-line radius context
- Insert separators (···) between omitted context gaps
- Calculate diff stats from full diff before line truncation
- Fix timestamp formatting to use 2-digit hours for consistency
@tyulyukov tyulyukov merged commit 8d334ab into main Mar 27, 2026
tyulyukov added a commit that referenced this pull request Apr 24, 2026
Upstream pingdotgg#2292 added the "restarts the provider session when the thread
workspace changes" test using the hardcoded path "/tmp/provider-project-worktree".
MarCode's ProviderCommandReactor (line 302) auto-archives threads whose
worktree directory is missing on disk — so the non-existent path short-circuits
the session restart and the test times out waiting for startSession call #2.

Use mkdtempSync for a real dir that exists during the test, clean up in finally.
This preserves MarCode's missing-worktree auto-archive behavior (MEMORY.md:
"Handle missing worktree directories gracefully #54e6ddc2") while still
exercising the workspace-change restart path.
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