Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

πŸ› fix(cli): guide acceptance storage quota recovery (#19921)

AmAzing-e27548173851
diff --git a/.agents/skills/acceptance/SKILL.md b/.agents/skills/acceptance/SKILL.md
index 783fec8b6d3..d8621032838 100644
--- a/.agents/skills/acceptance/SKILL.md
+++ b/.agents/skills/acceptance/SKILL.md
@@ -372,6 +372,35 @@ Before declaring the task done, prove coverage: for each check with
explicitly; a missing type holds the delivery at `uncertain` no matter how good
the work is.
+**Storage limits require a user-facing recovery handoff.** For report ingest,
+atomic evidence upload, or result submission with a file, recognize
+`recovery.reason: "storage_quota"`, `failedEvidence[].reason: "storage_quota"`,
+or a `storage_block:` error. Do not stop at "upload failed" or "noted in the PR":
+
+- In the final response, state that storage limits blocked publication, distinguish
+ locally observed results from uploaded evidence, and report the actual coverage.
+ Include the saved acceptance/round links when available; do not invent them for
+ an atomic submission that failed before saving a result.
+- Give **both clickable options**, in the user's language, using the CLI's
+ `recovery.cleanupUrl` and `recovery.upgradeUrl` verbatim:
+ **clean up unneeded acceptances** or **upgrade the plan**. Explain that cleanup
+ requires selecting "permanently delete all rounds, reports, and evidence files"
+ and cannot be undone. Deleting only the acceptance record or an evidence
+ association does not free file storage. Never delete user data automatically.
+- For an older CLI without recovery URLs, resolve its configured server using
+ `lh doctor --offline --json`, then use `/acceptance` and `/settings/plans` on
+ that server. For LobeHub Cloud, including its `app.lobehub.com` API endpoint,
+ the user-facing links are https://lobehub.com/acceptance and
+ https://lobehub.com/settings/plans . Do not send self-hosted users to Cloud
+ as a remedy for their server's storage limit.
+- Preserve local reports, artifacts, and the returned retry instructions. Stop
+ blind retries until the user has addressed storage. For a partially ingested
+ report, retry only failed artifacts using `failedEvidence[].retryArgs` or
+ `retryCommand`, not the whole ingest. For an atomic upload/submission that saved
+ nothing, retry that command. Supplementing evidence does not change recorded
+ verdicts; read back coverage and do not claim the delivery is complete while
+ required evidence is missing.
+
The final response for a completed handoff MUST include the published acceptance
URL together with the coverage result β€” never only a check-result id or a prose
claim. Obtain the links from the path you actually executed:
diff --git a/apps/cli/src/commands/acceptanceEvidence.ts b/apps/cli/src/commands/acceptanceEvidence.ts
index 702a8575090..5cdaef82f82 100644
--- a/apps/cli/src/commands/acceptanceEvidence.ts
+++ b/apps/cli/src/commands/acceptanceEvidence.ts
@@ -2,6 +2,9 @@ import { access } from 'node:fs/promises';
import path from 'node:path';
import type { TrpcClient } from '../api/client';
+import { resolveWorkspaceId } from '../api/workspace';
+import { resolveServerUrl } from '../settings';
+import { outputJson } from '../utils/format';
import { log } from '../utils/logger';
import { uploadLocalFile } from '../utils/uploadLocalFile';
import type { EvidenceType } from './verifyHelpers';
@@ -12,6 +15,74 @@ import {
reportEvidence,
} from './verifyHelpers';
+export async function storageQuotaRecovery(client: TrpcClient) {
+ const serverUrl = new URL(resolveServerUrl());
+ serverUrl.username = '';
+ serverUrl.password = '';
+ // Cloud's API still uses app.lobehub.com; user-facing pages use lobehub.com.
+ if (serverUrl.origin === 'https://app.lobehub.com') serverUrl.hostname = 'lobehub.com';
+ const workspaceId = resolveWorkspaceId();
+ let cleanupUrl: string | undefined;
+ let upgradeUrl: string | undefined;
+ let guidance: string;
+ if (workspaceId) {
+ let workspace: { id: string; slug: string } | null | undefined;
+ try {
+ workspace = await client.workspace.getById.query();
+ } catch {
+ log.warn(
+ 'Could not load workspace recovery links; verify the scope with lh workspace current.',
+ );
+ }
+ if (workspace?.id === workspaceId && workspace.slug) {
+ const prefix = `/${encodeURIComponent(workspace.slug)}`;
+ cleanupUrl = new URL(`${prefix}/resource`, serverUrl).toString();
+ upgradeUrl = new URL(`${prefix}/settings/plans`, serverUrl).toString();
+ guidance = `Free workspace space: ${cleanupUrl} β€” ask a workspace owner/admin to delete unneeded files from this workspace's resource library. Deletion is permanent and may affect shared evidence. Upgrade the workspace plan: ${upgradeUrl} (ask a workspace owner/admin if you cannot manage billing). Personal cleanup or a personal plan upgrade will not resolve this workspace quota.`;
+ } else {
+ guidance = `Could not verify workspace ${workspaceId}. Run lh workspace current and lh workspace list to check the scope, then ask its owner/admin to clean up workspace files or upgrade the workspace plan. Recovery links are unavailable; do not invent links or substitute personal pages.`;
+ }
+ } else {
+ cleanupUrl = new URL('/acceptance', serverUrl).toString();
+ upgradeUrl = new URL('/settings/plans', serverUrl).toString();
+ guidance = `Free space: ${cleanupUrl} β€” delete unneeded acceptances and select the option to permanently delete all rounds, reports, and evidence files. This cannot be undone; deleting only the acceptance record does not free file storage.\nUpgrade your plan: ${upgradeUrl}`;
+ }
+ return {
+ cleanupUrl,
+ message: [
+ `Acceptance evidence upload was blocked by file storage limits (CLI scope: ${workspaceId ? `workspace ${workspaceId}` : 'personal'}).`,
+ guidance,
+ 'Tell the user both options and any available links in the final response, following the scope-specific guidance above. Do not delete their files automatically. Keep local evidence and stop retrying until storage is available. Evidence publication is incomplete; do not claim all required evidence was uploaded.',
+ ].join('\n'),
+ reason: 'storage_quota' as const,
+ scope: workspaceId ? ('workspace' as const) : ('personal' as const),
+ upgradeUrl,
+ workspaceId,
+ };
+}
+
+/** Atomic submissions must stop before recording a result if its file cannot be uploaded. */
+export async function uploadAcceptanceFile(
+ client: TrpcClient,
+ file: string,
+ json: boolean | string | undefined,
+) {
+ try {
+ return await uploadLocalFile(client, file);
+ } catch (error) {
+ const message = error instanceof Error ? error.message : String(error);
+ if (!message.includes('storage_block:')) throw error;
+
+ const recovery = await storageQuotaRecovery(client);
+ process.exitCode = 1;
+ log.warn(recovery.message);
+ if (json !== undefined) {
+ outputJson({ error: message, recovery }, typeof json === 'string' ? json : undefined);
+ }
+ return undefined;
+ }
+}
+
export interface FailedReportEvidence {
checkResultId: string;
error: string;
diff --git a/apps/cli/src/commands/acceptanceRun.test.ts b/apps/cli/src/commands/acceptanceRun.test.ts
index 9aeaf504c98..a11ac053379 100644
--- a/apps/cli/src/commands/acceptanceRun.test.ts
+++ b/apps/cli/src/commands/acceptanceRun.test.ts
@@ -8,12 +8,15 @@ import { Command } from 'commander';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { getTrpcClient } from '../api/client';
+import { resolveWorkspaceId } from '../api/workspace';
+import { resolveServerUrl } from '../settings';
import { log } from '../utils/logger';
import { uploadLocalFile } from '../utils/uploadLocalFile';
import { attachAcceptanceRunCommands } from './acceptanceRun';
vi.mock('../api/client', () => ({ getTrpcClient: vi.fn() }));
-vi.mock('../settings', () => ({ resolveServerUrl: () => 'https://app.lobehub.com' }));
+vi.mock('../api/workspace', () => ({ resolveWorkspaceId: vi.fn() }));
+vi.mock('../settings', () => ({ resolveServerUrl: vi.fn() }));
vi.mock('../utils/uploadLocalFile', () => ({ uploadLocalFile: vi.fn() }));
describe('acceptance publication with missing evidence', () => {
@@ -28,6 +31,7 @@ describe('acceptance publication with missing evidence', () => {
uploadEvidence: { mutate: vi.fn() },
upsertReport: { mutate: vi.fn() },
},
+ workspace: { getById: { query: vi.fn() } },
};
let dir: string;
let printed: string[];
@@ -40,6 +44,7 @@ describe('acceptance publication with missing evidence', () => {
printed = [];
vi.spyOn(console, 'log').mockImplementation((line) => printed.push(String(line)));
vi.spyOn(log, 'warn').mockImplementation(() => {});
+ vi.mocked(resolveServerUrl).mockReturnValue('https://app.lobehub.com');
vi.mocked(getTrpcClient).mockResolvedValue(
client as unknown as Awaited<ReturnType<typeof getTrpcClient>>,
);
@@ -102,6 +107,11 @@ describe('acceptance publication with missing evidence', () => {
inlined: 1,
missingEvidence: [{ checkItemId: 'screen', types: ['screenshot'] }],
publicationStatus: 'partial',
+ recovery: {
+ cleanupUrl: 'https://lobehub.com/acceptance',
+ reason: 'storage_quota',
+ upgradeUrl: 'https://lobehub.com/settings/plans',
+ },
roundUrl: 'https://app.lobehub.com/acceptance/acceptance-1?r=2',
});
expect(result().failedEvidence[0].retryCommand).toContain('evidence upload');
@@ -184,10 +194,228 @@ describe('acceptance publication with missing evidence', () => {
expect(printed.join('\n')).toContain('evidence upload');
expect(printed.join('\n')).toContain('POSIX shell');
expect(printed.join('\n')).toContain('retryArgs');
- expect(log.warn).toHaveBeenCalledWith(expect.stringContaining('personal file storage quota'));
+ expect(log.warn).toHaveBeenCalledWith(
+ expect.stringContaining('https://lobehub.com/acceptance'),
+ );
+ expect(log.warn).toHaveBeenCalledWith(
+ expect.stringContaining('https://lobehub.com/settings/plans'),
+ );
+ expect(log.warn).toHaveBeenCalledWith(
+ expect.stringContaining('permanently delete all rounds, reports, and evidence files'),
+ );
expect(process.exitCode).toBe(1);
});
+ it('uses the configured server without credentials for recovery links', async () => {
+ vi.mocked(resolveServerUrl).mockReturnValue(
+ 'https://quota-user:quota%[email protected]:8443/base',
+ );
+ vi.mocked(uploadLocalFile).mockRejectedValue(new Error('storage_block:upgrade_required'));
+ await report(['screenshot'], ["screen's shot.png"]);
+
+ await run('ingest', dir, '--json');
+
+ expect(result().recovery).toMatchObject({
+ cleanupUrl: 'https://lobe.example.test:8443/acceptance',
+ upgradeUrl: 'https://lobe.example.test:8443/settings/plans',
+ });
+ expect(result().recovery.message).toContain('https://lobe.example.test:8443/acceptance');
+ expect(result().recovery.message).toContain('https://lobe.example.test:8443/settings/plans');
+ expect(JSON.stringify(result().recovery)).not.toMatch(
+ /quota-user|quota%40password|quota@password/,
+ );
+ expect(log.warn).toHaveBeenCalledWith(result().recovery.message);
+ });
+
+ it.each([undefined, 'Upload failed: 503 Service Unavailable'])(
+ 'does not suggest storage recovery for a non-quota outcome: %s',
+ async (error) => {
+ if (error) vi.mocked(uploadLocalFile).mockRejectedValue(new Error(error));
+ await report(['screenshot'], ["screen's shot.png"]);
+
+ await run('ingest', dir, '--json');
+
+ expect(result()).not.toHaveProperty('recovery');
+ expect(result().publicationStatus).toBe(error ? 'partial' : 'complete');
+ expect(log.warn).not.toHaveBeenCalledWith(expect.stringContaining('/settings/plans'));
+ expect(client.workspace.getById.query).not.toHaveBeenCalled();
+ },
+ );
+
+ describe.each(['ingest', 'evidence', 'result'])('workspace quota via %s', (command) => {
+ const upload = async (json: boolean) => {
+ await report(['screenshot'], ["screen's shot.png"]);
+ const args =
+ command === 'ingest'
+ ? ['ingest', dir]
+ : [
+ ...(command === 'evidence'
+ ? ['evidence', 'upload', '--check', 'result-screen']
+ : ['result', 'submit', '--run', 'run-1', '--item', 'screen']),
+ '--file',
+ path.join(dir, "screen's shot.png"),
+ '--type',
+ 'screenshot',
+ '--desc',
+ 'The visible result',
+ ];
+ await run(...args, ...(json ? ['--json'] : []));
+ };
+
+ beforeEach(() => {
+ vi.mocked(resolveWorkspaceId).mockReturnValue('workspace-42');
+ vi.mocked(uploadLocalFile).mockRejectedValue(new Error('storage_block:upgrade_required'));
+ client.workspace.getById.query.mockResolvedValue({ id: 'workspace-42', slug: 'design-team' });
+ });
+
+ it.each([false, true])('targets the workspace resources and plan (json=%s)', async (json) => {
+ await upload(json);
+
+ expect(process.exitCode).toBe(1);
+ expect(log.warn).toHaveBeenCalledWith(
+ expect.stringContaining('https://lobehub.com/design-team/resource'),
+ );
+ expect(log.warn).toHaveBeenCalledWith(
+ expect.stringContaining('https://lobehub.com/design-team/settings/plans'),
+ );
+ expect(log.warn).toHaveBeenCalledWith(
+ expect.stringContaining(
+ 'Personal cleanup or a personal plan upgrade will not resolve this workspace quota.',
+ ),
+ );
+ expect(log.warn).not.toHaveBeenCalledWith(
+ expect.stringContaining('https://lobehub.com/acceptance'),
+ );
+ expect(log.warn).not.toHaveBeenCalledWith(
+ expect.stringContaining('https://lobehub.com/settings/plans'),
+ );
+ if (json)
+ expect(result().recovery).toMatchObject({
+ cleanupUrl: 'https://lobehub.com/design-team/resource',
+ upgradeUrl: 'https://lobehub.com/design-team/settings/plans',
+ workspaceId: 'workspace-42',
+ scope: 'workspace',
+ reason: 'storage_quota',
+ });
+ });
+
+ it('keeps workspace links on a credential-free self-hosted origin', async () => {
+ vi.mocked(resolveServerUrl).mockReturnValue(
+ 'https://quota-user:quota%[email protected]:8443',
+ );
+
+ await upload(true);
+
+ expect(result().recovery).toMatchObject({
+ cleanupUrl: 'https://lobe.example.test:8443/design-team/resource',
+ upgradeUrl: 'https://lobe.example.test:8443/design-team/settings/plans',
+ });
+ expect(JSON.stringify(result().recovery)).not.toMatch(/quota-user|quota%40password/);
+ });
+
+ it.each([null, { id: 'another-workspace', slug: 'other' }, new Error('Lookup unavailable')])(
+ 'preserves quota recovery without personal links when workspace lookup returns %s',
+ async (workspace) => {
+ if (workspace instanceof Error) client.workspace.getById.query.mockRejectedValue(workspace);
+ else client.workspace.getById.query.mockResolvedValue(workspace);
+
+ await upload(true);
+
+ expect(process.exitCode).toBe(1);
+ expect(result().recovery).toMatchObject({
+ reason: 'storage_quota',
+ scope: 'workspace',
+ workspaceId: 'workspace-42',
+ });
+ expect(result().recovery).not.toHaveProperty('cleanupUrl');
+ expect(result().recovery).not.toHaveProperty('upgradeUrl');
+ expect(result().recovery.message).toContain('lh workspace current');
+ expect(result().recovery.message).toContain('workspace-42');
+ if (command === 'ingest') {
+ expect(result()).toMatchObject({
+ publicationStatus: 'partial',
+ acceptanceId: 'acceptance-1',
+ });
+ expect(result().failedEvidence[0].retryArgs).toContain('upload');
+ } else {
+ expect(client.verify.ingestResult.mutate).not.toHaveBeenCalled();
+ }
+ },
+ );
+ });
+
+ describe.each([
+ ['evidence', 'upload', '--check', 'result-screen'],
+ ['result', 'submit', '--run', 'run-1', '--item', 'screen'],
+ ])('atomic upload via %s %s', (...command) => {
+ it.each([false, true])(
+ 'reports quota recovery (json=%s) without writing a result',
+ async (json) => {
+ vi.mocked(resolveServerUrl).mockReturnValue(
+ 'https://quota-user:quota%[email protected]',
+ );
+ vi.mocked(uploadLocalFile).mockRejectedValue(new Error('storage_block:upgrade_required'));
+
+ await run(
+ ...command,
+ '--file',
+ path.join(dir, "screen's shot.png"),
+ '--type',
+ 'screenshot',
+ '--desc',
+ 'The visible result',
+ ...(json ? ['--json'] : []),
+ );
+
+ expect(process.exitCode).toBe(1);
+ expect(client.verify.uploadEvidence.mutate).not.toHaveBeenCalled();
+ expect(client.verify.ingestResult.mutate).not.toHaveBeenCalled();
+ expect(client.verify.createRun.mutate).not.toHaveBeenCalled();
+ expect(log.warn).toHaveBeenCalledWith(
+ expect.stringContaining('https://lobehub.com/acceptance'),
+ );
+ expect(log.warn).toHaveBeenCalledWith(
+ expect.stringContaining('https://lobehub.com/settings/plans'),
+ );
+ expect(JSON.stringify(vi.mocked(log.warn).mock.calls)).not.toMatch(
+ /quota-user|quota%40password|quota@password/,
+ );
+ expect(printed.join('\n')).not.toMatch(/quota-user|quota%40password|quota@password/);
+ if (json) {
+ expect(result()).toMatchObject({
+ error: 'storage_block:upgrade_required',
+ recovery: {
+ reason: 'storage_quota',
+ cleanupUrl: 'https://lobehub.com/acceptance',
+ upgradeUrl: 'https://lobehub.com/settings/plans',
+ },
+ });
+ }
+ },
+ );
+
+ it('preserves non-quota errors without suggesting an upgrade', async () => {
+ const error = new Error('Upload failed: 503 Service Unavailable');
+ vi.mocked(uploadLocalFile).mockRejectedValue(error);
+
+ await expect(
+ run(
+ ...command,
+ '--file',
+ path.join(dir, "screen's shot.png"),
+ '--type',
+ 'screenshot',
+ '--desc',
+ 'The visible result',
+ '--json',
+ ),
+ ).rejects.toBe(error);
+
+ expect(printed).toEqual([]);
+ expect(log.warn).not.toHaveBeenCalled();
+ });
+ });
+
it.each(['passed', 'failed'])(
'accounts for an unexecuted check alongside a %s case',
async (verdict) => {
diff --git a/apps/cli/src/commands/acceptanceRun.ts b/apps/cli/src/commands/acceptanceRun.ts
index 452eee25c75..e6750a8a142 100644
--- a/apps/cli/src/commands/acceptanceRun.ts
+++ b/apps/cli/src/commands/acceptanceRun.ts
@@ -15,9 +15,12 @@ import { confirm, outputJson, printTable, timeAgo, truncate } from '../utils/for
import { log } from '../utils/logger';
import type { LinkResult } from '../utils/skillWiring';
import { linkHarnessSkills } from '../utils/skillWiring';
-import { uploadLocalFile } from '../utils/uploadLocalFile';
import type { FailedReportEvidence } from './acceptanceEvidence';
-import { uploadReportEvidence } from './acceptanceEvidence';
+import {
+ storageQuotaRecovery,
+ uploadAcceptanceFile,
+ uploadReportEvidence,
+} from './acceptanceEvidence';
import {
type Decision,
DECISIONS,
@@ -368,7 +371,8 @@ async function submitAction(options: SubmitOptions): Promise<void> {
if (options.file) {
inlineContent = inlineTextEvidenceForFile(options.file, options.type!);
if (inlineContent === undefined) {
- const uploaded = await uploadLocalFile(client, options.file);
+ const uploaded = await uploadAcceptanceFile(client, options.file, options.json);
+ if (!uploaded) return;
fileId = uploaded.id;
}
}
@@ -445,7 +449,8 @@ async function evidenceUploadAction(options: EvidenceUploadOptions): Promise<voi
if (options.file) {
inlineContent = inlineTextEvidenceForFile(options.file, options.type);
if (inlineContent === undefined) {
- const uploaded = await uploadLocalFile(client, options.file);
+ const uploaded = await uploadAcceptanceFile(client, options.file, options.json);
+ if (!uploaded) return;
fileId = uploaded.id;
}
}
@@ -966,6 +971,9 @@ async function ingestReportAction(reportDir: string, options: IngestReportOption
? [...seenCheckItemIds].filter((id) => !plan.some((item) => item.id === id))
: [];
+ const recovery = failedEvidence.some((failure) => failure.reason === 'storage_quota')
+ ? await storageQuotaRecovery(client)
+ : undefined;
const partial = failedEvidence.length > 0 || missingEvidence.length > 0;
if (partial) {
process.exitCode = 1;
@@ -977,11 +985,7 @@ async function ingestReportAction(reportDir: string, options: IngestReportOption
'Unexecuted checks have no result to attach evidence to. Execute them and publish a new round on the same acceptance; do not re-ingest this unchanged report.',
);
}
- if (failedEvidence.some((failure) => failure.reason === 'storage_quota')) {
- log.warn(
- 'Acceptance evidence uses your personal file storage quota. Free space or upgrade your storage plan, then retry the failed artifacts.',
- );
- }
+ if (recovery) log.warn(recovery.message);
}
if (options.json !== undefined) {
@@ -1000,6 +1004,7 @@ async function ingestReportAction(reportDir: string, options: IngestReportOption
proposalPosted,
publicationStatus: partial ? 'partial' : 'complete',
pullRequest,
+ recovery,
roundIndex,
roundUrl,
scenario,