Skip to content

Commit a64803a

Browse files
Phase 8: README updates for OnLifecycle<T> and lifecycle event types
Replace stale references to SessionLifecycleEventTypes constants with the new typed hierarchy (SessionCreatedEvent / SessionDeletedEvent / etc.). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 59ddbf5 commit a64803a

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

dotnet/README.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,35 +153,31 @@ Get the ID of the session currently displayed in the TUI. Only available when co
153153

154154
Request the TUI to switch to displaying the specified session. Only available in TUI+server mode.
155155

156-
##### `On(Action<SessionLifecycleEvent> handler): IDisposable`
156+
##### `OnLifecycle<T>(Action<T> handler): IDisposable where T : SessionLifecycleEvent`
157157

158-
Subscribe to all session lifecycle events. Returns an `IDisposable` that unsubscribes when disposed.
158+
Subscribe to session lifecycle events. Pass a derived type to filter by kind, or `SessionLifecycleEvent` to receive every lifecycle event. Returns an `IDisposable` that unsubscribes when disposed.
159159

160160
```csharp
161+
// Receive every lifecycle event:
161162
using var subscription = client.OnLifecycle<SessionLifecycleEvent>(evt =>
162163
{
163164
Console.WriteLine($"Session {evt.SessionId}: {evt.Type}");
164165
});
165-
```
166-
167-
##### `On(string eventType, Action<SessionLifecycleEvent> handler): IDisposable`
168166

169-
Subscribe to a specific lifecycle event type. Use `SessionLifecycleEventTypes` constants.
170-
171-
```csharp
172-
using var subscription = client.OnLifecycle<SessionForegroundEvent>(evt =>
167+
// Only receive foreground events:
168+
using var foreground = client.OnLifecycle<SessionForegroundEvent>(evt =>
173169
{
174170
Console.WriteLine($"Session {evt.SessionId} is now in foreground");
175171
});
176172
```
177173

178174
**Lifecycle Event Types:**
179175

180-
- `SessionLifecycleEventTypes.Created` - A new session was created
181-
- `SessionLifecycleEventTypes.Deleted` - A session was deleted
182-
- `SessionLifecycleEventTypes.Updated` - A session was updated
183-
- `SessionLifecycleEventTypes.Foreground` - A session became the foreground session in TUI
184-
- `SessionLifecycleEventTypes.Background` - A session is no longer the foreground session
176+
- `SessionCreatedEvent` A new session was created
177+
- `SessionDeletedEvent` A session was deleted
178+
- `SessionUpdatedEvent` A session was updated
179+
- `SessionForegroundEvent` A session became the foreground session in TUI
180+
- `SessionBackgroundEvent` A session is no longer the foreground session
185181

186182
---
187183

dotnet/test/E2E/HookLifecycleAndOutputE2ETests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*--------------------------------------------------------------------------------------------*/
44

55
using Microsoft.Extensions.AI;
6+
using System.Text.Json;
67
using Xunit;
78
using Xunit.Abstractions;
89

@@ -326,7 +327,7 @@ public async Task Should_Allow_PostToolUse_To_Return_ModifiedResult()
326327
{
327328
TextResultForLlm = "modified by post hook",
328329
ResultType = "success",
329-
ToolTelemetry = new Dictionary<string, object>(),
330+
ToolTelemetry = new Dictionary<string, JsonElement>(),
330331
},
331332
SuppressOutput = false,
332333
});

0 commit comments

Comments
 (0)