@bevel-software/platform-core-frontend 0.1.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/LICENSE +202 -0
- package/package.json +70 -0
- package/src/core/CoreAppShell.tsx +444 -0
- package/src/core/__tests__/ShellRoutes.test.tsx +95 -0
- package/src/core/events.ts +29 -0
- package/src/core/registry.ts +336 -0
- package/src/css-side-effect-imports.d.ts +7 -0
- package/src/html-extensions.ts +12 -0
- package/src/index.css +49 -0
- package/src/index.ts +23 -0
- package/src/lib/api.ts +57 -0
- package/src/lib/utils.ts +138 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +130 -0
- package/src/modules/access/__tests__/useFileAccess.test.tsx +253 -0
- package/src/modules/access/api.ts +205 -0
- package/src/modules/access/components/AccessRestrictedBanner.tsx +31 -0
- package/src/modules/access/components/ManageAccessDialog.tsx +1232 -0
- package/src/modules/access/components/NodeOwnersBanner.tsx +30 -0
- package/src/modules/access/hooks/useFileAccess.ts +151 -0
- package/src/modules/admin/components/AdminRolesPage.tsx +943 -0
- package/src/modules/admin/components/RolesCorruptedBanner.tsx +74 -0
- package/src/modules/admin/services/admin.api.ts +92 -0
- package/src/modules/admin/services/roles.api.ts +136 -0
- package/src/modules/admin/state/admin.context.tsx +223 -0
- package/src/modules/auth/components/LoginScreen.tsx +135 -0
- package/src/modules/auth/hooks/useAuthState.ts +59 -0
- package/src/modules/auth/services/auth.api.ts +24 -0
- package/src/modules/auth/services/microsoft-oauth.ts +57 -0
- package/src/modules/auth/state/auth.context.ts +18 -0
- package/src/modules/git/__tests__/BranchSwitcher.test.tsx +347 -0
- package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +201 -0
- package/src/modules/git/__tests__/ProtectedBranchBanner.test.tsx +82 -0
- package/src/modules/git/__tests__/PullNeededBanner.test.tsx +441 -0
- package/src/modules/git/__tests__/git.api.test.ts +113 -0
- package/src/modules/git/__tests__/pr.api.test.ts +44 -0
- package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +212 -0
- package/src/modules/git/components/BranchSwitcher.tsx +527 -0
- package/src/modules/git/components/DiffView.tsx +30 -0
- package/src/modules/git/components/FileComparisonPanel.tsx +377 -0
- package/src/modules/git/components/FileHistoryPanel.tsx +320 -0
- package/src/modules/git/components/ProtectedBranchBanner.tsx +42 -0
- package/src/modules/git/components/PullNeededBanner.tsx +204 -0
- package/src/modules/git/components/PullRequestsForMe.tsx +244 -0
- package/src/modules/git/components/UnifiedDiffView.tsx +37 -0
- package/src/modules/git/hooks/__tests__/useGitState.deleteBranch.test.tsx +99 -0
- package/src/modules/git/hooks/useAutoPullUpdates.ts +121 -0
- package/src/modules/git/hooks/useGitState.ts +335 -0
- package/src/modules/git/services/__tests__/error-messages.test.ts +134 -0
- package/src/modules/git/services/error-messages.ts +257 -0
- package/src/modules/git/services/git.api.ts +163 -0
- package/src/modules/git/services/pr-prompts.ts +159 -0
- package/src/modules/git/services/pr.api.ts +39 -0
- package/src/modules/git/state/auto-update.context.ts +21 -0
- package/src/modules/git/state/git.context.ts +82 -0
- package/src/modules/layout/components/AppLayout.tsx +40 -0
- package/src/modules/layout/components/DemoBanner.tsx +57 -0
- package/src/modules/layout/components/MaintenanceOverlay.tsx +104 -0
- package/src/modules/layout/components/MobileChatLayout.tsx +153 -0
- package/src/modules/layout/components/ResizableThreePaneLayout.tsx +203 -0
- package/src/modules/layout/components/SlideOverlay.tsx +224 -0
- package/src/modules/layout/components/__tests__/MobileChatLayout.test.tsx +77 -0
- package/src/modules/layout/components/__tests__/ResizableThreePaneLayout.test.tsx +57 -0
- package/src/modules/layout/hooks/useMediaQuery.ts +23 -0
- package/src/modules/layout/state/__tests__/layout.context.test.tsx +39 -0
- package/src/modules/layout/state/layout.context.ts +46 -0
- package/src/modules/library/__tests__/DetailDialog.test.tsx +200 -0
- package/src/modules/library/__tests__/diff.test.ts +62 -0
- package/src/modules/library/__tests__/loadout.test.tsx +72 -0
- package/src/modules/library/__tests__/status.test.ts +117 -0
- package/src/modules/library/components/ChangeRequestDock.tsx +47 -0
- package/src/modules/library/components/CompareView.tsx +357 -0
- package/src/modules/library/components/DetailDialog.tsx +566 -0
- package/src/modules/library/components/GearIcon.tsx +12 -0
- package/src/modules/library/components/LibraryCard.tsx +132 -0
- package/src/modules/library/components/LibraryPage.tsx +254 -0
- package/src/modules/library/components/LoadoutSidebar.tsx +156 -0
- package/src/modules/library/components/StatusGem.tsx +21 -0
- package/src/modules/library/components/SuggestChange.tsx +171 -0
- package/src/modules/library/components/particles.ts +50 -0
- package/src/modules/library/hooks/useLibraryData.ts +119 -0
- package/src/modules/library/hooks/useSkillDetail.ts +74 -0
- package/src/modules/library/library.css +320 -0
- package/src/modules/library/services/library.api.ts +164 -0
- package/src/modules/library/state/loadout.tsx +129 -0
- package/src/modules/library/state/toast.tsx +42 -0
- package/src/modules/library/utils/diff.ts +102 -0
- package/src/modules/library/utils/status.ts +116 -0
- package/src/modules/pr/__tests__/PrApprovalBadge.test.tsx +93 -0
- package/src/modules/pr/__tests__/PrCancelButton.test.tsx +158 -0
- package/src/modules/pr/__tests__/PrCancelConfirmDialog.test.tsx +44 -0
- package/src/modules/pr/__tests__/PrMergeButton.test.tsx +360 -0
- package/src/modules/pr/__tests__/bucketize-comments.test.ts +85 -0
- package/src/modules/pr/__tests__/parsePatch.test.ts +104 -0
- package/src/modules/pr/__tests__/usePrViewerState.test.ts +72 -0
- package/src/modules/pr/components/OpenChangeRequestDialog.tsx +193 -0
- package/src/modules/pr/components/PrApprovalBadge.tsx +80 -0
- package/src/modules/pr/components/PrCancelButton.tsx +99 -0
- package/src/modules/pr/components/PrCancelConfirmDialog.tsx +119 -0
- package/src/modules/pr/components/PrCommentComposer.tsx +92 -0
- package/src/modules/pr/components/PrCommentThread.tsx +168 -0
- package/src/modules/pr/components/PrCommentsPanel.tsx +143 -0
- package/src/modules/pr/components/PrDiffPane.tsx +425 -0
- package/src/modules/pr/components/PrFileRow.tsx +164 -0
- package/src/modules/pr/components/PrFilesList.tsx +53 -0
- package/src/modules/pr/components/PrHeader.tsx +45 -0
- package/src/modules/pr/components/PrHeaderOverflowMenu.tsx +58 -0
- package/src/modules/pr/components/PrMergeButton.tsx +268 -0
- package/src/modules/pr/components/PrMergeConfirmDialog.tsx +112 -0
- package/src/modules/pr/components/PrRefreshFromTargetButton.tsx +110 -0
- package/src/modules/pr/components/PrViewer.tsx +364 -0
- package/src/modules/pr/hooks/usePrViewerState.ts +150 -0
- package/src/modules/pr/services/pr-approvals.api.ts +31 -0
- package/src/modules/pr/services/pr-cancel.api.ts +19 -0
- package/src/modules/pr/services/pr-comments.api.ts +45 -0
- package/src/modules/pr/services/pr-detail.api.ts +17 -0
- package/src/modules/pr/services/pr-merge.api.ts +53 -0
- package/src/modules/pr/services/pr-open.api.ts +30 -0
- package/src/modules/pr/state/pr-viewer.context.ts +34 -0
- package/src/modules/pr/utils/bucketize-comments.ts +55 -0
- package/src/modules/pr/utils/parsePatch.ts +57 -0
- package/src/modules/review/__tests__/review.api.test.ts +121 -0
- package/src/modules/review/components/BinaryChangePlaceholder.tsx +15 -0
- package/src/modules/review/components/DiffViewer.tsx +78 -0
- package/src/modules/review/components/MarkdownDiffViewer.tsx +263 -0
- package/src/modules/review/components/ReviewFileRow.tsx +114 -0
- package/src/modules/review/components/ReviewPanel.tsx +260 -0
- package/src/modules/review/components/ReviewPanelSurface.tsx +52 -0
- package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +106 -0
- package/src/modules/review/hooks/__tests__/useReviewState.test.ts +88 -0
- package/src/modules/review/hooks/useReviewState.ts +256 -0
- package/src/modules/review/services/review.api.ts +72 -0
- package/src/modules/review/state/ReviewProvider.tsx +28 -0
- package/src/modules/review/state/review.context.ts +29 -0
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +488 -0
- package/src/modules/secrets-vault/components/SecretsPage.tsx +276 -0
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +362 -0
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +51 -0
- package/src/modules/secrets-vault/services/connect.api.ts +113 -0
- package/src/modules/secrets-vault/services/secrets.api.ts +82 -0
- package/src/modules/secrets-vault/services/tool-secrets.api.ts +116 -0
- package/src/modules/toolbar/components/AdminMenu.tsx +250 -0
- package/src/modules/toolbar/components/AppSwitcher.tsx +108 -0
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +548 -0
- package/src/modules/toolbar/components/Toolbar.tsx +123 -0
- package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +122 -0
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +353 -0
- package/src/modules/toolbar/services/external-api-keys.api.ts +65 -0
- package/src/modules/tools/ToolsExplorerPage.tsx +380 -0
- package/src/modules/workflow/hooks/useEventBusSubscription.ts +24 -0
- package/src/modules/workflow/hooks/useFileLock.ts +430 -0
- package/src/modules/workflow/services/lock.api.ts +139 -0
- package/src/modules/workflow/state/EventBusFocusBinder.tsx +25 -0
- package/src/modules/workflow/state/EventBusProvider.tsx +232 -0
- package/src/modules/workflow/state/event-bus.context.ts +75 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +54 -0
- package/src/modules/workspace/__tests__/useWorkspaceState.test.ts +91 -0
- package/src/modules/workspace/components/EditorTabs.tsx +384 -0
- package/src/modules/workspace/components/FileExplorer.tsx +1068 -0
- package/src/modules/workspace/components/FileRoute.tsx +392 -0
- package/src/modules/workspace/components/FileViewer.tsx +906 -0
- package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +241 -0
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +666 -0
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +330 -0
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +492 -0
- package/src/modules/workspace/components/renderers/CsvRenderer.tsx +174 -0
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +87 -0
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +231 -0
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +50 -0
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +287 -0
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +252 -0
- package/src/modules/workspace/components/renderers/MermaidDiagram.tsx +268 -0
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +81 -0
- package/src/modules/workspace/components/renderers/TextRenderer.tsx +86 -0
- package/src/modules/workspace/components/renderers/ToolForm.tsx +404 -0
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +417 -0
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +157 -0
- package/src/modules/workspace/components/renderers/__tests__/CsvRenderer.test.ts +57 -0
- package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +95 -0
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +328 -0
- package/src/modules/workspace/components/renderers/__tests__/PdfRenderer.test.tsx +167 -0
- package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +318 -0
- package/src/modules/workspace/components/renderers/csvUtils.ts +76 -0
- package/src/modules/workspace/components/renderers/htmlSandbox.ts +332 -0
- package/src/modules/workspace/components/renderers/index.ts +39 -0
- package/src/modules/workspace/components/renderers/types.ts +27 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +298 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +1315 -0
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +99 -0
- package/src/modules/workspace/routing/kb-routes.ts +266 -0
- package/src/modules/workspace/services/__tests__/workspace.api.test.ts +72 -0
- package/src/modules/workspace/services/workspace.api.ts +185 -0
- package/src/modules/workspace/state/workspace.context.ts +235 -0
- package/src/modules/workspace/utils/__tests__/frontmatter.test.ts +107 -0
- package/src/modules/workspace/utils/diff.ts +53 -0
- package/src/modules/workspace/utils/fileTree.ts +179 -0
- package/src/modules/workspace/utils/frontmatter.ts +80 -0
- package/src/modules/workspace/utils/readDroppedEntries.ts +119 -0
- package/src/modules/workspace/utils/tab-persistence.ts +23 -0
- package/src/shared/components/Dialog.tsx +198 -0
- package/src/shared/components/PageShell.tsx +51 -0
- package/src/shared/components/useModalLayer.ts +35 -0
- package/src/shared/markdown/Markdown.tsx +62 -0
- package/src/test-setup.ts +59 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import type { GitContextValue } from '../state/git.context';
|
|
3
|
+
import {
|
|
4
|
+
IDLE_AUTO_UPDATE,
|
|
5
|
+
type AutoUpdateState,
|
|
6
|
+
} from '../state/auto-update.context';
|
|
7
|
+
import type { WorkspaceContextValue } from '../../workspace/state/workspace.context';
|
|
8
|
+
import { sanitizeErrorText } from '../services/error-messages';
|
|
9
|
+
import { PR_STALE_EVENT } from '../../../core/events';
|
|
10
|
+
|
|
11
|
+
export function useAutoPullUpdates(
|
|
12
|
+
git: GitContextValue,
|
|
13
|
+
workspace: WorkspaceContextValue,
|
|
14
|
+
): AutoUpdateState {
|
|
15
|
+
const attemptedKeyRef = useRef<string | null>(null);
|
|
16
|
+
const [autoUpdate, setAutoUpdate] = useState<AutoUpdateState>(IDLE_AUTO_UPDATE);
|
|
17
|
+
const { availability, status, pull } = git;
|
|
18
|
+
const {
|
|
19
|
+
workspaceId,
|
|
20
|
+
hasUnsavedFileChanges,
|
|
21
|
+
refreshFileTree,
|
|
22
|
+
bumpFsRevision,
|
|
23
|
+
} = workspace;
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!workspaceId || availability !== 'ready' || !status?.unmergedFromUpstream) {
|
|
27
|
+
attemptedKeyRef.current = null;
|
|
28
|
+
void Promise.resolve().then(() => setAutoUpdate(IDLE_AUTO_UPDATE));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Auto-pull on EVERY branch (protected + feature) whenever we're
|
|
33
|
+
// behind upstream and it's safe to touch. The old policy gated
|
|
34
|
+
// this to protected branches only, on the theory that feature
|
|
35
|
+
// branches were single-owner. Under the save=share workflow, multiple
|
|
36
|
+
// users share the on-disk clone per branch, and an agent acting on a
|
|
37
|
+
// user's behalf can advance origin between this client's saves — so
|
|
38
|
+
// a feature branch silently falling behind is the same bug class as
|
|
39
|
+
// a protected one. The only remaining guard is in-memory tab edits;
|
|
40
|
+
// working-tree dirty state + mid-merge conflicts don't exist as
|
|
41
|
+
// gating signals anymore (save=share rules them out).
|
|
42
|
+
if (hasUnsavedFileChanges) {
|
|
43
|
+
void Promise.resolve().then(() => setAutoUpdate(IDLE_AUTO_UPDATE));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const key = `${workspaceId}:${status.branch}`;
|
|
48
|
+
if (attemptedKeyRef.current === key) return;
|
|
49
|
+
attemptedKeyRef.current = key;
|
|
50
|
+
|
|
51
|
+
let cancelled = false;
|
|
52
|
+
|
|
53
|
+
void (async () => {
|
|
54
|
+
setAutoUpdate({ status: 'updating', branch: status.branch, reason: null });
|
|
55
|
+
|
|
56
|
+
// Only pull() failures should mark the whole auto-update as failed —
|
|
57
|
+
// that's the user-visible status the banner reads to decide whether
|
|
58
|
+
// to surface a Retry. A post-pull refresh hiccup is a UI staleness
|
|
59
|
+
// issue, not an "update couldn't happen" failure (the merge already
|
|
60
|
+
// landed on disk), and surfacing it as such would make the user
|
|
61
|
+
// re-pull when there's nothing left to pull.
|
|
62
|
+
try {
|
|
63
|
+
await pull();
|
|
64
|
+
} catch (err) {
|
|
65
|
+
if (cancelled) return;
|
|
66
|
+
const sanitizedReason = sanitizeErrorText(err) || 'Could not get updates.';
|
|
67
|
+
setAutoUpdate({
|
|
68
|
+
status: 'failed',
|
|
69
|
+
branch: status.branch,
|
|
70
|
+
reason: sanitizedReason,
|
|
71
|
+
});
|
|
72
|
+
// Log only the sanitized text — raw err.message can contain urls,
|
|
73
|
+
// tokens, or local paths we just stripped from the user-facing reason.
|
|
74
|
+
console.debug('[git] auto-pull skipped:', sanitizedReason, {
|
|
75
|
+
branch: status.branch,
|
|
76
|
+
});
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (cancelled) return;
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
await refreshFileTree();
|
|
83
|
+
if (cancelled) return;
|
|
84
|
+
|
|
85
|
+
// Invalidate cached tab content so the active tab eagerly refetches
|
|
86
|
+
// (and surfaces fresh bytes after the merge), and inactive tabs
|
|
87
|
+
// re-read on next activation. If a tab's path vanished underneath
|
|
88
|
+
// the pull, the eager refetch's 404 path drops that tab.
|
|
89
|
+
bumpFsRevision();
|
|
90
|
+
|
|
91
|
+
window.dispatchEvent(new CustomEvent(PR_STALE_EVENT));
|
|
92
|
+
} catch (err) {
|
|
93
|
+
if (cancelled) return;
|
|
94
|
+
// Pull already landed — keep the auto-update marked idle so the
|
|
95
|
+
// banner doesn't reappear with a misleading "couldn't update"
|
|
96
|
+
// message. Just log so a misbehaving refresh shows up in console.
|
|
97
|
+
console.debug(
|
|
98
|
+
'[git] auto-pull post-refresh failed:',
|
|
99
|
+
sanitizeErrorText(err) || String(err),
|
|
100
|
+
{ branch: status.branch },
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
if (cancelled) return;
|
|
104
|
+
setAutoUpdate(IDLE_AUTO_UPDATE);
|
|
105
|
+
})();
|
|
106
|
+
|
|
107
|
+
return () => {
|
|
108
|
+
cancelled = true;
|
|
109
|
+
};
|
|
110
|
+
}, [
|
|
111
|
+
availability,
|
|
112
|
+
status,
|
|
113
|
+
pull,
|
|
114
|
+
workspaceId,
|
|
115
|
+
hasUnsavedFileChanges,
|
|
116
|
+
refreshFileTree,
|
|
117
|
+
bumpFsRevision,
|
|
118
|
+
]);
|
|
119
|
+
|
|
120
|
+
return autoUpdate;
|
|
121
|
+
}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
BranchInfo,
|
|
4
|
+
CommitAttribution,
|
|
5
|
+
WorkingTreeStatus,
|
|
6
|
+
} from '@bevel-software/platform-shared';
|
|
7
|
+
import type { GitContextValue } from '../state/git.context';
|
|
8
|
+
import {
|
|
9
|
+
createBranch as apiCreateBranch,
|
|
10
|
+
deleteBranch as apiDeleteBranch,
|
|
11
|
+
fetchBranches,
|
|
12
|
+
fetchFileComparison,
|
|
13
|
+
fetchFileDiff,
|
|
14
|
+
fetchFileHistory,
|
|
15
|
+
fetchForkBase,
|
|
16
|
+
fetchStatus,
|
|
17
|
+
pull as apiPull,
|
|
18
|
+
revert as apiRevert,
|
|
19
|
+
} from '../services/git.api';
|
|
20
|
+
|
|
21
|
+
const STATUS_POLL_MS = 30_000;
|
|
22
|
+
|
|
23
|
+
export function useGitState(workspaceId: string | null): GitContextValue {
|
|
24
|
+
const [status, setStatus] = useState<WorkingTreeStatus | null>(null);
|
|
25
|
+
const [rawBranches, setRawBranches] = useState<BranchInfo[]>([]);
|
|
26
|
+
// Names of branches whose delete is in flight. Filtered out of the exposed
|
|
27
|
+
// `branches` so the row vanishes from the picker the instant the user
|
|
28
|
+
// confirms, before `git push --delete origin <name>` resolves. The set
|
|
29
|
+
// survives any concurrent `refreshBranches()` that lands mid-flight — the
|
|
30
|
+
// server still reports the branch as present until the delete commits,
|
|
31
|
+
// and without this filter the row would briefly reappear.
|
|
32
|
+
const [pendingDeletes, setPendingDeletes] = useState<Set<string>>(new Set());
|
|
33
|
+
const [availability, setAvailability] = useState<GitContextValue['availability']>('loading');
|
|
34
|
+
const [lastError, setLastError] = useState<string | null>(null);
|
|
35
|
+
const branches = useMemo(
|
|
36
|
+
() => rawBranches.filter((b) => !pendingDeletes.has(b.name)),
|
|
37
|
+
[rawBranches, pendingDeletes],
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
// Pin the latest workspaceId for async callbacks so we ignore stale responses.
|
|
41
|
+
const workspaceIdRef = useRef(workspaceId);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
workspaceIdRef.current = workspaceId;
|
|
44
|
+
}, [workspaceId]);
|
|
45
|
+
|
|
46
|
+
// Per-refresh sequence counters: two in-flight requests for the *same* workspace can
|
|
47
|
+
// still resolve out of order (e.g. after a polling tick overlaps a manual refresh), so
|
|
48
|
+
// workspaceId alone isn't sufficient — we also need to drop any response whose token
|
|
49
|
+
// is no longer the latest.
|
|
50
|
+
const statusSeqRef = useRef(0);
|
|
51
|
+
const branchesSeqRef = useRef(0);
|
|
52
|
+
const remoteRefreshInFlightRef = useRef(false);
|
|
53
|
+
// Set when a refresh is requested while one is already in flight. After the
|
|
54
|
+
// current refresh finishes we run exactly one more, so a workspace switch
|
|
55
|
+
// (or any other caller) that lands during an in-flight poll still gets
|
|
56
|
+
// immediate fresh data instead of waiting for the next 30s tick.
|
|
57
|
+
const pendingRefreshRef = useRef(false);
|
|
58
|
+
|
|
59
|
+
const refreshStatus = useCallback(async (): Promise<WorkingTreeStatus | null> => {
|
|
60
|
+
const wid = workspaceIdRef.current;
|
|
61
|
+
if (!wid) return null;
|
|
62
|
+
const token = ++statusSeqRef.current;
|
|
63
|
+
const isLatest = () => workspaceIdRef.current === wid && statusSeqRef.current === token;
|
|
64
|
+
try {
|
|
65
|
+
const s = await fetchStatus(wid);
|
|
66
|
+
if (!isLatest()) return null;
|
|
67
|
+
setStatus(s);
|
|
68
|
+
setAvailability('ready');
|
|
69
|
+
setLastError(null);
|
|
70
|
+
return s;
|
|
71
|
+
} catch (err) {
|
|
72
|
+
if (!isLatest()) return null;
|
|
73
|
+
setAvailability('error');
|
|
74
|
+
setLastError(err instanceof Error ? err.message : 'Unknown error');
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}, []);
|
|
78
|
+
|
|
79
|
+
const refreshBranches = useCallback(async (opts: { fresh?: boolean } = {}) => {
|
|
80
|
+
const wid = workspaceIdRef.current;
|
|
81
|
+
if (!wid) return;
|
|
82
|
+
const token = ++branchesSeqRef.current;
|
|
83
|
+
const isLatest = () => workspaceIdRef.current === wid && branchesSeqRef.current === token;
|
|
84
|
+
try {
|
|
85
|
+
const bs = await fetchBranches(wid, opts);
|
|
86
|
+
if (!isLatest()) return;
|
|
87
|
+
setRawBranches(bs);
|
|
88
|
+
} catch (err) {
|
|
89
|
+
if (!isLatest()) return;
|
|
90
|
+
setLastError(err instanceof Error ? err.message : 'Unknown error');
|
|
91
|
+
}
|
|
92
|
+
}, []);
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* User-invoked `git pull --rebase` against origin. Surfaces errors to the
|
|
96
|
+
* caller. On protected branches the API guards block local commits, so a
|
|
97
|
+
* clean working tree fast-forwards; a dirty tree (mid-flow agent edit) or
|
|
98
|
+
* any non-fast-forward situation makes git refuse the rebase and we throw
|
|
99
|
+
* — the PullNeededBanner uses that to fall back to seeding the agent
|
|
100
|
+
* prompt. Status + branches are refreshed even on failure so the UI
|
|
101
|
+
* reflects whatever state the backend ended up in.
|
|
102
|
+
*/
|
|
103
|
+
const pull = useCallback(async () => {
|
|
104
|
+
const wid = workspaceIdRef.current;
|
|
105
|
+
if (!wid) throw new Error('No workspace loaded');
|
|
106
|
+
try {
|
|
107
|
+
await apiPull(wid);
|
|
108
|
+
} finally {
|
|
109
|
+
if (workspaceIdRef.current === wid) {
|
|
110
|
+
await Promise.all([refreshStatus(), refreshBranches()]);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}, [refreshStatus, refreshBranches]);
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Refresh remote-tracking refs before checking status so the app can notice
|
|
117
|
+
* teammate commits that landed after the workspace was opened. `listBranches`
|
|
118
|
+
* performs the fetch server-side and swallows network/auth failures, so the
|
|
119
|
+
* status poll keeps serving local state when origin is temporarily unavailable.
|
|
120
|
+
*/
|
|
121
|
+
const refreshRemoteState = useCallback(async () => {
|
|
122
|
+
if (!workspaceIdRef.current) return;
|
|
123
|
+
if (remoteRefreshInFlightRef.current) {
|
|
124
|
+
// Coalesce concurrent calls into a single follow-up. Without this, a
|
|
125
|
+
// workspace switch during an in-flight refresh would silently drop the
|
|
126
|
+
// new workspace's initial fetch.
|
|
127
|
+
pendingRefreshRef.current = true;
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
remoteRefreshInFlightRef.current = true;
|
|
131
|
+
// Loop instead of recursing so the trailing follow-up always reads the
|
|
132
|
+
// latest workspaceIdRef, without needing the callback to depend on itself.
|
|
133
|
+
do {
|
|
134
|
+
pendingRefreshRef.current = false;
|
|
135
|
+
const wid = workspaceIdRef.current;
|
|
136
|
+
if (!wid) break;
|
|
137
|
+
try {
|
|
138
|
+
// Status is a cheap local call and is the ONLY thing the branch
|
|
139
|
+
// switcher's mid-switch label waits on — fire it up front so it
|
|
140
|
+
// resolves in a single round-trip instead of queuing behind the
|
|
141
|
+
// branch-list fetch (which carries a slow server-side `git fetch`).
|
|
142
|
+
const initialStatus = refreshStatus();
|
|
143
|
+
// `refreshBranches` performs that server-side fetch, refreshing
|
|
144
|
+
// origin's remote-tracking refs. Run it concurrently; once it lands,
|
|
145
|
+
// refresh status again so `unmergedFromUpstream` reflects the
|
|
146
|
+
// freshly-fetched refs (the reason the two were ordered
|
|
147
|
+
// branches-then-status before).
|
|
148
|
+
const branchesThenStatus = refreshBranches().then(() => {
|
|
149
|
+
if (workspaceIdRef.current === wid) return refreshStatus();
|
|
150
|
+
});
|
|
151
|
+
await Promise.all([initialStatus, branchesThenStatus]);
|
|
152
|
+
} catch {
|
|
153
|
+
// refreshBranches/refreshStatus already record their own errors;
|
|
154
|
+
// swallow here so a transient failure doesn't strand the in-flight
|
|
155
|
+
// flag and block the queued follow-up.
|
|
156
|
+
}
|
|
157
|
+
} while (pendingRefreshRef.current);
|
|
158
|
+
remoteRefreshInFlightRef.current = false;
|
|
159
|
+
}, [refreshBranches, refreshStatus]);
|
|
160
|
+
|
|
161
|
+
// Initial load + polling.
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
if (!workspaceId) {
|
|
164
|
+
setStatus(null);
|
|
165
|
+
setRawBranches([]);
|
|
166
|
+
setPendingDeletes(new Set());
|
|
167
|
+
setAvailability('loading');
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
setAvailability('loading');
|
|
171
|
+
refreshRemoteState();
|
|
172
|
+
|
|
173
|
+
const interval = window.setInterval(() => {
|
|
174
|
+
if (document.visibilityState === 'visible') {
|
|
175
|
+
refreshRemoteState();
|
|
176
|
+
}
|
|
177
|
+
}, STATUS_POLL_MS);
|
|
178
|
+
return () => window.clearInterval(interval);
|
|
179
|
+
}, [workspaceId, refreshRemoteState]);
|
|
180
|
+
|
|
181
|
+
// No `switchBranch` here on purpose. Under the per-branch workspace model
|
|
182
|
+
// (`workspaces/<encodeURIComponent(branch)>/`), switching branches is a
|
|
183
|
+
// pure UI navigation: the URL changes, FileRoute calls setPersistenceBranch,
|
|
184
|
+
// useWorkspaceState bootstraps the destination workspace (cloning at the
|
|
185
|
+
// requested branch if needed), workspaceId here updates, and the polling
|
|
186
|
+
// effect above re-fetches status against the new workspace. No git op runs
|
|
187
|
+
// on the source workspace's clone, so there is no dirty-tree gate to trip
|
|
188
|
+
// and no race between "switch the agent's branch" and "switch the UI's
|
|
189
|
+
// branch". The legacy `git.switchBranch` API + frontend callback have
|
|
190
|
+
// been removed; everything goes through the URL → workspaceId pipeline.
|
|
191
|
+
|
|
192
|
+
const createBranch = useCallback(
|
|
193
|
+
async (name: string, fromBase?: string): Promise<void> => {
|
|
194
|
+
const wid = workspaceIdRef.current;
|
|
195
|
+
if (!wid) throw new Error('No workspace loaded');
|
|
196
|
+
// Creating a branch is a write against the current workspace's clone.
|
|
197
|
+
// The caller (BranchSwitcher) navigates to the new branch's URL
|
|
198
|
+
// immediately after, which triggers the workspace bootstrap to clone
|
|
199
|
+
// (or fetch) the new branch into its own per-branch workspace dir.
|
|
200
|
+
await apiCreateBranch(wid, name, fromBase);
|
|
201
|
+
// Refresh branches so the picker reflects the new draft right away,
|
|
202
|
+
// even before the navigation completes its workspace bootstrap.
|
|
203
|
+
await refreshBranches();
|
|
204
|
+
},
|
|
205
|
+
[refreshBranches],
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
const deleteBranchCb = useCallback(
|
|
209
|
+
async (name: string, opts: { onlyIfNoRemote?: boolean } = {}): Promise<void> => {
|
|
210
|
+
const wid = workspaceIdRef.current;
|
|
211
|
+
if (!wid) throw new Error('No workspace loaded');
|
|
212
|
+
// Optimistic: hide the row immediately so the user gets instant
|
|
213
|
+
// feedback while `git push --delete origin <name>` runs over the wire.
|
|
214
|
+
// Mirrors the optimistic-mutation pattern in `useReviewState.rejectOne`.
|
|
215
|
+
setPendingDeletes((prev) => {
|
|
216
|
+
if (prev.has(name)) return prev;
|
|
217
|
+
const next = new Set(prev);
|
|
218
|
+
next.add(name);
|
|
219
|
+
return next;
|
|
220
|
+
});
|
|
221
|
+
try {
|
|
222
|
+
await apiDeleteBranch(wid, name, opts);
|
|
223
|
+
// Success: refresh so any concurrent changes (e.g. a teammate pushed
|
|
224
|
+
// a new draft while we were deleting) land in the picker too. The
|
|
225
|
+
// row stays hidden until the `finally` drops it from pendingDeletes,
|
|
226
|
+
// and by then rawBranches no longer includes it — no flicker.
|
|
227
|
+
await refreshBranches();
|
|
228
|
+
} catch (err) {
|
|
229
|
+
// Failure: refresh to put server truth back on rawBranches (which
|
|
230
|
+
// still has the branch). The `finally` then clears pendingDeletes,
|
|
231
|
+
// so the row reappears just as the error propagates to the caller.
|
|
232
|
+
await refreshBranches();
|
|
233
|
+
throw err;
|
|
234
|
+
} finally {
|
|
235
|
+
setPendingDeletes((prev) => {
|
|
236
|
+
if (!prev.has(name)) return prev;
|
|
237
|
+
const next = new Set(prev);
|
|
238
|
+
next.delete(name);
|
|
239
|
+
return next;
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
[refreshBranches],
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
// `forkToDraft` callback removed: equivalent to `createBranch` under
|
|
247
|
+
// save=share + per-branch workspaces. Use the latter and navigate to the
|
|
248
|
+
// new branch's URL.
|
|
249
|
+
|
|
250
|
+
const fetchForkBaseCb = useCallback(async (branch: string): Promise<string | null> => {
|
|
251
|
+
const wid = workspaceIdRef.current;
|
|
252
|
+
if (!wid) return null;
|
|
253
|
+
return fetchForkBase(wid, branch);
|
|
254
|
+
}, []);
|
|
255
|
+
|
|
256
|
+
const revert = useCallback(
|
|
257
|
+
async (sha: string): Promise<CommitAttribution> => {
|
|
258
|
+
const wid = workspaceIdRef.current;
|
|
259
|
+
if (!wid) throw new Error('No workspace loaded');
|
|
260
|
+
const attribution = await apiRevert(wid, sha);
|
|
261
|
+
await refreshStatus();
|
|
262
|
+
return attribution;
|
|
263
|
+
},
|
|
264
|
+
[refreshStatus],
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
const fetchFileHistoryCb = useCallback(
|
|
268
|
+
async (path: string, limit?: number): Promise<CommitAttribution[]> => {
|
|
269
|
+
const wid = workspaceIdRef.current;
|
|
270
|
+
if (!wid) return [];
|
|
271
|
+
return fetchFileHistory(wid, path, limit);
|
|
272
|
+
},
|
|
273
|
+
[],
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
const fetchFileDiffCb = useCallback(
|
|
277
|
+
async (path: string, sha: string): Promise<string> => {
|
|
278
|
+
const wid = workspaceIdRef.current;
|
|
279
|
+
if (!wid) return '';
|
|
280
|
+
return fetchFileDiff(wid, path, sha);
|
|
281
|
+
},
|
|
282
|
+
[],
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
const fetchFileComparisonCb = useCallback(
|
|
286
|
+
async (path: string, fromBranch: string, toBranch: string): Promise<string> => {
|
|
287
|
+
const wid = workspaceIdRef.current;
|
|
288
|
+
// The contract treats an empty string as "files are identical", so we
|
|
289
|
+
// can't reuse it as a sentinel for "no active workspace" — the panel
|
|
290
|
+
// would render the misleading "identical on both versions" empty
|
|
291
|
+
// state. Reject instead so callers fall into their error branch.
|
|
292
|
+
if (!wid) throw new Error('No active workspace.');
|
|
293
|
+
return fetchFileComparison(wid, path, fromBranch, toBranch);
|
|
294
|
+
},
|
|
295
|
+
[],
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
// `fetchWorkingStatusCb` + `fetchWorkingDiffCb` removed: working-tree dirty
|
|
299
|
+
// surface is always empty under save=share.
|
|
300
|
+
|
|
301
|
+
return useMemo(
|
|
302
|
+
() => ({
|
|
303
|
+
status,
|
|
304
|
+
branches,
|
|
305
|
+
availability,
|
|
306
|
+
lastError,
|
|
307
|
+
refreshStatus,
|
|
308
|
+
refreshBranches,
|
|
309
|
+
createBranch,
|
|
310
|
+
deleteBranch: deleteBranchCb,
|
|
311
|
+
pull,
|
|
312
|
+
fetchForkBase: fetchForkBaseCb,
|
|
313
|
+
revert,
|
|
314
|
+
fetchFileHistory: fetchFileHistoryCb,
|
|
315
|
+
fetchFileDiff: fetchFileDiffCb,
|
|
316
|
+
fetchFileComparison: fetchFileComparisonCb,
|
|
317
|
+
}),
|
|
318
|
+
[
|
|
319
|
+
status,
|
|
320
|
+
branches,
|
|
321
|
+
availability,
|
|
322
|
+
lastError,
|
|
323
|
+
refreshStatus,
|
|
324
|
+
refreshBranches,
|
|
325
|
+
createBranch,
|
|
326
|
+
deleteBranchCb,
|
|
327
|
+
pull,
|
|
328
|
+
fetchForkBaseCb,
|
|
329
|
+
revert,
|
|
330
|
+
fetchFileHistoryCb,
|
|
331
|
+
fetchFileDiffCb,
|
|
332
|
+
fetchFileComparisonCb,
|
|
333
|
+
],
|
|
334
|
+
);
|
|
335
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { GitApiError } from '../git.api';
|
|
3
|
+
import {
|
|
4
|
+
friendlyGitError,
|
|
5
|
+
parseGitError,
|
|
6
|
+
NO_SHARED_HISTORY_KIND,
|
|
7
|
+
NO_SHARED_HISTORY_RECOVERY_PROMPT,
|
|
8
|
+
} from '../error-messages';
|
|
9
|
+
|
|
10
|
+
describe('friendlyGitError — translates raw backend git messages', () => {
|
|
11
|
+
// The legacy "direct push to protected branch is not allowed" case is
|
|
12
|
+
// retired with the access-at-lock-acquisition refactor: writing to the
|
|
13
|
+
// official versions is allowed wherever the user has path-level access.
|
|
14
|
+
// `direct push` / `committing directly` / `reverting directly` are no
|
|
15
|
+
// longer thrown by the backend; the regex was trimmed accordingly.
|
|
16
|
+
it('rewrites protected-branch "opening a PR from a protected branch" errors', () => {
|
|
17
|
+
const err = new GitApiError(
|
|
18
|
+
403,
|
|
19
|
+
'Branch "target-company-state" is protected — opening a PR from a protected branch is not allowed.',
|
|
20
|
+
);
|
|
21
|
+
expect(friendlyGitError(err)).toBe(
|
|
22
|
+
'You can\'t propose changes from "target-company-state" — open the change request from a draft instead.',
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('rewrites protected-branch "creating a protected branch" errors', () => {
|
|
27
|
+
// The backend throws `ProtectedBranchError` with action "creating a
|
|
28
|
+
// protected branch" when the user tries to make a new branch whose
|
|
29
|
+
// name collides with an official version (the protected set).
|
|
30
|
+
const err = new GitApiError(
|
|
31
|
+
403,
|
|
32
|
+
'Branch "target-company-state" is protected — creating a protected branch is not allowed.',
|
|
33
|
+
);
|
|
34
|
+
expect(friendlyGitError(err)).toBe(
|
|
35
|
+
'The name "target-company-state" is reserved — it\'s an official version.',
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('rewrites protected-branch "deleting a protected branch" errors', () => {
|
|
40
|
+
// The backend throws `ProtectedBranchError` with action "deleting a
|
|
41
|
+
// protected branch" when the user tries to delete an official version
|
|
42
|
+
// via the delete-branch flow.
|
|
43
|
+
const err = new GitApiError(
|
|
44
|
+
403,
|
|
45
|
+
'Branch "current-company-state" is protected — deleting a protected branch is not allowed.',
|
|
46
|
+
);
|
|
47
|
+
expect(friendlyGitError(err)).toBe(
|
|
48
|
+
'"current-company-state" is an official version and can\'t be deleted.',
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('falls back to the raw message for shapes it does not recognize', () => {
|
|
53
|
+
const err = new GitApiError(500, 'something completely new went wrong');
|
|
54
|
+
expect(friendlyGitError(err)).toBe('something completely new went wrong');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('rewrites raw "no history in common" CLI errors when pre-flight is bypassed', () => {
|
|
58
|
+
const err = new GitApiError(
|
|
59
|
+
500,
|
|
60
|
+
'gh pr create failed: GraphQL: The alice/orphan branch has no history in common with target-company-state',
|
|
61
|
+
);
|
|
62
|
+
const message = friendlyGitError(err);
|
|
63
|
+
expect(message).not.toMatch(/gh pr create/i);
|
|
64
|
+
expect(message).not.toMatch(/graphql/i);
|
|
65
|
+
expect(message).toMatch(/share history/i);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('returns the no-shared-history message when the body carries the kind', () => {
|
|
69
|
+
const err = new GitApiError(
|
|
70
|
+
400,
|
|
71
|
+
'The draft "alice/orphan" doesn\'t share history with "target-company-state". …',
|
|
72
|
+
{ error: '…', kind: NO_SHARED_HISTORY_KIND, head: 'alice/orphan', base: 'target-company-state' },
|
|
73
|
+
);
|
|
74
|
+
const message = friendlyGitError(err);
|
|
75
|
+
// Renders "Target company state" via protectedBranchDisplayName, not the raw kebab slug.
|
|
76
|
+
expect(message).toMatch(/Target company state/);
|
|
77
|
+
expect(message).not.toMatch(/target-company-state/);
|
|
78
|
+
// No git vocabulary at the rendering boundary — see docs/glossary.md.
|
|
79
|
+
expect(message).not.toMatch(/\bbranch\b/i);
|
|
80
|
+
expect(message).not.toMatch(/\brebase\b/i);
|
|
81
|
+
expect(message).toMatch(/assistant/i);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe('parseGitError — structured form for actionable UIs', () => {
|
|
86
|
+
it('returns kind="plain" for arbitrary errors', () => {
|
|
87
|
+
const info = parseGitError(new Error('oops'));
|
|
88
|
+
expect(info).toEqual({ kind: 'plain', message: 'oops' });
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('returns kind=no-shared-history with head + base when the body shape matches', () => {
|
|
92
|
+
const err = new GitApiError(
|
|
93
|
+
400,
|
|
94
|
+
'The draft "alice/orphan" doesn\'t share history …',
|
|
95
|
+
{ error: '…', kind: NO_SHARED_HISTORY_KIND, head: 'alice/orphan', base: 'target-company-state' },
|
|
96
|
+
);
|
|
97
|
+
const info = parseGitError(err);
|
|
98
|
+
expect(info.kind).toBe(NO_SHARED_HISTORY_KIND);
|
|
99
|
+
if (info.kind === NO_SHARED_HISTORY_KIND) {
|
|
100
|
+
expect(info.head).toBe('alice/orphan');
|
|
101
|
+
expect(info.base).toBe('target-company-state');
|
|
102
|
+
expect(info.message).toMatch(/Target company state/);
|
|
103
|
+
} else {
|
|
104
|
+
throw new Error('expected no-shared-history');
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('falls back to plain when no-shared-history body is missing head or base', () => {
|
|
109
|
+
const err = new GitApiError(
|
|
110
|
+
400,
|
|
111
|
+
'plain message',
|
|
112
|
+
{ error: 'plain message', kind: NO_SHARED_HISTORY_KIND, base: 'target-company-state' },
|
|
113
|
+
);
|
|
114
|
+
expect(parseGitError(err).kind).toBe('plain');
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe('cross-package contract', () => {
|
|
119
|
+
it('pins the no-shared-history kind discriminator across packages', () => {
|
|
120
|
+
// The backend's NoSharedHistoryError sets `kind: 'no-shared-history'` in
|
|
121
|
+
// the response payload. Pin the literal so a rename on either side
|
|
122
|
+
// surfaces as a test failure instead of a silent dispatch miss in the UI.
|
|
123
|
+
expect(NO_SHARED_HISTORY_KIND).toBe('no-shared-history');
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('seeds the chat with a recovery prompt that names both the draft and the target', () => {
|
|
127
|
+
const prompt = NO_SHARED_HISTORY_RECOVERY_PROMPT('alice/orphan', 'target-company-state');
|
|
128
|
+
expect(prompt).toContain('alice/orphan');
|
|
129
|
+
expect(prompt).toContain('target-company-state');
|
|
130
|
+
// Steers the agent toward investigating + recovering, not toward a single
|
|
131
|
+
// canned action that might destroy the user's edits.
|
|
132
|
+
expect(prompt).toMatch(/investigate/i);
|
|
133
|
+
});
|
|
134
|
+
});
|