Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(control-ui): finish 401 PATCH handling and disjoint gate lanes

Me00249eecb73
diff --git a/control-ui/components/GfsBrowser.tsx b/control-ui/components/GfsBrowser.tsx
index 54e18e922..ff36f17de 100644
--- a/control-ui/components/GfsBrowser.tsx
+++ b/control-ui/components/GfsBrowser.tsx
@@ -2000,6 +2000,17 @@ export function GfsBrowser(): React.JSX.Element {
break
} catch (error) {
if (!isGfsNameConflict(error)) {
+ // A 401 from the PATCH itself is session loss (A11), not a
+ // transient failure: raise the persistent sign-in alert and stop
+ // — no ladder retry can succeed against a dead session. The API
+ // layer's global unauthorized boundary has already run.
+ if (isUnauthorizedRead(error)) {
+ if (options.revalidate) {
+ raiseSessionLostNotice()
+ return
+ }
+ throw error
+ }
if (
options.revalidate &&
entityChangeErrorStatus(error) === undefined &&
@@ -2172,6 +2183,14 @@ export function GfsBrowser(): React.JSX.Element {
resolveEndpointView(destination.gfsUri, destination.resourceId),
])
if (!isGestureEpochCurrent(epoch)) return 'unknown'
+ if (sourceRead.status === 'unauthorized' || targetRead.status === 'unauthorized') {
+ // The session died after the PATCH was dispatched: the move outcome
+ // stays HONESTLY UNKNOWN (the PATCH may have landed first), and the
+ // session loss surfaces alongside it through the persistent alert —
+ // never as a connection-flavored warning.
+ raiseSessionLostNotice()
+ return 'unknown'
+ }
if (sourceRead.status !== 'resolved' || targetRead.status !== 'resolved') return 'unknown'
if (targetRead.view.kind !== 'directory') return 'unknown'
if (typeof sourceRead.view.path !== 'string' || typeof targetRead.view.path !== 'string') {
diff --git a/control-ui/components/__tests__/GfsBrowser.test.tsx b/control-ui/components/__tests__/GfsBrowser.test.tsx
index 33721af8f..edb1092c4 100644
--- a/control-ui/components/__tests__/GfsBrowser.test.tsx
+++ b/control-ui/components/__tests__/GfsBrowser.test.tsx
@@ -5331,4 +5331,70 @@ describe('GfsBrowser — breadcrumb drop moves', () => {
expect(mockApiSend).not.toHaveBeenCalled()
expect(screen.queryByRole('dialog')).toBeNull()
})
+
+ it('raises the persistent sign-in alert when the dispatched PATCH itself comes back 401 (A11)', async () => {
+ breadcrumbTrailFixture()
+ // The API layer already routes PATCH 401s through the global
+ // unauthorized handler (throwing AuthExpiredError); a raw 401 status
+ // exercises the same classification. Either way: persistent sign-in
+ // alert, no transient error toast, no ladder retry.
+ mockApiSend.mockImplementation(async () => {
+ throw Object.assign(new Error('401 Unauthorized'), { status: 401 })
+ })
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+
+ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))
+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move file abac.md to Product',
+ })
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+
+ const alert = await screen.findByRole('alert')
+ expect(alert).toHaveTextContent('Your session ended. Sign in again to continue moving files.')
+ // No generic transient toast for the 401, no unknown-outcome claim, no
+ // success claim — and exactly one PATCH (a dead session never retries).
+ expect(screen.queryByText(/401/)).toBeNull()
+ expect(screen.queryByText(/couldn.t (verify this move|confirm the move)/)).toBeNull()
+ expect(screen.queryByText(/Moved "abac\.md"/)).toBeNull()
+ await waitFor(() => expect(mockApiSend).toHaveBeenCalledTimes(1))
+ await act(async () => {
+ await Promise.resolve()
+ })
+ expect(mockApiSend).toHaveBeenCalledTimes(1)
+ })
+
+ it('surfaces session loss alongside an honestly unknown outcome when verification reads 401', async () => {
+ const fixture = breadcrumbTrailFixture()
+ // The PATCH transport-fails after dispatch, and the session expires
+ // before the verification read can answer: the move outcome stays
+ // unknown (the PATCH may have landed) while the session loss surfaces
+ // through the persistent alert next to the warning toast.
+ fixture.policy.sourceReadResults.set(3, 'unauthorized')
+ mockApiSend.mockImplementation(async () => {
+ throw new TypeError('fetch failed')
+ })
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+
+ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))
+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move file abac.md to Product',
+ })
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+
+ const alert = await screen.findByRole('alert')
+ expect(alert).toHaveTextContent('Your session ended. Sign in again to continue moving files.')
+ expect(
+ await screen.findByText(/Couldn.t confirm the move\. Refresh before trying again\./)
+ ).toBeTruthy()
+ expect(screen.getByText(/confirm the move/).closest('.cu-toast')).toHaveClass(
+ 'cu-toast--warning'
+ )
+ // No connection-flavored warning and no repeat PATCH.
+ expect(screen.queryByText(/couldn.t verify this move/)).toBeNull()
+ expect(mockApiSend).toHaveBeenCalledTimes(1)
+ })
})
diff --git a/control-ui/e2e/run-gfs-drag-and-drop.mjs b/control-ui/e2e/run-gfs-drag-and-drop.mjs
index 920f2ec89..c63c0849f 100644
--- a/control-ui/e2e/run-gfs-drag-and-drop.mjs
+++ b/control-ui/e2e/run-gfs-drag-and-drop.mjs
@@ -70,11 +70,29 @@ const PLAYWRIGHT_ARGS = [
* owns live journeys; a spec file that silently loses them would still
* report green for the remaining journeys, so their absence from the
* inventory is a gate failure, not a smaller pass.
+ *
+ * The four patterns are ANCHORED and DISJOINT — each matches exactly one
+ * journey title — so every lane is required independently: losing the root
+ * move alone (or any other single lane) fails the gate even when the other
+ * breadcrumb journeys survive.
*/
export const REQUIRED_JOURNEY_INVENTORY = [
- { label: 'a breadcrumb file-move journey', pattern: /breadcrumb crumb|drive-root crumb/i },
- { label: 'an active-crumb same-parent journey', pattern: /active breadcrumb crumb/i },
- { label: 'an ancestor folder-move journey', pattern: /ancestor crumb/i },
+ {
+ label: 'the file ancestor-crumb move journey',
+ pattern: /^file drag onto a breadcrumb crumb/i,
+ },
+ {
+ label: 'the file drive-root-crumb move journey',
+ pattern: /^file drag onto the main drive-root crumb/i,
+ },
+ {
+ label: 'the active-crumb same-parent no-op journey',
+ pattern: /^drop onto the active breadcrumb crumb/i,
+ },
+ {
+ label: 'the folder ancestor-crumb move journey',
+ pattern: /^folder drag onto an ancestor crumb/i,
+ },
]
/**
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 3ea631711..d03913f1a 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.747",
+ "version": "0.1.748",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.747",
+ "version": "0.1.748",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/frontend-components": "file:../packages/frontend-components",
diff --git a/control-ui/package.json b/control-ui/package.json
index f2e710a39..16c9af4f6 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.747",
+ "version": "0.1.748",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",
diff --git a/control-ui/test/__tests__/gfsDragAndDropGate.test.ts b/control-ui/test/__tests__/gfsDragAndDropGate.test.ts
index b34cf4466..887d14970 100644
--- a/control-ui/test/__tests__/gfsDragAndDropGate.test.ts
+++ b/control-ui/test/__tests__/gfsDragAndDropGate.test.ts
@@ -388,10 +388,14 @@ describe('EvenDrive drag-and-drop E2E gate', () => {
{ title: 'drop onto the active breadcrumb crumb explains it is already there' },
{ title: 'folder drag onto an ancestor crumb above its parent commits after confirmation' },
]
+ const unrelatedJourneys = [
+ { title: 'file drag into folder moves it' },
+ { title: 'folder drag opens the one confirmation and Cancel changes nothing' },
+ ]
it('accepts an inventory that carries every required lane', () => {
const journeys = collectReportJourneys(
- journeyReport([...breadcrumbJourneys, { title: 'file drag into folder moves it' }])
+ journeyReport([...breadcrumbJourneys, ...unrelatedJourneys])
)
expect(missingRequiredJourneyInventories(journeys)).toEqual([])
})
@@ -399,35 +403,40 @@ describe('EvenDrive drag-and-drop E2E gate', () => {
it('fails an inventory that lost the breadcrumb journeys entirely', () => {
// The pre-breadcrumb spec: still a valid Playwright inventory, but it
// can no longer certify the breadcrumb drop-move feature.
- const journeys = collectReportJourneys(
- journeyReport([
- { title: 'file drag into folder moves it' },
- { title: 'folder drag opens the one confirmation and Cancel changes nothing' },
- ])
- )
+ const journeys = collectReportJourneys(journeyReport(unrelatedJourneys))
const missing = missingRequiredJourneyInventories(journeys)
expect(missing).toEqual(REQUIRED_JOURNEY_INVENTORY.map(lane => lane.label))
})
- it('names the exact lane a partial inventory is missing', () => {
- const journeys = collectReportJourneys(
- journeyReport([breadcrumbJourneys[0]!, breadcrumbJourneys[1]!, breadcrumbJourneys[3]!])
- )
- expect(missingRequiredJourneyInventories(journeys)).toEqual([
- 'an active-crumb same-parent journey',
- ])
- })
-
- it('requires the same-parent lane through the active-crumb wording, not any crumb title', () => {
- const journeys = collectReportJourneys(
- journeyReport([breadcrumbJourneys[0]!, breadcrumbJourneys[1]!, breadcrumbJourneys[3]!])
- )
- expect(
- REQUIRED_JOURNEY_INVENTORY.find(lane => lane.label.includes('active-crumb'))?.pattern.test(
- 'file drag onto a breadcrumb crumb moves it up'
- )
- ).toBe(false)
- void journeys
+ it.each(
+ breadcrumbJourneys.map((lane, index) => ({
+ laneTitle: lane.title,
+ laneLabel: REQUIRED_JOURNEY_INVENTORY[index].label,
+ }))
+ )('fails when only the $laneLabel goes missing', ({ laneTitle, laneLabel }) => {
+ // Every lane is required INDEPENDENTLY: removing any single journey —
+ // including the root move — must fail the gate even while the other
+ // three breadcrumb journeys survive.
+ const remaining = breadcrumbJourneys.filter(journey => journey.title !== laneTitle)
+ expect(remaining).toHaveLength(breadcrumbJourneys.length - 1)
+ const journeys = collectReportJourneys(journeyReport([...remaining, ...unrelatedJourneys]))
+ expect(missingRequiredJourneyInventories(journeys)).toEqual([laneLabel])
+ })
+
+ it('requires the four lanes through disjoint anchored patterns', () => {
+ const titles = breadcrumbJourneys.map(journey => journey.title)
+ for (const lane of REQUIRED_JOURNEY_INVENTORY) {
+ // The lane pattern matches exactly one journey title — its own —
+ // so no sibling lane can satisfy it by accident.
+ const matches = titles.filter(title => lane.pattern.test(title))
+ expect(matches, lane.label).toHaveLength(1)
+ }
+ // And nothing outside the breadcrumb lanes is captured.
+ for (const lane of REQUIRED_JOURNEY_INVENTORY) {
+ for (const journey of unrelatedJourneys) {
+ expect(lane.pattern.test(journey.title), lane.label).toBe(false)
+ }
+ }
})
})
})