mirror of
https://github.com/Louis-CFM/coucou.git
synced 2026-12-07 07:32:35 +09:00
* feat: live diff — see file changes in the notch as Claude edits - DiffEngine.swift (Foundation-only): LCS-based line diff with 3-line context hunks, 200 KB / 4000-line size guards, CRLF normalization; handles Edit, MultiEdit and Write tool inputs. String.makeDiffStep/parseDiffStep encode diff step metadata in a private-use prefix so TickerRowView can detect them - HookServer: PostToolUse for Edit/MultiEdit/Write builds and stores a FileDiff in AppState.sessionDiffs[pillId], then appends a diff step. SessionEnd clears the session; 1-hour inactivity timer auto-expires diffs - TickerRowView: diff steps render filename + "+N" (green #22C55E) + "−M" (red #F4505E), small monospaced — all other steps unchanged - TickerView: tap on a diff step fires onDiffTap callback with the step index - OverviewView: diff overlay (DiffCardView) replaces the ticker in the left card when a diff step is tapped; Escape or ← dismisses it - DiffCardView: scrollable monospaced diff lines (10.5 pt), ±12% background, header with filename + totals + ↗ (code -g path:line or NSWorkspace) - FinishedView: lists up to 4 touched files with +/− totals below the buttons; tapping a file opens its DiffCardView - Tests: 38 assertions across 11 groups; all 6 test scripts pass Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: diff tap on integration pills, static final line after Stop Bug 1 — diff step taps now work on both the current and completed ticker rows for all pills (including integration pills like integration_claude). IntegrationCardView gains an onDiffTap callback wired from OverviewView; TickerView passes per-row closures computed from the row text rather than a single global tap; activeDiffStep renamed to activeDiffIdx and stores the sessionDiffs index directly so it survives appendStep's 20-step cap. Diff card also closes on view/mode change. Bug 2 — after Stop the ticker shows the last assistant message as static text (#C9CDD4, no shimmer, checkmark icon) until a new turn starts. DiffEngine.toOneLine strips Markdown and collapses whitespace; Stop reads last_assistant_message (fallback message), calls toOneLine, appendStep and sets AgentTask.finalLine. finalLine is cleared on SessionStart, UserPromptSubmit, PreToolUse and SessionEnd. TickerRowView gates shimmer and chevron on isActive (thinking || working). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: stable diff ids, memory cap, ticker polish, Write jump, CI step 1. Stable diff ids: FileDiff gains an `id` int assigned by AppState from a monotonically-increasing counter (nextDiffId) that is never reset across sessions. appendSessionDiff sets and returns this id; the step marker encodes diffId instead of a transient array index. Lookup is now first(where: { \$0.id == diffId }) — tapping a step whose diff was evicted is a no-op. 2. Memory cap: appendSessionDiff keeps at most 50 diffs per pill (oldest evicted first). DiffEngine.fromNew applies the same 200 KB / 4 000-line limit as fromEdit (tooLarge, no hunks, line count preserved). 3. Ticker non-active style: staticColor (#C9CDD4) only when !isActive && phase < 0.5 (current row); the completed row above keeps #6B7079. 4. FinishedView main text: finalLine ?? last non-diff step ?? "Session finished". Never shows a \u{E001}-prefixed diff marker string. 5. DiffCardView ↗ button: /opt/homebrew/bin/code added first; Write opens `code -g file:1`, Edit/MultiEdit opens `code file`. firstChangedLine removed from FileDiff (no longer used). 6. fromEdit perf guard: m*n > 1_000_000 triggers countFallback (tooLarge). 7. CI: "Diff engine tests" step added to build.yml. Tests: new cases for m*n blowup, fromNew tooLarge, diffId > 9 round-trip. Docs: INTEGRATIONS.md corrected for Write semantics and 50-diff cap. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
9 lines
305 B
Bash
Executable File
9 lines
305 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
TEST_DIR="$(mktemp -d "${TMPDIR:-/tmp}/coucou-diff-engine.XXXXXX")"
|
|
trap 'rm -rf "$TEST_DIR"' EXIT
|
|
swiftc NotchBuddy/Sources/App/DiffEngine.swift \
|
|
tests/DiffEngineTests.swift -o "$TEST_DIR/diff-engine-tests"
|
|
"$TEST_DIR/diff-engine-tests"
|