github-issue-tower-defence-management 2.6.1 → 2.8.0
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/CHANGELOG.md +14 -0
- package/README.md +0 -2
- package/bin/adapter/entry-points/cli/index.js +3 -6
- package/bin/adapter/entry-points/cli/index.js.map +1 -1
- package/bin/adapter/entry-points/cli/projectConfig.js +0 -3
- package/bin/adapter/entry-points/cli/projectConfig.js.map +1 -1
- package/bin/adapter/entry-points/console/consoleAirplaneSnapshotApi.js +347 -0
- package/bin/adapter/entry-points/console/consoleAirplaneSnapshotApi.js.map +1 -0
- package/bin/adapter/entry-points/console/ui-dist/assets/index-DkMqSpkk.js +88 -0
- package/bin/adapter/entry-points/console/ui-dist/index.html +1 -1
- package/bin/adapter/entry-points/console/webServer.js +28 -0
- package/bin/adapter/entry-points/console/webServer.js.map +1 -1
- package/bin/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.js +1 -3
- package/bin/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.js.map +1 -1
- package/bin/domain/usecases/CheckIssueReviewReadinessUseCase.js +4 -2
- package/bin/domain/usecases/CheckIssueReviewReadinessUseCase.js.map +1 -1
- package/bin/domain/usecases/HandleScheduledEventUseCase.js +1 -6
- package/bin/domain/usecases/HandleScheduledEventUseCase.js.map +1 -1
- package/bin/domain/usecases/IssueRejectionEvaluator.js +0 -23
- package/bin/domain/usecases/IssueRejectionEvaluator.js.map +1 -1
- package/bin/domain/usecases/NotifyFinishedIssuePreparationUseCase.js +39 -69
- package/bin/domain/usecases/NotifyFinishedIssuePreparationUseCase.js.map +1 -1
- package/bin/domain/usecases/RevertNotReadyReviewQueueIssueUseCase.js +3 -2
- package/bin/domain/usecases/RevertNotReadyReviewQueueIssueUseCase.js.map +1 -1
- package/bin/domain/usecases/RevertOrphanedPreparationUseCase.js +0 -43
- package/bin/domain/usecases/RevertOrphanedPreparationUseCase.js.map +1 -1
- package/bin/domain/usecases/autoStatusCheckComments.js +1 -11
- package/bin/domain/usecases/autoStatusCheckComments.js.map +1 -1
- package/bin/domain/usecases/extractNextStepAgentFromComments.js +14 -0
- package/bin/domain/usecases/extractNextStepAgentFromComments.js.map +1 -0
- package/bin/domain/usecases/triagerAgentName.js +7 -0
- package/bin/domain/usecases/triagerAgentName.js.map +1 -0
- package/jest.config.js +1 -0
- package/package.json +1 -1
- package/src/adapter/entry-points/cli/index.test.ts +0 -2
- package/src/adapter/entry-points/cli/index.ts +4 -10
- package/src/adapter/entry-points/cli/projectConfig.ts +0 -8
- package/src/adapter/entry-points/console/consoleAirplaneSnapshotApi.test.ts +658 -0
- package/src/adapter/entry-points/console/consoleAirplaneSnapshotApi.ts +482 -0
- package/src/adapter/entry-points/console/ui/jest-globals.cjs +26 -0
- package/src/adapter/entry-points/console/ui/src/features/console/components/detail/ConsoleFileDiff.test.tsx +10 -0
- package/src/adapter/entry-points/console/ui/src/features/console/components/detail/ConsoleFileDiff.tsx +23 -16
- package/src/adapter/entry-points/console/ui/src/features/console/components/layout/ConsoleAirplaneModeButton.stories.tsx +56 -0
- package/src/adapter/entry-points/console/ui/src/features/console/components/layout/ConsoleAirplaneModeButton.test.tsx +111 -0
- package/src/adapter/entry-points/console/ui/src/features/console/components/layout/ConsoleAirplaneModeButton.tsx +92 -0
- package/src/adapter/entry-points/console/ui/src/features/console/components/layout/ConsoleTabList.stories.tsx +15 -0
- package/src/adapter/entry-points/console/ui/src/features/console/components/layout/ConsoleTabList.test.tsx +19 -0
- package/src/adapter/entry-points/console/ui/src/features/console/components/layout/ConsoleTabList.tsx +30 -1
- package/src/adapter/entry-points/console/ui/src/features/console/components/operations/ConsoleErrorToast.stories.tsx +10 -0
- package/src/adapter/entry-points/console/ui/src/features/console/components/operations/ConsoleUndoToast.test.tsx +1 -3
- package/src/adapter/entry-points/console/ui/src/features/console/components/operations/ConsoleUndoToast.tsx +8 -7
- package/src/adapter/entry-points/console/ui/src/features/console/hooks/useAirplaneMode.test.ts +304 -0
- package/src/adapter/entry-points/console/ui/src/features/console/hooks/useAirplaneMode.ts +167 -0
- package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleActionQueue.test.ts +15 -0
- package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleActionQueue.ts +6 -1
- package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleCaches.test.ts +77 -0
- package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleCaches.ts +48 -3
- package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleFeaturesConfig.test.ts +51 -0
- package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleFeaturesConfig.ts +39 -0
- package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleTabData.test.ts +215 -0
- package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleTabData.ts +20 -1
- package/src/adapter/entry-points/console/ui/src/features/console/lib/airplaneSnapshot.test.ts +361 -0
- package/src/adapter/entry-points/console/ui/src/features/console/lib/airplaneSnapshot.ts +401 -0
- package/src/adapter/entry-points/console/ui/src/features/console/lib/resourceCache.ts +4 -0
- package/src/adapter/entry-points/console/ui/src/features/console/pages/ConsolePage.test.tsx +209 -0
- package/src/adapter/entry-points/console/ui/src/features/console/pages/ConsolePage.tsx +27 -2
- package/src/adapter/entry-points/console/ui-dist/assets/index-DkMqSpkk.js +88 -0
- package/src/adapter/entry-points/console/ui-dist/index.html +1 -1
- package/src/adapter/entry-points/console/webServer.test.ts +189 -0
- package/src/adapter/entry-points/console/webServer.ts +38 -0
- package/src/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.ts +0 -7
- package/src/domain/usecases/CheckIssueReviewReadinessUseCase.test.ts +26 -4
- package/src/domain/usecases/CheckIssueReviewReadinessUseCase.ts +5 -3
- package/src/domain/usecases/HandleScheduledEventUseCase.test.ts +0 -28
- package/src/domain/usecases/HandleScheduledEventUseCase.ts +0 -6
- package/src/domain/usecases/IssueRejectionEvaluator.test.ts +0 -119
- package/src/domain/usecases/IssueRejectionEvaluator.ts +0 -21
- package/src/domain/usecases/NotifyFinishedIssuePreparationUseCase.test.ts +185 -327
- package/src/domain/usecases/NotifyFinishedIssuePreparationUseCase.ts +68 -138
- package/src/domain/usecases/RevertNotReadyReviewQueueIssueUseCase.test.ts +4 -4
- package/src/domain/usecases/RevertNotReadyReviewQueueIssueUseCase.ts +11 -5
- package/src/domain/usecases/RevertOrphanedPreparationUseCase.test.ts +0 -313
- package/src/domain/usecases/RevertOrphanedPreparationUseCase.ts +1 -102
- package/src/domain/usecases/autoStatusCheckComments.ts +0 -17
- package/src/domain/usecases/extractNextStepAgentFromComments.ts +13 -0
- package/src/domain/usecases/isHumanComment.test.ts +0 -13
- package/src/domain/usecases/triagerAgentName.ts +4 -0
- package/types/adapter/entry-points/cli/index.d.ts.map +1 -1
- package/types/adapter/entry-points/cli/projectConfig.d.ts +0 -1
- package/types/adapter/entry-points/cli/projectConfig.d.ts.map +1 -1
- package/types/adapter/entry-points/console/consoleAirplaneSnapshotApi.d.ts +90 -0
- package/types/adapter/entry-points/console/consoleAirplaneSnapshotApi.d.ts.map +1 -0
- package/types/adapter/entry-points/console/webServer.d.ts +1 -0
- package/types/adapter/entry-points/console/webServer.d.ts.map +1 -1
- package/types/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.d.ts.map +1 -1
- package/types/domain/usecases/CheckIssueReviewReadinessUseCase.d.ts.map +1 -1
- package/types/domain/usecases/HandleScheduledEventUseCase.d.ts +1 -3
- package/types/domain/usecases/HandleScheduledEventUseCase.d.ts.map +1 -1
- package/types/domain/usecases/IssueRejectionEvaluator.d.ts +0 -1
- package/types/domain/usecases/IssueRejectionEvaluator.d.ts.map +1 -1
- package/types/domain/usecases/NotifyFinishedIssuePreparationUseCase.d.ts +0 -1
- package/types/domain/usecases/NotifyFinishedIssuePreparationUseCase.d.ts.map +1 -1
- package/types/domain/usecases/RevertNotReadyReviewQueueIssueUseCase.d.ts.map +1 -1
- package/types/domain/usecases/RevertOrphanedPreparationUseCase.d.ts +0 -1
- package/types/domain/usecases/RevertOrphanedPreparationUseCase.d.ts.map +1 -1
- package/types/domain/usecases/autoStatusCheckComments.d.ts +0 -4
- package/types/domain/usecases/autoStatusCheckComments.d.ts.map +1 -1
- package/types/domain/usecases/extractNextStepAgentFromComments.d.ts +5 -0
- package/types/domain/usecases/extractNextStepAgentFromComments.d.ts.map +1 -0
- package/types/domain/usecases/triagerAgentName.d.ts +3 -0
- package/types/domain/usecases/triagerAgentName.d.ts.map +1 -0
- package/bin/adapter/entry-points/console/ui-dist/assets/index-CaxYBHiT.js +0 -86
- package/src/adapter/entry-points/console/ui-dist/assets/index-CaxYBHiT.js +0 -86
- package/src/domain/usecases/TriagerApprovalDispatchUseCase.test.ts +0 -1051
- package/src/domain/usecases/TriagerApprovalDispatchUseCase.ts +0 -274
- package/src/domain/usecases/awaitingOwnerApprovalMessage.ts +0 -5
- package/src/domain/usecases/isPullRequestDeclaredUnnecessary.test.ts +0 -162
- package/src/domain/usecases/isPullRequestDeclaredUnnecessary.ts +0 -29
- package/src/domain/usecases/isWaitingForOwnerApproval.test.ts +0 -91
- package/src/domain/usecases/isWaitingForOwnerApproval.ts +0 -17
- package/src/domain/usecases/returnedToAwaitingWorkspaceMessage.ts +0 -5
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
type AirplaneSnapshot,
|
|
4
|
+
clearAirplaneSnapshot,
|
|
5
|
+
loadAirplaneSnapshot,
|
|
6
|
+
parseAirplaneSnapshot,
|
|
7
|
+
readAirplaneModeFlag,
|
|
8
|
+
storeAirplaneSnapshot,
|
|
9
|
+
writeAirplaneModeFlag,
|
|
10
|
+
} from '../lib/airplaneSnapshot';
|
|
11
|
+
|
|
12
|
+
export type AirplaneModeStatus = 'off' | 'syncing' | 'on' | 'error';
|
|
13
|
+
|
|
14
|
+
export type AirplaneSyncProgress = {
|
|
15
|
+
fetched: number;
|
|
16
|
+
total: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type AirplaneModeState = {
|
|
20
|
+
status: AirplaneModeStatus;
|
|
21
|
+
progress: AirplaneSyncProgress | null;
|
|
22
|
+
snapshot: AirplaneSnapshot | null;
|
|
23
|
+
failures: string[];
|
|
24
|
+
startSync: () => void;
|
|
25
|
+
turnOff: () => void;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const AIRPLANE_SYNC_PATH = '/api/airplanesync';
|
|
29
|
+
|
|
30
|
+
const parseSyncEvent = (
|
|
31
|
+
raw: string,
|
|
32
|
+
): { type: string; [key: string]: unknown } | null => {
|
|
33
|
+
try {
|
|
34
|
+
const parsed: unknown = JSON.parse(raw);
|
|
35
|
+
if (
|
|
36
|
+
parsed !== null &&
|
|
37
|
+
typeof parsed === 'object' &&
|
|
38
|
+
!Array.isArray(parsed) &&
|
|
39
|
+
'type' in parsed &&
|
|
40
|
+
typeof (parsed as { type: unknown }).type === 'string'
|
|
41
|
+
) {
|
|
42
|
+
return parsed as { type: string; [key: string]: unknown };
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const useAirplaneMode = (): AirplaneModeState => {
|
|
51
|
+
const [status, setStatus] = useState<AirplaneModeStatus>('off');
|
|
52
|
+
const [progress, setProgress] = useState<AirplaneSyncProgress | null>(null);
|
|
53
|
+
const [snapshot, setSnapshot] = useState<AirplaneSnapshot | null>(null);
|
|
54
|
+
const [failures, setFailures] = useState<string[]>([]);
|
|
55
|
+
const abortControllerRef = useRef<AbortController | null>(null);
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (!readAirplaneModeFlag()) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
let cancelled = false;
|
|
62
|
+
loadAirplaneSnapshot()
|
|
63
|
+
.then((stored) => {
|
|
64
|
+
if (cancelled || stored === null) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
setSnapshot(stored);
|
|
68
|
+
setStatus('on');
|
|
69
|
+
})
|
|
70
|
+
.catch(() => {
|
|
71
|
+
writeAirplaneModeFlag(false);
|
|
72
|
+
});
|
|
73
|
+
return () => {
|
|
74
|
+
cancelled = true;
|
|
75
|
+
};
|
|
76
|
+
}, []);
|
|
77
|
+
|
|
78
|
+
const startSync = useCallback((): void => {
|
|
79
|
+
if (abortControllerRef.current !== null) {
|
|
80
|
+
abortControllerRef.current.abort();
|
|
81
|
+
}
|
|
82
|
+
const controller = new AbortController();
|
|
83
|
+
abortControllerRef.current = controller;
|
|
84
|
+
|
|
85
|
+
setStatus('syncing');
|
|
86
|
+
setProgress({ fetched: 0, total: 0 });
|
|
87
|
+
setFailures([]);
|
|
88
|
+
|
|
89
|
+
fetch(AIRPLANE_SYNC_PATH, { signal: controller.signal })
|
|
90
|
+
.then(async (response) => {
|
|
91
|
+
if (!response.ok || response.body === null) {
|
|
92
|
+
setStatus('error');
|
|
93
|
+
setFailures([`HTTP ${response.status}`]);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const reader = response.body
|
|
98
|
+
.pipeThrough(new TextDecoderStream())
|
|
99
|
+
.getReader();
|
|
100
|
+
|
|
101
|
+
let buffer = '';
|
|
102
|
+
for (;;) {
|
|
103
|
+
const { done, value } = await reader.read();
|
|
104
|
+
if (done) {
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
buffer += value;
|
|
108
|
+
const blocks = buffer.split('\n\n');
|
|
109
|
+
buffer = blocks.pop() ?? '';
|
|
110
|
+
for (const block of blocks) {
|
|
111
|
+
if (!block.startsWith('data: ')) {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const event = parseSyncEvent(block.slice('data: '.length));
|
|
115
|
+
if (event === null) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (event.type === 'progress') {
|
|
119
|
+
setProgress({
|
|
120
|
+
fetched: typeof event.fetched === 'number' ? event.fetched : 0,
|
|
121
|
+
total: typeof event.total === 'number' ? event.total : 0,
|
|
122
|
+
});
|
|
123
|
+
} else if (event.type === 'done') {
|
|
124
|
+
const parsed = parseAirplaneSnapshot(event.snapshot);
|
|
125
|
+
if (parsed === null) {
|
|
126
|
+
setStatus('error');
|
|
127
|
+
setFailures(['Failed to parse snapshot']);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (parsed.failures.length > 0) {
|
|
131
|
+
setFailures(parsed.failures);
|
|
132
|
+
setStatus('error');
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
await storeAirplaneSnapshot(parsed);
|
|
136
|
+
writeAirplaneModeFlag(true);
|
|
137
|
+
setSnapshot(parsed);
|
|
138
|
+
setStatus('on');
|
|
139
|
+
setFailures([]);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
.catch((error: unknown) => {
|
|
145
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
setStatus('error');
|
|
149
|
+
setFailures([error instanceof Error ? error.message : String(error)]);
|
|
150
|
+
});
|
|
151
|
+
}, []);
|
|
152
|
+
|
|
153
|
+
const turnOff = useCallback((): void => {
|
|
154
|
+
if (abortControllerRef.current !== null) {
|
|
155
|
+
abortControllerRef.current.abort();
|
|
156
|
+
abortControllerRef.current = null;
|
|
157
|
+
}
|
|
158
|
+
setStatus('off');
|
|
159
|
+
setSnapshot(null);
|
|
160
|
+
setProgress(null);
|
|
161
|
+
setFailures([]);
|
|
162
|
+
writeAirplaneModeFlag(false);
|
|
163
|
+
clearAirplaneSnapshot().catch(() => {});
|
|
164
|
+
}, []);
|
|
165
|
+
|
|
166
|
+
return { status, progress, snapshot, failures, startSync, turnOff };
|
|
167
|
+
};
|
package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleActionQueue.test.ts
CHANGED
|
@@ -197,4 +197,19 @@ describe('useConsoleActionQueue', () => {
|
|
|
197
197
|
});
|
|
198
198
|
expect(result.current.error).toBeNull();
|
|
199
199
|
});
|
|
200
|
+
|
|
201
|
+
it('showError sets the error state without touching pending', () => {
|
|
202
|
+
const { result } = renderHook(() => useConsoleActionQueue());
|
|
203
|
+
act(() => {
|
|
204
|
+
result.current.showError(
|
|
205
|
+
'Airplane mode',
|
|
206
|
+
'This action requires a network connection.',
|
|
207
|
+
);
|
|
208
|
+
});
|
|
209
|
+
expect(result.current.error).toEqual({
|
|
210
|
+
message: 'Airplane mode',
|
|
211
|
+
reason: 'This action requires a network connection.',
|
|
212
|
+
});
|
|
213
|
+
expect(result.current.pending).toBeNull();
|
|
214
|
+
});
|
|
200
215
|
});
|
package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleActionQueue.ts
CHANGED
|
@@ -42,6 +42,7 @@ export type ConsoleActionQueue = {
|
|
|
42
42
|
pending: ConsolePendingActionView | null;
|
|
43
43
|
error: ConsoleActionError | null;
|
|
44
44
|
enqueue: (action: ConsoleQueuedAction) => void;
|
|
45
|
+
showError: (message: string, reason: string) => void;
|
|
45
46
|
undo: () => void;
|
|
46
47
|
dismissError: () => void;
|
|
47
48
|
};
|
|
@@ -89,6 +90,10 @@ export const useConsoleActionQueue = (): ConsoleActionQueue => {
|
|
|
89
90
|
setError(null);
|
|
90
91
|
}, []);
|
|
91
92
|
|
|
93
|
+
const showError = useCallback((message: string, reason: string): void => {
|
|
94
|
+
setError({ message, reason });
|
|
95
|
+
}, []);
|
|
96
|
+
|
|
92
97
|
const enqueue = useCallback(
|
|
93
98
|
(action: ConsoleQueuedAction): void => {
|
|
94
99
|
if (actionRef.current !== null && !committedRef.current) {
|
|
@@ -126,5 +131,5 @@ export const useConsoleActionQueue = (): ConsoleActionQueue => {
|
|
|
126
131
|
|
|
127
132
|
useEffect(() => clearTimer, [clearTimer]);
|
|
128
133
|
|
|
129
|
-
return { pending, error, enqueue, undo, dismissError };
|
|
134
|
+
return { pending, error, enqueue, showError, undo, dismissError };
|
|
130
135
|
};
|
package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleCaches.test.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { renderHook } from '@testing-library/react';
|
|
2
|
+
import type { AirplaneSnapshot } from '../lib/airplaneSnapshot';
|
|
2
3
|
import { useConsoleCaches } from './useConsoleCaches';
|
|
3
4
|
|
|
4
5
|
describe('useConsoleCaches', () => {
|
|
@@ -19,4 +20,80 @@ describe('useConsoleCaches', () => {
|
|
|
19
20
|
rerender();
|
|
20
21
|
expect(result.current).toBe(first);
|
|
21
22
|
});
|
|
23
|
+
|
|
24
|
+
it('pre-seeds item detail caches from airplane snapshot so item detail renders with network rejecting', () => {
|
|
25
|
+
const prUrl = 'https://github.com/owner/repo/pull/42';
|
|
26
|
+
const airplaneSnapshot: AirplaneSnapshot = {
|
|
27
|
+
capturedAt: '2026-08-01T10:00:00Z',
|
|
28
|
+
failures: [],
|
|
29
|
+
tabs: {},
|
|
30
|
+
items: {
|
|
31
|
+
[prUrl]: {
|
|
32
|
+
body: 'PR body text',
|
|
33
|
+
comments: [
|
|
34
|
+
{
|
|
35
|
+
author: 'alice',
|
|
36
|
+
body: 'LGTM',
|
|
37
|
+
createdAt: '2026-08-01T09:00:00Z',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
state: {
|
|
41
|
+
state: 'open',
|
|
42
|
+
merged: false,
|
|
43
|
+
isPullRequest: true,
|
|
44
|
+
title: 'Offline PR',
|
|
45
|
+
},
|
|
46
|
+
files: [
|
|
47
|
+
{
|
|
48
|
+
path: 'src/foo.ts',
|
|
49
|
+
additions: 3,
|
|
50
|
+
deletions: 1,
|
|
51
|
+
status: 'modified',
|
|
52
|
+
patch: '@@ -1 +1 @@\n-old\n+new',
|
|
53
|
+
rawUrl: null,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
commits: [
|
|
57
|
+
{
|
|
58
|
+
sha: 'abc123',
|
|
59
|
+
message: 'fix: something',
|
|
60
|
+
author: 'alice',
|
|
61
|
+
authoredAt: '2026-08-01T08:00:00Z',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
prStatus: {
|
|
65
|
+
found: true,
|
|
66
|
+
isConflicted: false,
|
|
67
|
+
mergeableStatus: 'MERGEABLE',
|
|
68
|
+
isPassedAllCiJob: true,
|
|
69
|
+
isCiStateSuccess: true,
|
|
70
|
+
isBranchOutOfDate: false,
|
|
71
|
+
missingRequiredCheckNames: [],
|
|
72
|
+
},
|
|
73
|
+
relatedPrs: null,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const { result } = renderHook(() => useConsoleCaches(airplaneSnapshot));
|
|
79
|
+
|
|
80
|
+
const cacheKey = 'owner/repo#42';
|
|
81
|
+
expect(result.current.body.peek(cacheKey)).toBe('PR body text');
|
|
82
|
+
|
|
83
|
+
const comments = result.current.comments.peek(cacheKey);
|
|
84
|
+
expect(comments).toHaveLength(1);
|
|
85
|
+
expect(comments?.[0].author).toBe('alice');
|
|
86
|
+
|
|
87
|
+
const files = result.current.files.peek(cacheKey);
|
|
88
|
+
expect(files).toHaveLength(1);
|
|
89
|
+
expect(files?.[0].path).toBe('src/foo.ts');
|
|
90
|
+
|
|
91
|
+
const commits = result.current.commits.peek(cacheKey);
|
|
92
|
+
expect(commits).toHaveLength(1);
|
|
93
|
+
expect(commits?.[0].sha).toBe('abc123');
|
|
94
|
+
|
|
95
|
+
const prStatus = result.current.prStatus.peek(cacheKey);
|
|
96
|
+
expect(prStatus?.isPassedAllCiJob).toBe(true);
|
|
97
|
+
expect(prStatus?.mergeableStatus).toBe('MERGEABLE');
|
|
98
|
+
});
|
|
22
99
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
+
import type { AirplaneSnapshot } from '../lib/airplaneSnapshot';
|
|
2
3
|
import {
|
|
3
4
|
type ConsoleApiClient,
|
|
4
5
|
createConsoleApiClient,
|
|
@@ -24,10 +25,50 @@ export type ConsoleCaches = {
|
|
|
24
25
|
client: ConsoleApiClient;
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
const deriveCacheKey = (url: string): string => {
|
|
29
|
+
try {
|
|
30
|
+
const urlObj = new URL(url);
|
|
31
|
+
const parts = urlObj.pathname.split('/').filter(Boolean);
|
|
32
|
+
if (parts.length >= 4) {
|
|
33
|
+
const owner = parts[0];
|
|
34
|
+
const repoName = parts[1];
|
|
35
|
+
const number = parts[3];
|
|
36
|
+
return `${owner}/${repoName}#${number}`;
|
|
37
|
+
}
|
|
38
|
+
} catch {}
|
|
39
|
+
return url;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const populateCachesFromSnapshot = (
|
|
43
|
+
caches: ConsoleCaches,
|
|
44
|
+
snapshot: AirplaneSnapshot,
|
|
45
|
+
): void => {
|
|
46
|
+
for (const [url, item] of Object.entries(snapshot.items)) {
|
|
47
|
+
const key = deriveCacheKey(url);
|
|
48
|
+
caches.body.seed(key, item.body);
|
|
49
|
+
caches.comments.seed(key, item.comments);
|
|
50
|
+
caches.state.seed(key, item.state);
|
|
51
|
+
if (item.files !== null) {
|
|
52
|
+
caches.files.seed(key, item.files);
|
|
53
|
+
}
|
|
54
|
+
if (item.commits !== null) {
|
|
55
|
+
caches.commits.seed(key, item.commits);
|
|
56
|
+
}
|
|
57
|
+
if (item.prStatus !== null) {
|
|
58
|
+
caches.prStatus.seed(key, item.prStatus);
|
|
59
|
+
}
|
|
60
|
+
if (item.relatedPrs !== null) {
|
|
61
|
+
caches.relatedPrs.seed(key, item.relatedPrs);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const useConsoleCaches = (
|
|
67
|
+
airplaneSnapshot: AirplaneSnapshot | null = null,
|
|
68
|
+
): ConsoleCaches => {
|
|
28
69
|
return useMemo(() => {
|
|
29
70
|
const client = createConsoleApiClient();
|
|
30
|
-
|
|
71
|
+
const caches: ConsoleCaches = {
|
|
31
72
|
client,
|
|
32
73
|
body: new ResourceCache<string>(client.fetchItemBody),
|
|
33
74
|
comments: new ResourceCache<ConsoleComment[]>(client.fetchComments),
|
|
@@ -41,5 +82,9 @@ export const useConsoleCaches = (): ConsoleCaches => {
|
|
|
41
82
|
client.fetchPullRequestStatus,
|
|
42
83
|
),
|
|
43
84
|
};
|
|
44
|
-
|
|
85
|
+
if (airplaneSnapshot !== null) {
|
|
86
|
+
populateCachesFromSnapshot(caches, airplaneSnapshot);
|
|
87
|
+
}
|
|
88
|
+
return caches;
|
|
89
|
+
}, [airplaneSnapshot]);
|
|
45
90
|
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { renderHook, waitFor } from '@testing-library/react';
|
|
2
|
+
import { useConsoleFeaturesConfig } from './useConsoleFeaturesConfig';
|
|
3
|
+
|
|
4
|
+
describe('useConsoleFeaturesConfig', () => {
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
jest.restoreAllMocks();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('returns airplaneMode false while loading (initial state)', () => {
|
|
10
|
+
global.fetch = jest.fn().mockReturnValue(new Promise(() => {}));
|
|
11
|
+
const { result } = renderHook(() => useConsoleFeaturesConfig());
|
|
12
|
+
expect(result.current.airplaneMode).toBe(false);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('returns airplaneMode true when /api/features responds { airplaneMode: true }', async () => {
|
|
16
|
+
global.fetch = jest.fn().mockResolvedValue({
|
|
17
|
+
ok: true,
|
|
18
|
+
json: async () => ({ airplaneMode: true }),
|
|
19
|
+
});
|
|
20
|
+
const { result } = renderHook(() => useConsoleFeaturesConfig());
|
|
21
|
+
await waitFor(() => expect(result.current.airplaneMode).toBe(true));
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('returns airplaneMode false when /api/features responds { airplaneMode: false }', async () => {
|
|
25
|
+
global.fetch = jest.fn().mockResolvedValue({
|
|
26
|
+
ok: true,
|
|
27
|
+
json: async () => ({ airplaneMode: false }),
|
|
28
|
+
});
|
|
29
|
+
const { result } = renderHook(() => useConsoleFeaturesConfig());
|
|
30
|
+
await waitFor(() => expect(global.fetch).toHaveBeenCalled());
|
|
31
|
+
expect(result.current.airplaneMode).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('returns airplaneMode false on fetch failure', async () => {
|
|
35
|
+
global.fetch = jest.fn().mockRejectedValue(new Error('network error'));
|
|
36
|
+
const consoleSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
37
|
+
const { result } = renderHook(() => useConsoleFeaturesConfig());
|
|
38
|
+
await waitFor(() => expect(consoleSpy).toHaveBeenCalled());
|
|
39
|
+
expect(result.current.airplaneMode).toBe(false);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('returns airplaneMode false when response is not ok', async () => {
|
|
43
|
+
global.fetch = jest.fn().mockResolvedValue({
|
|
44
|
+
ok: false,
|
|
45
|
+
json: async () => ({ airplaneMode: true }),
|
|
46
|
+
});
|
|
47
|
+
const { result } = renderHook(() => useConsoleFeaturesConfig());
|
|
48
|
+
await waitFor(() => expect(global.fetch).toHaveBeenCalled());
|
|
49
|
+
expect(result.current.airplaneMode).toBe(false);
|
|
50
|
+
});
|
|
51
|
+
});
|
package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleFeaturesConfig.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
export type ConsoleFeaturesConfig = {
|
|
4
|
+
airplaneMode: boolean;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const FEATURES_PATH = '/api/features';
|
|
8
|
+
|
|
9
|
+
export const useConsoleFeaturesConfig = (): ConsoleFeaturesConfig => {
|
|
10
|
+
const [config, setConfig] = useState<ConsoleFeaturesConfig>({
|
|
11
|
+
airplaneMode: false,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
fetch(FEATURES_PATH)
|
|
16
|
+
.then(async (response) => {
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const data: unknown = await response.json();
|
|
21
|
+
if (
|
|
22
|
+
data !== null &&
|
|
23
|
+
typeof data === 'object' &&
|
|
24
|
+
!Array.isArray(data) &&
|
|
25
|
+
'airplaneMode' in data &&
|
|
26
|
+
typeof (data as { airplaneMode: unknown }).airplaneMode === 'boolean'
|
|
27
|
+
) {
|
|
28
|
+
setConfig({
|
|
29
|
+
airplaneMode: (data as { airplaneMode: boolean }).airplaneMode,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
.catch((err: unknown) => {
|
|
34
|
+
console.warn('Failed to fetch /api/features', err);
|
|
35
|
+
});
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
return config;
|
|
39
|
+
};
|
package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleTabData.test.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { act, renderHook, waitFor } from '@testing-library/react';
|
|
2
|
+
import type { AirplaneSnapshot } from '../lib/airplaneSnapshot';
|
|
2
3
|
import { CONSOLE_TABS } from '../logic/types';
|
|
3
4
|
import {
|
|
4
5
|
CONSOLE_TAB_REFRESH_INTERVAL_MS,
|
|
@@ -257,4 +258,218 @@ describe('useConsoleTabData', () => {
|
|
|
257
258
|
expect(result.current.error).toBe('No project specified in the URL path.');
|
|
258
259
|
expect(fetchMock).not.toHaveBeenCalled();
|
|
259
260
|
});
|
|
261
|
+
|
|
262
|
+
it('renders board items from airplane snapshot without fetching when network rejects', async () => {
|
|
263
|
+
const fetchMock = jest.fn().mockRejectedValue(new Error('network down'));
|
|
264
|
+
global.fetch = fetchMock as unknown as typeof fetch;
|
|
265
|
+
|
|
266
|
+
const airplaneSnapshot: AirplaneSnapshot = {
|
|
267
|
+
capturedAt: '2026-08-01T10:00:00Z',
|
|
268
|
+
failures: [],
|
|
269
|
+
items: {},
|
|
270
|
+
tabs: {
|
|
271
|
+
acme: {
|
|
272
|
+
prs: {
|
|
273
|
+
generatedAt: '2026-08-01T10:00:00Z',
|
|
274
|
+
statusOptions: [],
|
|
275
|
+
storyOptions: [],
|
|
276
|
+
storyColors: {},
|
|
277
|
+
stories: [],
|
|
278
|
+
defaultNameWithOwner: null,
|
|
279
|
+
fromCache: false,
|
|
280
|
+
storyOrder: [],
|
|
281
|
+
items: [
|
|
282
|
+
{
|
|
283
|
+
number: 1,
|
|
284
|
+
title: 'Offline PR',
|
|
285
|
+
url: 'https://github.com/o/r/pull/1',
|
|
286
|
+
repo: 'o/r',
|
|
287
|
+
nameWithOwner: 'o/r',
|
|
288
|
+
projectItemId: 'PVTI_1',
|
|
289
|
+
itemId: 'PVTI_1',
|
|
290
|
+
isPr: true,
|
|
291
|
+
story: 'regular',
|
|
292
|
+
status: 'Awaiting Quality Check',
|
|
293
|
+
nextActionDate: null,
|
|
294
|
+
nextActionHour: null,
|
|
295
|
+
dependedIssueUrls: [],
|
|
296
|
+
labels: [],
|
|
297
|
+
createdAt: '2026-08-01T00:00:00Z',
|
|
298
|
+
relatedOpenPullRequestUrls: [],
|
|
299
|
+
agent: null,
|
|
300
|
+
},
|
|
301
|
+
],
|
|
302
|
+
},
|
|
303
|
+
'workflow-blocker': {
|
|
304
|
+
generatedAt: '2026-08-01T10:00:00Z',
|
|
305
|
+
statusOptions: [],
|
|
306
|
+
storyOptions: [],
|
|
307
|
+
storyColors: {},
|
|
308
|
+
items: [],
|
|
309
|
+
stories: [],
|
|
310
|
+
defaultNameWithOwner: null,
|
|
311
|
+
fromCache: false,
|
|
312
|
+
storyOrder: [],
|
|
313
|
+
},
|
|
314
|
+
'failed-preparation': {
|
|
315
|
+
generatedAt: '2026-08-01T10:00:00Z',
|
|
316
|
+
statusOptions: [],
|
|
317
|
+
storyOptions: [],
|
|
318
|
+
storyColors: {},
|
|
319
|
+
items: [],
|
|
320
|
+
stories: [],
|
|
321
|
+
defaultNameWithOwner: null,
|
|
322
|
+
fromCache: false,
|
|
323
|
+
storyOrder: [],
|
|
324
|
+
},
|
|
325
|
+
'todo-by-human': {
|
|
326
|
+
generatedAt: '2026-08-01T10:00:00Z',
|
|
327
|
+
statusOptions: [],
|
|
328
|
+
storyOptions: [],
|
|
329
|
+
storyColors: {},
|
|
330
|
+
items: [],
|
|
331
|
+
stories: [],
|
|
332
|
+
defaultNameWithOwner: null,
|
|
333
|
+
fromCache: false,
|
|
334
|
+
storyOrder: [],
|
|
335
|
+
},
|
|
336
|
+
'todo-by-agent': {
|
|
337
|
+
generatedAt: '2026-08-01T10:00:00Z',
|
|
338
|
+
statusOptions: [],
|
|
339
|
+
storyOptions: [],
|
|
340
|
+
storyColors: {},
|
|
341
|
+
items: [],
|
|
342
|
+
stories: [],
|
|
343
|
+
defaultNameWithOwner: null,
|
|
344
|
+
fromCache: false,
|
|
345
|
+
storyOrder: [],
|
|
346
|
+
},
|
|
347
|
+
stories: {
|
|
348
|
+
generatedAt: '2026-08-01T10:00:00Z',
|
|
349
|
+
statusOptions: [],
|
|
350
|
+
storyOptions: [],
|
|
351
|
+
storyColors: {},
|
|
352
|
+
items: [],
|
|
353
|
+
stories: [],
|
|
354
|
+
defaultNameWithOwner: null,
|
|
355
|
+
fromCache: false,
|
|
356
|
+
storyOrder: [],
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
const { result } = renderHook(() =>
|
|
363
|
+
useConsoleTabData('acme', airplaneSnapshot),
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
await waitFor(() => {
|
|
367
|
+
expect(result.current.isLoading).toBe(false);
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
371
|
+
expect(result.current.error).toBeNull();
|
|
372
|
+
expect(result.current.snapshots.prs?.items).toHaveLength(1);
|
|
373
|
+
expect(result.current.snapshots.prs?.items[0].title).toBe('Offline PR');
|
|
374
|
+
expect(result.current.snapshots.prs?.generatedAt).toBe(
|
|
375
|
+
'2026-08-01T10:00:00Z',
|
|
376
|
+
);
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
it('stops the 60-second periodic refresh while an airplane snapshot is in use', async () => {
|
|
380
|
+
jest.useFakeTimers();
|
|
381
|
+
const fetchMock = jest.fn().mockRejectedValue(new Error('network down'));
|
|
382
|
+
global.fetch = fetchMock as unknown as typeof fetch;
|
|
383
|
+
|
|
384
|
+
const airplaneSnapshot: AirplaneSnapshot = {
|
|
385
|
+
capturedAt: '2026-08-01T10:00:00Z',
|
|
386
|
+
failures: [],
|
|
387
|
+
items: {},
|
|
388
|
+
tabs: {
|
|
389
|
+
acme: {
|
|
390
|
+
prs: {
|
|
391
|
+
generatedAt: '2026-08-01T10:00:00Z',
|
|
392
|
+
statusOptions: [],
|
|
393
|
+
storyOptions: [],
|
|
394
|
+
storyColors: {},
|
|
395
|
+
items: [],
|
|
396
|
+
stories: [],
|
|
397
|
+
defaultNameWithOwner: null,
|
|
398
|
+
fromCache: false,
|
|
399
|
+
storyOrder: [],
|
|
400
|
+
},
|
|
401
|
+
'workflow-blocker': {
|
|
402
|
+
generatedAt: '2026-08-01T10:00:00Z',
|
|
403
|
+
statusOptions: [],
|
|
404
|
+
storyOptions: [],
|
|
405
|
+
storyColors: {},
|
|
406
|
+
items: [],
|
|
407
|
+
stories: [],
|
|
408
|
+
defaultNameWithOwner: null,
|
|
409
|
+
fromCache: false,
|
|
410
|
+
storyOrder: [],
|
|
411
|
+
},
|
|
412
|
+
'failed-preparation': {
|
|
413
|
+
generatedAt: '2026-08-01T10:00:00Z',
|
|
414
|
+
statusOptions: [],
|
|
415
|
+
storyOptions: [],
|
|
416
|
+
storyColors: {},
|
|
417
|
+
items: [],
|
|
418
|
+
stories: [],
|
|
419
|
+
defaultNameWithOwner: null,
|
|
420
|
+
fromCache: false,
|
|
421
|
+
storyOrder: [],
|
|
422
|
+
},
|
|
423
|
+
'todo-by-human': {
|
|
424
|
+
generatedAt: '2026-08-01T10:00:00Z',
|
|
425
|
+
statusOptions: [],
|
|
426
|
+
storyOptions: [],
|
|
427
|
+
storyColors: {},
|
|
428
|
+
items: [],
|
|
429
|
+
stories: [],
|
|
430
|
+
defaultNameWithOwner: null,
|
|
431
|
+
fromCache: false,
|
|
432
|
+
storyOrder: [],
|
|
433
|
+
},
|
|
434
|
+
'todo-by-agent': {
|
|
435
|
+
generatedAt: '2026-08-01T10:00:00Z',
|
|
436
|
+
statusOptions: [],
|
|
437
|
+
storyOptions: [],
|
|
438
|
+
storyColors: {},
|
|
439
|
+
items: [],
|
|
440
|
+
stories: [],
|
|
441
|
+
defaultNameWithOwner: null,
|
|
442
|
+
fromCache: false,
|
|
443
|
+
storyOrder: [],
|
|
444
|
+
},
|
|
445
|
+
stories: {
|
|
446
|
+
generatedAt: '2026-08-01T10:00:00Z',
|
|
447
|
+
statusOptions: [],
|
|
448
|
+
storyOptions: [],
|
|
449
|
+
storyColors: {},
|
|
450
|
+
items: [],
|
|
451
|
+
stories: [],
|
|
452
|
+
defaultNameWithOwner: null,
|
|
453
|
+
fromCache: false,
|
|
454
|
+
storyOrder: [],
|
|
455
|
+
},
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
const { result } = renderHook(() =>
|
|
461
|
+
useConsoleTabData('acme', airplaneSnapshot),
|
|
462
|
+
);
|
|
463
|
+
|
|
464
|
+
await waitFor(() => {
|
|
465
|
+
expect(result.current.isLoading).toBe(false);
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
act(() => {
|
|
469
|
+
jest.advanceTimersByTime(CONSOLE_TAB_REFRESH_INTERVAL_MS * 3);
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
473
|
+
jest.useRealTimers();
|
|
474
|
+
});
|
|
260
475
|
});
|