@cortexkit/opencode-antigravity-auth 3.0.35 → 3.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server.js +3446 -3408
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/ga/tui/host-ga.d.ts +21 -58
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +122 -230
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/ga-location-services.d.ts +1 -0
- package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/src/plugin/ga-location-services.js +87 -51
- package/dist/src/plugin/ga-location-services.js.map +1 -1
- package/dist/tui-ga-build-map.json +4 -4
- package/dist/types/src/plugin/ga-location-services.d.ts +1 -0
- package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/tui-ga-compiled/host-ga.js +122 -238
- package/src/tui-ga-raw/host-ga.tsx +189 -306
|
@@ -31,11 +31,10 @@ import { jsx as _jsx } from "@opentui/solid/jsx-runtime";
|
|
|
31
31
|
* not match is refused and logged by field name only.
|
|
32
32
|
*
|
|
33
33
|
* The wire shapes mirror the facade's `ga/rpc/protocol.ts` (clean v1:
|
|
34
|
-
* accounts carry opaque `selector`s
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* it; after every apply the menu is rebuilt from a fresh `state` read.
|
|
34
|
+
* accounts carry opaque `selector`s and every snapshot carries the location's
|
|
35
|
+
* settings). Notifications and apply answers carry the server's shared menu.
|
|
36
|
+
* The drawer keeps its presentation while submitting the issued menu item
|
|
37
|
+
* and action ids, never a sidebar selector or an account position.
|
|
39
38
|
*
|
|
40
39
|
* Nothing here imports account storage, tokens, OAuth, the vault client or
|
|
41
40
|
* server code, and nothing writes to the terminal or forces a theme.
|
|
@@ -43,7 +42,7 @@ import { jsx as _jsx } from "@opentui/solid/jsx-runtime";
|
|
|
43
42
|
import { createSignal } from 'solid-js';
|
|
44
43
|
import { projectAccount, projectSidebar, } from '../../sidebar-projection';
|
|
45
44
|
import { MenuRefusedError, openAntigravityMenu, } from '../../tui/command-dialogs';
|
|
46
|
-
import { ANTIGRAVITY_MENU_COMMAND, ANTIGRAVITY_MENU_TITLE, } from '../../tui/host-api';
|
|
45
|
+
import { ANTIGRAVITY_MENU_COMMAND, ANTIGRAVITY_MENU_TITLE, parseMenuApplyResult, parseMenuDialogPayload, parseMenuNotifyPayload, } from '../../tui/host-api';
|
|
47
46
|
import { AntigravitySidebar, DEFAULT_FRAME_SETTINGS, } from '../../tui/sidebar-frame';
|
|
48
47
|
export const GA_TUI_ID = 'cortexkit.antigravity-auth';
|
|
49
48
|
export const GA_RPC_ID = 'antigravity-auth';
|
|
@@ -52,14 +51,6 @@ export const GA_RPC_VERSION = 1;
|
|
|
52
51
|
export const GA_SIDEBAR_PULL_MS = 1_000;
|
|
53
52
|
/** Pulls in one tick while the server reports more notifications waiting. */
|
|
54
53
|
const MAX_PULLS_PER_TICK = 4;
|
|
55
|
-
/** The dialog commands the server names in notifications and text applies. */
|
|
56
|
-
export const GA_COMMANDS = [
|
|
57
|
-
'antigravity-quota',
|
|
58
|
-
'antigravity-account',
|
|
59
|
-
'antigravity-killswitch',
|
|
60
|
-
'antigravity-dump',
|
|
61
|
-
'antigravity-logging',
|
|
62
|
-
];
|
|
63
54
|
export const GA_LOG_LEVELS = [
|
|
64
55
|
'error',
|
|
65
56
|
'warn',
|
|
@@ -72,13 +63,6 @@ const SESSION_ID = /^[\x21-\x7e]{1,256}$/;
|
|
|
72
63
|
const ACCOUNT_ID = /^acct-(0|[1-9][0-9]{0,5})$/;
|
|
73
64
|
const ACCOUNT_LABEL = /^Account [1-9][0-9]{0,5}$/;
|
|
74
65
|
const SELECTOR = /^sel-[A-Za-z0-9_-]{32}$/;
|
|
75
|
-
const TARGET_OUTCOMES = [
|
|
76
|
-
'applied',
|
|
77
|
-
'stale-target',
|
|
78
|
-
'unknown-target',
|
|
79
|
-
'unsupported-index-action',
|
|
80
|
-
'failed',
|
|
81
|
-
];
|
|
82
66
|
function isRecord(value) {
|
|
83
67
|
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
84
68
|
return false;
|
|
@@ -282,18 +266,15 @@ function checkNotification(value, path, issues) {
|
|
|
282
266
|
issues.push(`${path}: expected a notification`);
|
|
283
267
|
return;
|
|
284
268
|
}
|
|
285
|
-
keys(value, ['cursor', '
|
|
269
|
+
keys(value, ['cursor', 'payload'], [], path, issues);
|
|
286
270
|
if (!isCursor(value.cursor) || value.cursor < 1) {
|
|
287
271
|
issues.push(`${path}.cursor: expected a positive cursor`);
|
|
288
272
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if (!
|
|
293
|
-
issues.push(`${path}.
|
|
294
|
-
}
|
|
295
|
-
if (typeof value.text !== 'string')
|
|
296
|
-
issues.push(`${path}.text: expected text`);
|
|
273
|
+
const parsed = isRecord(value.payload) && Object.hasOwn(value.payload, 'notify')
|
|
274
|
+
? parseMenuNotifyPayload(value.payload)
|
|
275
|
+
: parseMenuDialogPayload(value.payload);
|
|
276
|
+
if (!parsed.ok)
|
|
277
|
+
issues.push(...parsed.issues.map((issue) => `${path}.payload: ${issue}`));
|
|
297
278
|
}
|
|
298
279
|
function checkBool(value, path, issues) {
|
|
299
280
|
if (typeof value !== 'boolean')
|
|
@@ -345,63 +326,6 @@ function checkAccountsStatus(value, path, issues) {
|
|
|
345
326
|
}
|
|
346
327
|
issues.push(`${path}.kind: unknown accounts status`);
|
|
347
328
|
}
|
|
348
|
-
function checkAccountList(value, path, issues) {
|
|
349
|
-
if (value === null)
|
|
350
|
-
return;
|
|
351
|
-
if (!Array.isArray(value) || value.length > 64) {
|
|
352
|
-
issues.push(`${path}: expected at most 64 accounts`);
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
value.forEach((entry, index) => {
|
|
356
|
-
checkAccount(entry, `${path}.${index}`, issues);
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
/** One command result, with the closed field list of its command. */
|
|
360
|
-
function checkCommandResult(value, path, issues) {
|
|
361
|
-
if (!isRecord(value)) {
|
|
362
|
-
issues.push(`${path}: expected a command result`);
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
const base = ['command', 'status', 'text'];
|
|
366
|
-
if (value.status !== 'applied' &&
|
|
367
|
-
value.status !== 'rejected' &&
|
|
368
|
-
value.status !== 'failed') {
|
|
369
|
-
issues.push(`${path}.status: unknown status`);
|
|
370
|
-
}
|
|
371
|
-
if (typeof value.text !== 'string')
|
|
372
|
-
issues.push(`${path}.text: expected text`);
|
|
373
|
-
switch (value.command) {
|
|
374
|
-
case 'antigravity-quota':
|
|
375
|
-
keys(value, [...base, 'accounts'], [], path, issues);
|
|
376
|
-
checkAccountList(value.accounts, `${path}.accounts`, issues);
|
|
377
|
-
return;
|
|
378
|
-
case 'antigravity-account':
|
|
379
|
-
keys(value, [...base, 'accounts', 'authorizationUrl', 'targetOutcome'], [], path, issues);
|
|
380
|
-
checkAccountList(value.accounts, `${path}.accounts`, issues);
|
|
381
|
-
if (value.authorizationUrl !== null &&
|
|
382
|
-
!(typeof value.authorizationUrl === 'string' &&
|
|
383
|
-
/^https:\/\//.test(value.authorizationUrl) &&
|
|
384
|
-
value.authorizationUrl.length <= 4096)) {
|
|
385
|
-
issues.push(`${path}.authorizationUrl: expected an https link or null`);
|
|
386
|
-
}
|
|
387
|
-
if (value.targetOutcome !== null &&
|
|
388
|
-
!TARGET_OUTCOMES.includes(value.targetOutcome)) {
|
|
389
|
-
issues.push(`${path}.targetOutcome: unknown outcome`);
|
|
390
|
-
}
|
|
391
|
-
return;
|
|
392
|
-
case 'antigravity-killswitch':
|
|
393
|
-
keys(value, [...base, 'killswitch'], [], path, issues);
|
|
394
|
-
return;
|
|
395
|
-
case 'antigravity-dump':
|
|
396
|
-
keys(value, [...base, 'dump'], [], path, issues);
|
|
397
|
-
return;
|
|
398
|
-
case 'antigravity-logging':
|
|
399
|
-
keys(value, [...base, 'logLevel'], [], path, issues);
|
|
400
|
-
return;
|
|
401
|
-
default:
|
|
402
|
-
issues.push(`${path}.command: unknown command`);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
329
|
/** Unwraps the host's `{ output }` answer. */
|
|
406
330
|
function unwrap(raw, issues) {
|
|
407
331
|
if (!isRecord(raw)) {
|
|
@@ -512,7 +436,9 @@ export function parseGaApplyAnswer(raw) {
|
|
|
512
436
|
keys(output, ['version', 'kind', 'generation', 'scope', 'result'], [], 'output', issues);
|
|
513
437
|
checkGeneration(output.generation, 'output.generation', issues);
|
|
514
438
|
checkScope(output.scope, 'output.scope', issues);
|
|
515
|
-
|
|
439
|
+
const result = parseMenuApplyResult(output.result);
|
|
440
|
+
if (!result.ok)
|
|
441
|
+
issues.push(...result.issues);
|
|
516
442
|
return finish(output, issues);
|
|
517
443
|
}
|
|
518
444
|
// ── Location client ─────────────────────────────────────────────────────────
|
|
@@ -645,24 +571,6 @@ export function createGaLocationClient(options) {
|
|
|
645
571
|
};
|
|
646
572
|
}
|
|
647
573
|
// ── Menu over the native state ──────────────────────────────────────────────
|
|
648
|
-
/**
|
|
649
|
-
* GA notifications name only a dialog command, so this host builds the
|
|
650
|
-
* `/antigravity` menu itself from the latest `state` answer: the accounts
|
|
651
|
-
* with their opaque selectors and the location's settings, both read fresh
|
|
652
|
-
* for that answer. The shared drawer renders it like the OpenCode 1 menu.
|
|
653
|
-
* Each item and action id encodes what the action sends; an account is named
|
|
654
|
-
* only by its selector, never by position or `acct-<n>` id.
|
|
655
|
-
*/
|
|
656
|
-
const SECTION_FOR_COMMAND = {
|
|
657
|
-
'antigravity-account': 'accounts',
|
|
658
|
-
'antigravity-quota': 'quota',
|
|
659
|
-
'antigravity-killswitch': 'limits',
|
|
660
|
-
'antigravity-dump': 'diagnostics',
|
|
661
|
-
'antigravity-logging': 'diagnostics',
|
|
662
|
-
};
|
|
663
|
-
export function sectionForCommand(command) {
|
|
664
|
-
return SECTION_FOR_COMMAND[command];
|
|
665
|
-
}
|
|
666
574
|
const ACCOUNT_ITEM_PREFIX = 'account:';
|
|
667
575
|
function onOff(value) {
|
|
668
576
|
return value ? 'on' : 'off';
|
|
@@ -711,7 +619,8 @@ export function buildGaMenu(snapshot, now) {
|
|
|
711
619
|
use('select-active', 'Use for all models', 'Make this the current account.'),
|
|
712
620
|
use('select-claude', 'Use for Claude', 'Make this the current Claude account.'),
|
|
713
621
|
use('select-gemini', 'Use for Gemini', 'Make this the current Gemini account.'),
|
|
714
|
-
...(snapshot.vaultHostStatus
|
|
622
|
+
...(snapshot.vaultHostStatus ||
|
|
623
|
+
settings.selectionStrategy === 'vault'
|
|
715
624
|
? []
|
|
716
625
|
: [
|
|
717
626
|
{
|
|
@@ -728,7 +637,7 @@ export function buildGaMenu(snapshot, now) {
|
|
|
728
637
|
],
|
|
729
638
|
};
|
|
730
639
|
}),
|
|
731
|
-
actions: snapshot.vaultHostStatus
|
|
640
|
+
actions: snapshot.vaultHostStatus || settings.selectionStrategy === 'vault'
|
|
732
641
|
? []
|
|
733
642
|
: [
|
|
734
643
|
{
|
|
@@ -862,122 +771,106 @@ export function buildGaMenu(snapshot, now) {
|
|
|
862
771
|
: sections,
|
|
863
772
|
};
|
|
864
773
|
}
|
|
865
|
-
/**
|
|
774
|
+
/** A displayed choice is no longer present in the server-issued menu. */
|
|
866
775
|
export class GaMenuChoiceError extends Error {
|
|
867
776
|
constructor(message) {
|
|
868
777
|
super(message);
|
|
869
778
|
this.name = 'GaMenuChoiceError';
|
|
870
779
|
}
|
|
871
780
|
}
|
|
872
|
-
const TEXT_ACTIONS = {
|
|
873
|
-
'accounts/add': {
|
|
874
|
-
command: 'antigravity-account',
|
|
875
|
-
arguments: 'add-oauth-start',
|
|
876
|
-
},
|
|
877
|
-
'quota/refresh': { command: 'antigravity-quota', arguments: 'refresh' },
|
|
878
|
-
'limits/killswitch-on': {
|
|
879
|
-
command: 'antigravity-killswitch',
|
|
880
|
-
arguments: 'enabled=true',
|
|
881
|
-
},
|
|
882
|
-
'limits/killswitch-off': {
|
|
883
|
-
command: 'antigravity-killswitch',
|
|
884
|
-
arguments: 'enabled=false',
|
|
885
|
-
},
|
|
886
|
-
'diagnostics/dump-on': { command: 'antigravity-dump', arguments: 'on' },
|
|
887
|
-
'diagnostics/dump-off': { command: 'antigravity-dump', arguments: 'off' },
|
|
888
|
-
};
|
|
889
781
|
/**
|
|
890
|
-
*
|
|
891
|
-
*
|
|
892
|
-
*
|
|
893
|
-
*
|
|
782
|
+
* Keep the drawer's labels and order, but bind every choice to an action
|
|
783
|
+
* actually issued by the server. Snapshot selectors are display data, not
|
|
784
|
+
* shared-menu item ids. The bindings retain the server's exact item id even
|
|
785
|
+
* when the roster changes before a choice arrives.
|
|
894
786
|
*/
|
|
895
|
-
export function
|
|
896
|
-
const
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
: request.actionId === 'disable'
|
|
908
|
-
? { kind: 'disable', selector }
|
|
909
|
-
: request.actionId === 'remove'
|
|
910
|
-
? { kind: 'remove', selector }
|
|
911
|
-
: request.actionId === 'select-active'
|
|
912
|
-
? { kind: 'select', selector, target: 'active' }
|
|
913
|
-
: request.actionId === 'select-claude'
|
|
914
|
-
? { kind: 'select', selector, target: 'claude' }
|
|
915
|
-
: request.actionId === 'select-gemini'
|
|
916
|
-
? { kind: 'select', selector, target: 'gemini' }
|
|
917
|
-
: undefined;
|
|
918
|
-
if (!action)
|
|
919
|
-
throw new GaMenuChoiceError('Unknown account action.');
|
|
920
|
-
if (action.kind === 'remove' && request.confirmed !== true) {
|
|
921
|
-
throw new GaMenuChoiceError('Removing an account needs a confirmation.');
|
|
922
|
-
}
|
|
923
|
-
return { command: 'antigravity-account', action };
|
|
924
|
-
}
|
|
925
|
-
if (request.itemId !== undefined) {
|
|
926
|
-
throw new GaMenuChoiceError('Unknown menu entry.');
|
|
927
|
-
}
|
|
928
|
-
const fixed = TEXT_ACTIONS[key];
|
|
929
|
-
if (fixed)
|
|
930
|
-
return fixed;
|
|
931
|
-
if (key === 'limits/killswitch-minimum') {
|
|
932
|
-
const percent = request.values.percent;
|
|
933
|
-
if (typeof percent !== 'number' ||
|
|
934
|
-
!Number.isInteger(percent) ||
|
|
935
|
-
percent < 0 ||
|
|
936
|
-
percent > 100) {
|
|
937
|
-
throw new GaMenuChoiceError('The minimum must be a whole number from 0 to 100.');
|
|
938
|
-
}
|
|
787
|
+
export function presentGaMenu(snapshot, now, source) {
|
|
788
|
+
const bindings = new Map();
|
|
789
|
+
const key = (sectionId, itemId, actionId) => JSON.stringify([sectionId, itemId, actionId]);
|
|
790
|
+
const bind = (sectionId, itemId, display, action, values = (choice) => choice) => {
|
|
791
|
+
bindings.set(key(sectionId, itemId, display.id), (choice) => ({
|
|
792
|
+
command: source.command,
|
|
793
|
+
sectionId,
|
|
794
|
+
...(itemId === undefined ? {} : { itemId }),
|
|
795
|
+
actionId: action.id,
|
|
796
|
+
values: values(choice.values),
|
|
797
|
+
...(choice.confirmed ? { confirmed: true } : {}),
|
|
798
|
+
}));
|
|
939
799
|
return {
|
|
940
|
-
|
|
941
|
-
|
|
800
|
+
...display,
|
|
801
|
+
...(action.confirm ? { confirm: action.confirm } : {}),
|
|
942
802
|
};
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
803
|
+
};
|
|
804
|
+
const display = buildGaMenu(snapshot, now);
|
|
805
|
+
const sections = display.sections
|
|
806
|
+
.filter((section) => section.slot !== 'extra')
|
|
807
|
+
.flatMap((section) => {
|
|
808
|
+
const actual = source.sections.find((candidate) => candidate.id === section.id);
|
|
809
|
+
if (!actual)
|
|
810
|
+
return [];
|
|
811
|
+
const actions = section.actions.flatMap((action) => {
|
|
812
|
+
const id = section.id === 'limits'
|
|
813
|
+
? 'set'
|
|
814
|
+
: action.id === 'log-level'
|
|
815
|
+
? 'logging'
|
|
816
|
+
: action.id.startsWith('dump-')
|
|
817
|
+
? 'dump'
|
|
818
|
+
: action.id;
|
|
819
|
+
const offered = actual.actions.find((candidate) => candidate.id === id);
|
|
820
|
+
if (!offered)
|
|
821
|
+
return [];
|
|
822
|
+
const values = section.id !== 'limits'
|
|
823
|
+
? undefined
|
|
824
|
+
: action.id === 'killswitch-minimum'
|
|
825
|
+
? (input) => ({
|
|
826
|
+
minimumRemainingPercent: input.percent ?? null,
|
|
827
|
+
})
|
|
828
|
+
: () => ({ enabled: action.id === 'killswitch-on' });
|
|
829
|
+
return [bind(actual.id, undefined, action, offered, values)];
|
|
830
|
+
});
|
|
831
|
+
const items = actual.items.map((item) => {
|
|
832
|
+
const projected = section.items.find((candidate) => candidate.label === item.label);
|
|
833
|
+
if (!projected)
|
|
834
|
+
return { ...item, actions: [] };
|
|
835
|
+
return {
|
|
836
|
+
...projected,
|
|
837
|
+
id: item.id,
|
|
838
|
+
actions: projected.actions.flatMap((action) => {
|
|
839
|
+
const target = action.id.startsWith('select-')
|
|
840
|
+
? action.id.slice('select-'.length)
|
|
841
|
+
: undefined;
|
|
842
|
+
const offered = item.actions.find((candidate) => candidate.id === (target ? 'select' : action.id));
|
|
843
|
+
if (!offered)
|
|
844
|
+
return [];
|
|
845
|
+
return [
|
|
846
|
+
bind(actual.id, item.id, action, offered, target ? () => ({ target }) : undefined),
|
|
847
|
+
];
|
|
848
|
+
}),
|
|
849
|
+
};
|
|
850
|
+
});
|
|
851
|
+
return [{ ...section, items, actions }];
|
|
852
|
+
});
|
|
853
|
+
// Enrollment and hosted status remain the server's own sections, including
|
|
854
|
+
// their authority-dependent Connect/Disconnect actions and read-only host.
|
|
855
|
+
for (const section of source.sections.filter((candidate) => candidate.slot === 'extra')) {
|
|
856
|
+
sections.push({
|
|
857
|
+
...section,
|
|
858
|
+
actions: section.actions.map((action) => bind(section.id, undefined, action, action)),
|
|
859
|
+
items: section.items.map((item) => ({
|
|
860
|
+
...item,
|
|
861
|
+
actions: item.actions.map((action) => bind(section.id, item.id, action, action)),
|
|
862
|
+
})),
|
|
863
|
+
});
|
|
974
864
|
}
|
|
975
865
|
return {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
866
|
+
menu: { ...display, sections },
|
|
867
|
+
source,
|
|
868
|
+
request(choice) {
|
|
869
|
+
const resolve = bindings.get(key(choice.sectionId, choice.itemId, choice.actionId));
|
|
870
|
+
if (choice.command !== source.command || !resolve)
|
|
871
|
+
throw new GaMenuChoiceError('That action is no longer offered. Open the menu again.');
|
|
872
|
+
return resolve(choice);
|
|
873
|
+
},
|
|
981
874
|
};
|
|
982
875
|
}
|
|
983
876
|
// ── Dialogs ─────────────────────────────────────────────────────────────────
|
|
@@ -1164,7 +1057,7 @@ export function setupGaTui(context, options = {}) {
|
|
|
1164
1057
|
append: 'sidebar.content',
|
|
1165
1058
|
render: (input) => (_jsx(GaSidebar, { view: view, sessionID: input.sessionID, theme: () => context.theme, version: options.version ?? '', collapsed: collapse.collapsed, toggleCollapsed: collapse.toggle })),
|
|
1166
1059
|
});
|
|
1167
|
-
//
|
|
1060
|
+
// Sidebar readings and presentation are scoped to the menu's own session.
|
|
1168
1061
|
const latest = new Map();
|
|
1169
1062
|
const showSnapshot = (snapshot) => {
|
|
1170
1063
|
latest.set(scopeKey(snapshot.scope), snapshot);
|
|
@@ -1178,22 +1071,19 @@ export function setupGaTui(context, options = {}) {
|
|
|
1178
1071
|
});
|
|
1179
1072
|
};
|
|
1180
1073
|
/**
|
|
1181
|
-
* Pulls fresh state for `scope
|
|
1074
|
+
* Pulls fresh state for `scope`. Any
|
|
1182
1075
|
* notifications the pull carries are handled like a poll tick's.
|
|
1183
1076
|
*/
|
|
1184
|
-
const
|
|
1185
|
-
let fresh;
|
|
1077
|
+
const refresh = async (scope) => {
|
|
1186
1078
|
await pollGaOnce({
|
|
1187
1079
|
client,
|
|
1188
1080
|
scope: () => scope,
|
|
1189
1081
|
onSnapshot: (snapshot) => {
|
|
1190
|
-
fresh = snapshot;
|
|
1191
1082
|
showSnapshot(snapshot);
|
|
1192
1083
|
},
|
|
1193
1084
|
onNotification,
|
|
1194
1085
|
...(logger ? { logger } : {}),
|
|
1195
1086
|
});
|
|
1196
|
-
return fresh ? buildGaMenu(fresh, now()) : undefined;
|
|
1197
1087
|
};
|
|
1198
1088
|
const applyChoice = async (scope, request, shown) => {
|
|
1199
1089
|
const refused = async (text, code) => ({
|
|
@@ -1201,11 +1091,11 @@ export function setupGaTui(context, options = {}) {
|
|
|
1201
1091
|
ok: false,
|
|
1202
1092
|
text,
|
|
1203
1093
|
code,
|
|
1204
|
-
menu:
|
|
1094
|
+
menu: shown.source,
|
|
1205
1095
|
});
|
|
1206
1096
|
let body;
|
|
1207
1097
|
try {
|
|
1208
|
-
body =
|
|
1098
|
+
body = { request: shown.request(request) };
|
|
1209
1099
|
}
|
|
1210
1100
|
catch (error) {
|
|
1211
1101
|
if (error instanceof GaMenuChoiceError)
|
|
@@ -1221,22 +1111,25 @@ export function setupGaTui(context, options = {}) {
|
|
|
1221
1111
|
return refused(error.message, error.reason);
|
|
1222
1112
|
throw error;
|
|
1223
1113
|
}
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
const menu = (await freshMenu(scope)) ?? shown();
|
|
1227
|
-
return gaMenuResult(result, menu);
|
|
1114
|
+
await refresh(scope);
|
|
1115
|
+
return result;
|
|
1228
1116
|
};
|
|
1229
1117
|
function onNotification(notification, scope) {
|
|
1118
|
+
const payload = notification.payload;
|
|
1119
|
+
if ('notify' in payload) {
|
|
1120
|
+
ui.toast(payload.notify.message, payload.notify.kind);
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1230
1123
|
const snapshot = latest.get(scopeKey(scope));
|
|
1231
1124
|
if (!snapshot)
|
|
1232
1125
|
return;
|
|
1233
|
-
let shown =
|
|
1126
|
+
let shown = presentGaMenu(snapshot, now(), payload.menu);
|
|
1234
1127
|
void openAntigravityMenu({
|
|
1235
1128
|
ui,
|
|
1236
1129
|
apply: async (request) => {
|
|
1237
|
-
const result = await applyChoice(scope, request,
|
|
1238
|
-
shown = result.menu;
|
|
1239
|
-
return result;
|
|
1130
|
+
const result = await applyChoice(scope, request, shown);
|
|
1131
|
+
shown = presentGaMenu(latest.get(scopeKey(scope)) ?? snapshot, now(), result.menu);
|
|
1132
|
+
return { ...result, menu: shown.menu };
|
|
1240
1133
|
},
|
|
1241
1134
|
...(context.renderer?.copyToClipboardOSC52
|
|
1242
1135
|
? {
|
|
@@ -1244,8 +1137,7 @@ export function setupGaTui(context, options = {}) {
|
|
|
1244
1137
|
}
|
|
1245
1138
|
: {}),
|
|
1246
1139
|
onError: (message, detail) => logger?.warn(message, detail),
|
|
1247
|
-
|
|
1248
|
-
}, { command: ANTIGRAVITY_MENU_COMMAND, menu: shown }).catch((error) => {
|
|
1140
|
+
}, { command: ANTIGRAVITY_MENU_COMMAND, menu: shown.menu }).catch((error) => {
|
|
1249
1141
|
logger?.warn('menu-drawer-failed', {
|
|
1250
1142
|
error: error instanceof Error ? error.name : typeof error,
|
|
1251
1143
|
});
|