feat: Real-time Git Status Integration (#8)

* feat: implement real-time git status integration

- Add workspace tracker to monitor git changes every 2 seconds
- Implement WebSocket streaming for git status updates
- Add database persistence for git status in agent session metadata
- Compute diffs backend-side with additions/deletions per file
- Integrate git status into frontend UI (top bar, files panel, changes panel)
- Display real-time ahead/behind commits and line changes
- Show file diffs with syntax highlighting in task view
- Add retry logic for WebSocket connections during reconciliation
- Fix context lifecycle issue in workspace tracker

* refactor: remove debug and unnecessary logging

- Remove debug logs from workspace tracker
- Remove info logs from WebSocket handlers
- Remove verbose git status update logs
- Keep only essential error logs

* fix: compare git diff against remote branch instead of HEAD

- Changed git diff comparison from HEAD to remote tracking branch
- Now shows all changes including committed files that haven't been pushed
- Files committed locally but not pushed will appear in the diff
- Falls back to HEAD if no remote branch is configured

* fix: prevent stale git status when switching tasks

- Clear git status when switching to a new task
- Only accept git.status WebSocket updates for the current task
- Prevents showing git data from previous task when switching

* refactor: remove unused diff stream client code

- Remove diffConn field from agentctl Client struct
- Remove StreamDiff() method (never called)
- Remove CloseDiffStream() method
- Remove DiffUpdate type from client.go
- All diff data is already included in GitStatusUpdate.Files
- Keep server-side diff endpoint in agentctl for potential future use

* refactor: remove unused diff stream server-side code

- Remove /workspace/diff/stream endpoint from agentctl API
- Remove handleDiffStreamWS handler
- Remove DiffUpdate type from workspace_tracker.go
- Remove DiffSubscriber type
- Remove updateDiff() and getDiff() methods
- Remove SubscribeDiff(), UnsubscribeDiff() methods
- Remove notifyDiffSubscribers() method
- Remove GetCurrentDiff() method
- Remove currentDiff field and diffSubscribers map
- All diff data is already included in GitStatusUpdate.Files

* refactor: remove unused output stream code

- Remove /output and /output/stream endpoints from agentctl API
- Remove handleGetOutput and handleOutputStreamWS handlers
- Delete output.go file entirely
- Remove OutputBuffer and related code (buffer.go deleted)
- Remove outputConn field from agentctl Client
- Remove StreamOutput() and CloseOutputStream() methods
- Remove OutputLine type from client.go
- Remove OutputBufferSize config option
- Update readStderr to just log instead of buffering

Output data flows through ACP stream (StreamUpdates) which includes
all session notifications. The separate output stream was never used.
This commit is contained in:
João Salavisa
2026-01-12 23:44:29 +00:00
committed by GitHub
parent c5eac3551a
commit a1013342a3
26 changed files with 1643 additions and 438 deletions
@@ -757,6 +757,13 @@ func (r *SQLiteRepository) AddTaskToBoard(ctx context.Context, taskID, boardID,
VALUES (?, ?, ?, ?)
ON CONFLICT(task_id, board_id) DO UPDATE SET column_id = excluded.column_id, position = excluded.position
`, taskID, boardID, columnID, position)
if err != nil {
return err
}
// Also update the column_id in the tasks table so GetTask returns the correct column
_, err = r.db.ExecContext(ctx, `
UPDATE tasks SET column_id = ?, position = ?, updated_at = ? WHERE id = ?
`, columnID, position, time.Now().UTC(), taskID)
return err
}
@@ -776,11 +783,18 @@ func (r *SQLiteRepository) addTaskToBoardTx(ctx context.Context, tx *sql.Tx, tas
return err
}
_, err := tx.ExecContext(ctx, `
if _, err := tx.ExecContext(ctx, `
INSERT INTO task_columns (task_id, board_id, column_id, position)
VALUES (?, ?, ?, ?)
ON CONFLICT(task_id, board_id) DO UPDATE SET column_id = excluded.column_id, position = excluded.position
`, taskID, boardID, columnID, position)
`, taskID, boardID, columnID, position); err != nil {
return err
}
// Also update the column_id in the tasks table so GetTask returns the correct column
_, err := tx.ExecContext(ctx, `
UPDATE tasks SET column_id = ?, position = ?, updated_at = ? WHERE id = ?
`, columnID, position, time.Now().UTC(), taskID)
return err
}
@@ -914,6 +928,21 @@ func (r *SQLiteRepository) GetColumn(ctx context.Context, id string) (*models.Co
return column, err
}
// GetColumnByState retrieves a column by board ID and state
func (r *SQLiteRepository) GetColumnByState(ctx context.Context, boardID string, state v1.TaskState) (*models.Column, error) {
column := &models.Column{}
err := r.db.QueryRowContext(ctx, `
SELECT id, board_id, name, position, state, color, created_at, updated_at
FROM columns WHERE board_id = ? AND state = ?
`, boardID, state).Scan(&column.ID, &column.BoardID, &column.Name, &column.Position, &column.State, &column.Color, &column.CreatedAt, &column.UpdatedAt)
if err == sql.ErrNoRows {
return nil, fmt.Errorf("column not found for board %s with state %s", boardID, state)
}
return column, err
}
// UpdateColumn updates an existing column
func (r *SQLiteRepository) UpdateColumn(ctx context.Context, column *models.Column) error {
column.UpdatedAt = time.Now().UTC()