Skip to content

Comments

Add real-time session event monitoring to execution screen#12

Draft
Copilot wants to merge 8 commits intomainfrom
copilot/add-realtime-session-monitoring
Draft

Add real-time session event monitoring to execution screen#12
Copilot wants to merge 8 commits intomainfrom
copilot/add-realtime-session-monitoring

Conversation

Copy link
Contributor

Copilot AI commented Feb 13, 2026

Implementation Plan: Real-Time Session Event Monitoring

All tasks completed!

  • Extend copilot.ts to support session event callbacks
  • Update executor.ts to propagate session events
  • Enhance execute.tsx to display real-time events
  • Add unit tests for event handling
  • Update documentation in README
  • Code review and refinements
  • Fix React key issue: Added unique id field to DisplayEvent
  • Improved event ID generation for better uniqueness guarantee
  • Enhanced test coverage for event callbacks and forwarding

Recent Changes

  • Improved copilot.test.ts with comprehensive StreamCallbacks testing
  • Enhanced executor.test.ts with event forwarding and lifecycle validation
  • Added tests for:
    • Event callback structure and type validation
    • Multiple sequential events through callbacks
    • Event data preservation when forwarding
    • TaskId context enrichment in executor layer
    • Error event handling with taskId context
    • Complete task lifecycle with events
  • All 17 tests passing ✅
Original prompt

This section details on the original issue you should resolve

<issue_title>[enhancement] Add Real-Time Session Event Monitoring for Task Execution Feedback</issue_title>
<issue_description>## Background

Recent changes in the Copilot SDK (v0.1.24-preview.0) include:

Commit reference: 439e0f0

Proposal

Implement real-time session event monitoring in src/services/executor.ts to provide users with granular feedback during task execution. The SDK's session event API allows subscriptions to events like:

  • tool.execution_complete (formerly tool.execution_end)
  • Progress updates from Copilot agents
  • Token usage and performance metrics

Implementation approach:

  1. Add event listeners in the Copilot SDK wrapper (src/services/copilot.ts)
  2. Stream events to the execution screen component (src/screens/execute.tsx)
  3. Display real-time progress indicators for each task (e.g., "Installing dependencies...", "Running tests...", "Generating code...")
  4. Show estimated completion percentages based on event data

Benefit

  • Better UX: Users see what Copilot is actively doing instead of staring at a blank "In Progress" spinner
  • Debugging: When tasks fail, users can see exactly where execution stopped
  • Transparency: Token usage and performance data help users understand costs
  • Trust: Real-time feedback builds confidence that the system is working

Acceptance Criteria

  • Session event subscription implemented in src/services/copilot.ts using SDK's event API
  • Event stream plumbed to src/screens/execute.tsx (via React state or context)
  • Execution screen displays at least 3 types of events: task start, progress updates, and tool.execution_complete
  • Event log is scrollable and shows timestamps
  • Error events are highlighted in red and include actionable messages
  • Unit tests verify event handlers properly parse SDK event payloads
  • Documentation updated to explain the event monitoring feature

AI generated by Weekly Enhancement Suggestions

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits February 13, 2026 01:10
Co-authored-by: colindembovsky <1932561+colindembovsky@users.noreply.github.com>
Co-authored-by: colindembovsky <1932561+colindembovsky@users.noreply.github.com>
Co-authored-by: colindembovsky <1932561+colindembovsky@users.noreply.github.com>
…ts, document event subscription

Co-authored-by: colindembovsky <1932561+colindembovsky@users.noreply.github.com>
Copilot AI changed the title [WIP] Add real-time session event monitoring for task execution feedback Add real-time session event monitoring to execution screen Feb 13, 2026
Copilot AI requested a review from colindembovsky February 13, 2026 01:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds real-time session event monitoring to provide users with granular visibility into Copilot SDK agent behavior during task execution. The implementation subscribes to SDK session events (tool executions, progress updates, token usage, errors) and displays them in a toggleable event log panel accessible via the e keyboard shortcut.

Changes:

  • Added session event subscription infrastructure in copilot.ts with SessionEventData interface and callback plumbing through sendPrompt and sendPromptSync
  • Extended executor callbacks to forward events with task context (onSessionEvent receives taskId + event data)
  • Implemented event log UI in execute screen with bounded 100-event memory, showing last 8 events with timestamps and color-coded error highlighting
  • Added documentation for the new feature in README with usage instructions

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/services/copilot.ts Added SessionEventData interface, onSessionEvent callback to StreamCallbacks, and session.on() subscription to capture all SDK events
src/services/copilot.test.ts Added type structure tests for SessionEventData covering tool execution, usage, and error events
src/services/executor.ts Extended ExecutionCallbacks with optional onSessionEvent, forwarding events from copilot.ts with taskId context for both regular and init tasks
src/services/executor.test.ts Added tests verifying onSessionEvent callback signature and multi-task event handling
src/screens/execute.tsx Implemented event log UI with DisplayEvent interface, formatSessionEvent helper, toggle functionality (e key), bounded 100-event buffer, and last-8 display panel
README.md Added keyboard shortcut table entries and "Real-Time Session Event Monitoring" feature section with usage instructions

Comment on lines 487 to 493
{visible.map((evt, i) => (
<Box key={i}>
<Text color="gray">[{evt.timestamp}] </Text>
<Text color="cyan">{evt.taskId}: </Text>
<Text color={evt.isError ? 'red' : 'white'}>{evt.message}</Text>
</Box>
))}
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using array index as React key can cause rendering issues when the event log is updated. Since events are bounded to the last 100 and displayed items are sliced from the end, the same index could refer to different events after updates. Consider adding a unique identifier to DisplayEvent (like a counter or timestamp+taskId combination) and use that as the key instead of the array index.

Copilot uses AI. Check for mistakes.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d9709b9. Added a unique id field to DisplayEvent using a counter-based approach (taskId-timestamp-counter), and updated the map to use evt.id as the React key instead of the array index.

Comment on lines 1 to 60
import { describe, it, expect, vi } from 'vitest';
import type { SessionEventData } from './copilot.js';

describe('SessionEventData', () => {
it('should have correct type structure', () => {
const mockEvent: SessionEventData = {
type: 'tool.execution_start',
timestamp: new Date().toISOString(),
data: { toolName: 'test-tool' },
};

expect(mockEvent.type).toBe('tool.execution_start');
expect(mockEvent.timestamp).toBeDefined();
expect(mockEvent.data).toBeDefined();
});

it('should handle tool.execution_complete events', () => {
const mockEvent: SessionEventData = {
type: 'tool.execution_complete',
timestamp: new Date().toISOString(),
data: {
toolCallId: 'test-123',
success: true,
result: { content: 'Task completed' },
},
};

expect(mockEvent.type).toBe('tool.execution_complete');
expect(mockEvent.data).toHaveProperty('success');
});

it('should handle session.error events', () => {
const mockEvent: SessionEventData = {
type: 'session.error',
timestamp: new Date().toISOString(),
data: {
errorType: 'timeout',
message: 'Request timed out',
},
};

expect(mockEvent.type).toBe('session.error');
expect((mockEvent.data as { message: string }).message).toBe('Request timed out');
});

it('should handle assistant.usage events', () => {
const mockEvent: SessionEventData = {
type: 'assistant.usage',
timestamp: new Date().toISOString(),
data: {
model: 'claude-sonnet-4',
inputTokens: 100,
outputTokens: 50,
},
};

expect(mockEvent.type).toBe('assistant.usage');
expect((mockEvent.data as { inputTokens: number }).inputTokens).toBe(100);
});
});
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests in this file only verify the interface type structure and don't test actual SDK integration or event callback behavior. Consider adding integration tests that mock the SDK's session.on() method to verify that events are properly captured and forwarded through the callback chain.

Copilot uses AI. Check for mistakes.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enhanced in 81acab6. Added comprehensive tests for StreamCallbacks including:

  • Event callback structure validation
  • Multiple sequential event handling
  • Event data preservation when forwarding
  • Tests verify callbacks properly handle tool.execution_start, tool.execution_progress, tool.execution_complete, session.error, and assistant.usage events

Comment on lines +1 to +58
import { describe, it, expect, vi } from 'vitest';
import type { ExecutionCallbacks } from './executor.js';
import type { SessionEventData } from './copilot.js';

describe('ExecutionCallbacks with session events', () => {
it('should define onSessionEvent callback', () => {
const mockCallback: ExecutionCallbacks = {
onTaskStart: vi.fn(),
onTaskDelta: vi.fn(),
onTaskDone: vi.fn(),
onTaskFailed: vi.fn(),
onBatchComplete: vi.fn(),
onAllDone: vi.fn(),
onSessionEvent: vi.fn(),
};

expect(mockCallback.onSessionEvent).toBeDefined();
expect(typeof mockCallback.onSessionEvent).toBe('function');
});

it('should call onSessionEvent with taskId and event data', () => {
const onSessionEvent = vi.fn();

const mockEvent: SessionEventData = {
type: 'tool.execution_start',
timestamp: new Date().toISOString(),
data: { toolName: 'bash' },
};

onSessionEvent('task-1', mockEvent);

expect(onSessionEvent).toHaveBeenCalledWith('task-1', mockEvent);
expect(onSessionEvent).toHaveBeenCalledTimes(1);
});

it('should handle multiple session events for different tasks', () => {
const onSessionEvent = vi.fn();

const event1: SessionEventData = {
type: 'tool.execution_start',
timestamp: new Date().toISOString(),
data: { toolName: 'bash' },
};

const event2: SessionEventData = {
type: 'tool.execution_complete',
timestamp: new Date().toISOString(),
data: { success: true },
};

onSessionEvent('task-1', event1);
onSessionEvent('task-2', event2);

expect(onSessionEvent).toHaveBeenCalledTimes(2);
expect(onSessionEvent).toHaveBeenNthCalledWith(1, 'task-1', event1);
expect(onSessionEvent).toHaveBeenNthCalledWith(2, 'task-2', event2);
});
});
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests only verify that callbacks can be called with the correct signature, but don't test the actual event forwarding behavior in the executor. Consider adding tests that verify the executor correctly forwards events from sendPromptSync through the onSessionEvent callback with the appropriate taskId context.

Copilot uses AI. Check for mistakes.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enhanced in 81acab6. Added tests that verify:

  • Event forwarding with taskId context enrichment
  • Complete task lifecycle with event flow
  • Multiple tasks with correct taskId assignment
  • Error event handling with taskId context
  • Event data structure preservation through the forwarding chain

Copilot AI and others added 2 commits February 20, 2026 20:46
Co-authored-by: colindembovsky <1932561+colindembovsky@users.noreply.github.com>
Co-authored-by: colindembovsky <1932561+colindembovsky@users.noreply.github.com>
…g validation

Co-authored-by: colindembovsky <1932561+colindembovsky@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 20, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/user
    • Triggering command: /home/REDACTED/work/planeteer/planeteer/node_modules/@github/copilot-linux-x64/copilot /home/REDACTED/work/planeteer/planeteer/node_modules/@github/copilot-linux-x64/copilot --headless --log-level debug --stdio (http block)

If you need me to access, download, or install something from one of these locations, you can either:

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.

[enhancement] Add Real-Time Session Event Monitoring for Task Execution Feedback

2 participants