Commit ed4c004
committed
copilot_chat: support SDK auth.db and reload via LSP didChangeStatus
The GitHub Copilot SDK migrated its OAuth token storage from JSON files (apps.json / hosts.json) to a SQLite database (auth.db) under the same github-copilot config directory. Zed only knew about the JSON files, so users on a fresh SDK install saw an empty Copilot Chat model dropdown even though they were signed in via the LSP.
Changes:
* Add extract_oauth_token_from_db() which reads token_ciphertext from the oauth_tokens table via the existing sqlez dependency. The column stores the raw 'ghu_...' OAuth token as text on current SDK builds; format is validated (prefix + length + charset) so we fail closed if the SDK changes the schema.
* Replace the previous fs.watch() loop on the config directory with an LSP-driven reload. The copilot crate already receives didChangeStatus notifications from the Copilot language server; we now route those through a small public CopilotChat::reload_auth() method. SQLite's WAL writes interact poorly with directory watchers (we observed both spurious early fires and missed commits on Windows), and the LSP gives us a clean, semantic, cross-platform signal that fires after the token is durable.
* Sign-out clears api_endpoint and the model catalogue so a subsequent sign-in re-discovers them rather than reusing stale state.
Tested on Windows 11 with the official Copilot SDK build that ships auth.db; cold sign-in now populates the model list within a couple of seconds of the LSP reporting Authorized status, with no manual restart.1 parent 1dac14c commit ed4c004
4 files changed
Lines changed: 130 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1259 | 1259 | | |
1260 | 1260 | | |
1261 | 1261 | | |
| 1262 | + | |
1262 | 1263 | | |
1263 | 1264 | | |
1264 | 1265 | | |
| |||
1278 | 1279 | | |
1279 | 1280 | | |
1280 | 1281 | | |
| 1282 | + | |
1281 | 1283 | | |
1282 | 1284 | | |
1283 | 1285 | | |
| |||
1381 | 1383 | | |
1382 | 1384 | | |
1383 | 1385 | | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
1384 | 1397 | | |
1385 | 1398 | | |
1386 | 1399 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
| |||
501 | 499 | | |
502 | 500 | | |
503 | 501 | | |
| 502 | + | |
504 | 503 | | |
505 | 504 | | |
506 | 505 | | |
| |||
546 | 545 | | |
547 | 546 | | |
548 | 547 | | |
549 | | - | |
550 | | - | |
551 | | - | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
552 | 560 | | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
564 | 570 | | |
565 | | - | |
| 571 | + | |
566 | 572 | | |
567 | 573 | | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
| 574 | + | |
572 | 575 | | |
573 | 576 | | |
574 | 577 | | |
575 | 578 | | |
576 | 579 | | |
577 | 580 | | |
578 | | - | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
579 | 588 | | |
580 | 589 | | |
581 | 590 | | |
582 | 591 | | |
| 592 | + | |
583 | 593 | | |
584 | 594 | | |
585 | 595 | | |
| |||
764 | 774 | | |
765 | 775 | | |
766 | 776 | | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
767 | 814 | | |
768 | 815 | | |
769 | 816 | | |
| |||
917 | 964 | | |
918 | 965 | | |
919 | 966 | | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
920 | 986 | | |
921 | 987 | | |
922 | 988 | | |
| |||
934 | 1000 | | |
935 | 1001 | | |
936 | 1002 | | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
937 | 1030 | | |
938 | 1031 | | |
939 | 1032 | | |
| |||
0 commit comments