Commit 4125fe7
Register sessions before RPC and add SessionConfig.OnEvent (#664)
Register sessions in the client's sessions map before issuing the
session.create and session.resume RPC calls, so that events emitted
by the CLI during the RPC (e.g. session.start, permission requests,
tool calls) are not dropped. Previously, sessions were registered
only after the RPC completed, creating a window where notifications
for the session had no target.
The session ID is now generated client-side (via UUID) rather than
extracted from the server response. On RPC failure, the session is
cleaned up from the map.
Add a new OnEvent property to each SDK's session configuration
(SessionConfig / ResumeSessionConfig) that registers an event handler
on the session before the create/resume RPC is issued. This guarantees
that early events emitted by the CLI during session creation (e.g.
session.start) are delivered to the handler, unlike calling On() after
createSession() returns.
Changes across all four SDKs (Node.js, Python, Go, .NET):
- Generate sessionId client-side before the RPC
- Create and register the session in the sessions map before the RPC
- Set workspacePath from the RPC response after it completes
- Remove the session from the map if the RPC fails
- Add OnEvent/on_event config property wired up before the RPC
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 7235609 commit 4125fe7
File tree
78 files changed
+580
-209
lines changed- dotnet
- src
- test
- go
- internal/e2e
- nodejs
- src
- test/e2e
- python
- copilot
- e2e
- test/scenarios
- auth
- byok-anthropic/go
- byok-azure/go
- byok-ollama/go
- byok-openai/go
- gh-app/go
- bundling
- app-backend-to-server/go
- app-direct-server/go
- container-proxy/go
- fully-bundled/go
- callbacks
- hooks/go
- permissions/go
- user-input/go
- modes
- default/go
- minimal/go
- prompts
- attachments/go
- reasoning-effort/go
- system-message/go
- sessions
- concurrent-sessions/go
- infinite-sessions/go
- session-resume/go
- streaming/go
- tools
- custom-agents/go
- mcp-servers/go
- no-tools/go
- skills/go
- tool-filtering/go
- tool-overrides/go
- virtual-filesystem/go
- transport
- reconnect/go
- stdio/go
- tcp/go
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
78 files changed
+580
-209
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
434 | 411 | | |
435 | 412 | | |
436 | 413 | | |
| |||
441 | 418 | | |
442 | 419 | | |
443 | 420 | | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
444 | 426 | | |
445 | | - | |
| 427 | + | |
446 | 428 | | |
447 | | - | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
448 | 462 | | |
449 | 463 | | |
450 | 464 | | |
| |||
495 | 509 | | |
496 | 510 | | |
497 | 511 | | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
527 | 515 | | |
528 | 516 | | |
529 | 517 | | |
| |||
534 | 522 | | |
535 | 523 | | |
536 | 524 | | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
537 | 568 | | |
538 | | - | |
539 | | - | |
540 | 569 | | |
541 | 570 | | |
542 | 571 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1183 | 1183 | | |
1184 | 1184 | | |
1185 | 1185 | | |
| 1186 | + | |
1186 | 1187 | | |
1187 | 1188 | | |
1188 | 1189 | | |
| |||
1307 | 1308 | | |
1308 | 1309 | | |
1309 | 1310 | | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
1310 | 1323 | | |
1311 | 1324 | | |
1312 | 1325 | | |
| |||
1355 | 1368 | | |
1356 | 1369 | | |
1357 | 1370 | | |
| 1371 | + | |
1358 | 1372 | | |
1359 | 1373 | | |
1360 | 1374 | | |
| |||
1482 | 1496 | | |
1483 | 1497 | | |
1484 | 1498 | | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
1485 | 1505 | | |
1486 | 1506 | | |
1487 | 1507 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
248 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
249 | 259 | | |
250 | 260 | | |
251 | 261 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
493 | 495 | | |
494 | 496 | | |
495 | 497 | | |
496 | | - | |
497 | 498 | | |
498 | 499 | | |
499 | 500 | | |
| |||
527 | 528 | | |
528 | 529 | | |
529 | 530 | | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
538 | 534 | | |
| 535 | + | |
539 | 536 | | |
540 | | - | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
541 | 540 | | |
542 | 541 | | |
543 | 542 | | |
| |||
547 | 546 | | |
548 | 547 | | |
549 | 548 | | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
550 | 552 | | |
551 | 553 | | |
552 | | - | |
| 554 | + | |
553 | 555 | | |
554 | 556 | | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
555 | 575 | | |
556 | 576 | | |
557 | 577 | | |
| |||
627 | 647 | | |
628 | 648 | | |
629 | 649 | | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
634 | 653 | | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | 654 | | |
642 | 655 | | |
643 | 656 | | |
| |||
646 | 659 | | |
647 | 660 | | |
648 | 661 | | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
649 | 665 | | |
650 | 666 | | |
651 | | - | |
| 667 | + | |
652 | 668 | | |
653 | 669 | | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
654 | 688 | | |
655 | 689 | | |
656 | 690 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
0 commit comments