From 13ac45c203d5916d5aeb3c96c672ecf1dd21fc9e Mon Sep 17 00:00:00 2001 From: Hibryda Date: Wed, 11 Mar 2026 00:25:26 +0100 Subject: [PATCH] docs: update meta files for conflict detection enhancements session --- .claude/CLAUDE.md | 8 ++++---- CHANGELOG.md | 5 +++++ CLAUDE.md | 8 ++++---- TODO.md | 2 ++ docs/v3-progress.md | 26 ++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md index c6f79fb..4e7c9b6 100644 --- a/.claude/CLAUDE.md +++ b/.claude/CLAUDE.md @@ -5,7 +5,7 @@ - v1 is a single-file Python app (`bterminal.py`). Changes are localized. - v2 docs are in `docs/`. Architecture decisions are in `docs/task_plan.md`. - v2 Phases 1-7 + multi-machine (A-D) + profiles/skills complete. Extras: SSH, ctx, themes, detached mode, auto-updater, shiki, copy/paste, session resume, drag-resize, session groups, Deno sidecar, Claude profiles, skill discovery. -- v3 Mission Control (All Phases 1-10 Complete + S-1 Conflict Detection): project groups, workspace store, 12 Workspace components, session continuity, workspace teardown, file overlap conflict detection, dead v2 component cleanup. 170 vitest + 34 cargo tests. +- v3 Mission Control (All Phases 1-10 Complete + S-1 Conflict Detection): project groups, workspace store, 12 Workspace components, session continuity, workspace teardown, file overlap conflict detection (Bash writes, dismiss/acknowledge, worktree suppression), dead v2 component cleanup. 194 vitest + 34 cargo tests. - v3 docs: `docs/v3-task_plan.md`, `docs/v3-findings.md`, `docs/v3-progress.md`. - Consult Memora (tag: `bterminal`) before making architectural changes. @@ -53,9 +53,9 @@ - Notifications use ephemeral toast system: `notifications.svelte.ts` store (max 5, 4s auto-dismiss), `ToastContainer.svelte` display. Agent dispatcher emits toasts on agent complete/error/crash. - StatusBar → Mission Control bar: running/idle/stalled agent counts (color-coded), total $/hr burn rate, "needs attention" dropdown priority queue (up to 5 cards sorted by urgency score, click-to-focus), total tokens + cost. Uses health.svelte.ts store (not workspace store for health signals). - health.svelte.ts store: per-project health tracking via ProjectTracker map. ActivityState = inactive|running|idle|stalled (15-min stall threshold). Burn rate from 5-min EMA costSnapshots. Context pressure = tokens/model limit. File conflict count from conflicts.svelte.ts. Attention scoring: stalled=100, error=90, ctx>90%=80, file_conflict=70, ctx>75%=40. 5-second tick timer (auto-stop/start). API: trackProject(), recordActivity(), recordToolDone(), recordTokenSnapshot(), getProjectHealth(), getAttentionQueue(), getHealthAggregates(). -- conflicts.svelte.ts store: per-project file overlap detection. Records Write/Edit tool_call file paths per session. Detects when 2+ sessions write same file. recordFileWrite() returns true on new conflict → toast notification. clearSessionWrites() on agent completion. clearAllConflicts() on group switch. Session-scoped, no persistence. -- tool-files.ts utility: shared extractFilePaths(tc) → ToolFileRef[] and extractWritePaths(tc) → string[]. Used by ContextTab (all ops) and agent-dispatcher (writes only for conflict detection). -- ProjectHeader shows status dot (green pulse=running, gray=idle, orange pulse=stalled, dim=inactive) + file conflict badge (red "⚠ N conflicts") + context pressure badge (>90% red, >75% orange, >50% yellow) + burn rate badge ($/hr). Health prop from ProjectBox via getProjectHealth(). +- conflicts.svelte.ts store: per-project file overlap detection. Records Write/Edit/Bash-write tool_call file paths per session. Detects when 2+ sessions in same worktree write same file. Worktree-aware: sessions in different worktrees don't conflict. Dismissible: acknowledgeConflicts(projectId) suppresses badge until new session writes. recordFileWrite() returns true on new conflict → toast notification. clearSessionWrites() on agent completion. clearAllConflicts() on group switch. Session-scoped, no persistence. +- tool-files.ts utility: shared extractFilePaths(tc) → ToolFileRef[], extractWritePaths(tc) → string[], extractWorktreePath(tc) → string|null. Bash write detection via regex (>, >>, sed -i, tee, cp, mv). Used by ContextTab (all ops) and agent-dispatcher (writes + worktree tracking for conflict detection). +- ProjectHeader shows status dot (green pulse=running, gray=idle, orange pulse=stalled, dim=inactive) + file conflict badge (red clickable button with ✕ — acknowledgeConflicts on click) + context pressure badge (>90% red, >75% orange, >50% yellow) + burn rate badge ($/hr). Health prop from ProjectBox via getProjectHealth(). - session_metrics SQLite table: per-project historical session data (project_id, session_id, timestamps, peak_tokens, turn_count, tool_call_count, cost_usd, model, status, error_message). 100-row retention per project. Tauri commands: session_metric_save, session_metrics_load. Persisted on agent completion via agent-dispatcher. - Agent tree (AgentTree.svelte) uses SVG with recursive layout. Tree data built by `agent-tree.ts` utility from agent messages. - ctx integration opens `~/.claude-context/context.db` as SQLITE_OPEN_READ_ONLY — never writes. CtxDb uses Option for graceful absence if DB doesn't exist. diff --git a/CHANGELOG.md b/CHANGELOG.md index 2df1fab..55831eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Shared tool-files utility: extractFilePaths() and extractWritePaths() extracted from ContextTab to reusable module (tool-files.ts) - File conflict indicators: red "⚠ N conflicts" badge in ProjectHeader, conflict count in StatusBar, toast notification on new conflict, conflict cards in attention queue (ProjectHeader.svelte, StatusBar.svelte) - Health tick auto-stop/auto-start: tick timer self-stops when no running/starting sessions, auto-restarts on recordActivity() (health.svelte.ts) +- Bash write detection in tool-files.ts: BASH_WRITE_PATTERNS regex array covering >, >>, sed -i, tee, cp, mv, chmod/chown — conflict detection now catches shell-based file writes (tool-files.ts) +- Worktree-aware conflict suppression: sessions in different git worktrees don't trigger conflicts, sessionWorktrees tracking map, setSessionWorktree() API, extractWorktreePath() detects Agent/Task isolation:"worktree" and EnterWorktree tool calls (conflicts.svelte.ts, tool-files.ts, agent-dispatcher.ts) +- Acknowledge/dismiss conflicts: acknowledgeConflicts(projectId) suppresses badge until new session writes, acknowledgedFiles state map, auto-clear on new session write to acknowledged file (conflicts.svelte.ts) +- Clickable conflict badge in ProjectHeader: red button with ✕ calls acknowledgeConflicts() on click with stopPropagation, hover darkens background (ProjectHeader.svelte) +- `useWorktrees` optional boolean field on ProjectConfig for future per-project worktree spawning setting (groups.ts) ### Changed - AgentPane UI redesign: sans-serif root font (system-ui), tool calls paired with results in collapsible `
` groups, hook messages collapsed into compact labels, context window usage meter in status strip, cost bar made minimal (no background), session summary with translucent background, two-phase scroll anchoring, tool-aware output truncation (Bash 500/Read 50/Glob 20 lines), colors softened via `color-mix()`, responsive margins via container queries (AgentPane.svelte) diff --git a/CLAUDE.md b/CLAUDE.md index 7babaa6..8006cc6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -78,8 +78,8 @@ Terminal emulator with SSH and Claude Code session management. v1 (GTK3+VTE Pyth | `v2/src/lib/components/Workspace/ContextTab.svelte` | LLM context window visualization (stats, token meter, file refs, turn breakdown) | | `v2/src/lib/components/Workspace/CodeEditor.svelte` | CodeMirror 6 wrapper (15 languages, Catppuccin theme, save/blur callbacks) | | `v2/src/lib/stores/health.svelte.ts` | Project health store (activity state, burn rate, context pressure, file conflicts, attention scoring) | -| `v2/src/lib/stores/conflicts.svelte.ts` | File overlap conflict detection (per-project, session-scoped) | -| `v2/src/lib/utils/tool-files.ts` | Shared file path extraction from tool_call inputs (extractFilePaths, extractWritePaths) | +| `v2/src/lib/stores/conflicts.svelte.ts` | File overlap conflict detection (per-project, session-scoped, worktree-aware, dismissible) | +| `v2/src/lib/utils/tool-files.ts` | Shared file path extraction from tool_call inputs (extractFilePaths, extractWritePaths, extractWorktreePath) | | `v2/src/lib/components/StatusBar/StatusBar.svelte` | Mission Control bar (agent states, $/hr burn rate, attention queue, cost) | | `v2/src/lib/components/Notifications/ToastContainer.svelte` | Toast notification display | | `v2/src/lib/components/Workspace/` | v3 components: GlobalTabBar, ProjectGrid, ProjectBox, ProjectHeader, ClaudeSession, TeamAgentsPanel, AgentCard, TerminalTabs, ProjectFiles, FilesTab, SshTab, MemoriesTab, CommandPalette, DocsTab, SettingsTab | @@ -92,8 +92,8 @@ Terminal emulator with SSH and Claude Code session management. v1 (GTK3+VTE Pyth | `v2/src/lib/adapters/sdk-messages.test.ts` | Vitest tests for SDK message adapter (25 tests) | | `v2/src/lib/adapters/agent-bridge.test.ts` | Vitest tests for agent IPC bridge (11 tests) | | `v2/src/lib/agent-dispatcher.test.ts` | Vitest tests for agent dispatcher (29 tests) | -| `v2/src/lib/stores/conflicts.test.ts` | Vitest tests for conflict detection (19 tests) | -| `v2/src/lib/utils/tool-files.test.ts` | Vitest tests for tool file extraction (12 tests) | +| `v2/src/lib/stores/conflicts.test.ts` | Vitest tests for conflict detection (28 tests) | +| `v2/src/lib/utils/tool-files.test.ts` | Vitest tests for tool file extraction (27 tests) | | `v2/src/lib/stores/layout.test.ts` | Vitest tests for layout store (30 tests) | | `v2/src/lib/utils/agent-tree.test.ts` | Vitest tests for agent tree builder (20 tests) | | `v2/src/lib/stores/workspace.test.ts` | Vitest tests for workspace store (24 tests) | diff --git a/TODO.md b/TODO.md index 19ef4c5..b1a20f7 100644 --- a/TODO.md +++ b/TODO.md @@ -14,9 +14,11 @@ - [ ] **Agent provider adapter pattern** -- Abstract model interface (ProviderConfig, ProviderCapabilities) for multi-model support (Claude, Codex, Ollama). Rename agent-runner.mjs → claude-runner.mjs, capability gates in UI. - [ ] **S-1 Phase 2 — filesystem write detection** -- inotify-based file change detection (already have notify crate). PID attribution to distinguish BTerminal-managed vs external writes. Always-on red "write conflict" cards. - [ ] **S-2 — session anchors** -- Preserve first 5 turns / 2K tokens verbatim through checkpoint chains. Pin additional turns via AST conversation tree action. +- [ ] **Worktree spawning per project** -- useWorktrees field exists on ProjectConfig. Need UI toggle in SettingsTab and wiring to auto-spawn agents in git worktrees via Agent SDK isolation:"worktree". ## Completed +- [x] **Conflict Detection Enhancements (S-1 Phase 1.5)** -- Bash write detection (>, >>, sed -i, tee, cp, mv). Acknowledge/dismiss conflicts (clickable badge). Worktree-aware conflict suppression. useWorktrees ProjectConfig field. 194/194 tests. | Done: 2026-03-11 - [x] **File Overlap Conflict Detection (S-1 Phase 1)** -- conflicts.svelte.ts store tracks per-session Write/Edit file paths. Detects 2+ agents writing same file. Health attention score=70. Toast on conflict. Red badge in ProjectHeader + StatusBar. Shared tool-files.ts utility. 170/170 tests. | Done: 2026-03-10 - [x] **Project Health Dashboard (S-3)** -- health.svelte.ts store (activity state, burn rate, context pressure, attention scoring). Mission Control status bar (running/idle/stalled counts, $/hr, attention queue). ProjectHeader indicators (status dot, ctx%, $/hr). session_metrics SQLite table (100-row retention). Metric persistence on agent completion. | Done: 2026-03-10 - [x] **Context tab repurpose** -- Replaced ContextPane (ctx database viewer) with ContextTab (LLM context window visualization). Stats bar, segmented token meter, file references, turn breakdown. Tribunal debate (S-1-R4 at 82%). Token estimation via ~4 chars/token heuristic. | Done: 2026-03-10 diff --git a/docs/v3-progress.md b/docs/v3-progress.md index 144e341..03636aa 100644 --- a/docs/v3-progress.md +++ b/docs/v3-progress.md @@ -510,3 +510,29 @@ All editor themes map to the same `--ctp-*` CSS custom property names (26 vars). - [x] svelte-check: 0 new errors (only pre-existing esrap type errors) - [x] vitest: 139/139 tests pass - [x] cargo test: 34/34 pass + +### Session: 2026-03-11 — S-1 Phase 1.5: Conflict Detection Enhancements + +#### Bash Write Detection +- [x] BASH_WRITE_PATTERNS regex array in tool-files.ts: >, >>, sed -i, tee [-a], cp dest, mv dest, chmod/chown +- [x] extractBashWritePaths() helper with /dev/null and flag-target filtering +- [x] Write detection prioritized over read detection for ambiguous commands (cat file > out) +- [x] extractWritePaths() now captures Bash writes alongside Write/Edit + +#### Acknowledge/Dismiss Conflicts +- [x] acknowledgeConflicts(projectId) API in conflicts.svelte.ts — marks current conflicts as acknowledged +- [x] acknowledgedFiles Map state — suppresses badge until new session writes to acknowledged file +- [x] ProjectHeader conflict badge → clickable button with ✕ (stopPropagation, hover darkens) +- [x] Ack auto-cleared when new session writes to previously-acknowledged file + +#### Worktree-Aware Conflict Suppression +- [x] sessionWorktrees Map in conflicts store — tracks worktree path per session (null = main tree) +- [x] setSessionWorktree(sessionId, path) API +- [x] areInDifferentWorktrees() / hasRealConflict() — suppresses conflicts between sessions in different worktrees +- [x] extractWorktreePath(tc) in tool-files.ts — detects Agent/Task isolation:"worktree" and EnterWorktree +- [x] agent-dispatcher.ts wiring: registers worktree paths from tool_call events +- [x] useWorktrees?: boolean field on ProjectConfig (groups.ts) for future per-project setting + +#### Verification +- [x] vitest: 194/194 tests pass (+24 new: 5 extractWorktreePath, 10 bash write, 9 acknowledge/worktree) +- [x] cargo test: 34/34 pass