diff --git a/changelog.d/1281.fixed.md b/changelog.d/1281.fixed.md new file mode 100644 index 00000000..12fc0d86 --- /dev/null +++ b/changelog.d/1281.fixed.md @@ -0,0 +1 @@ +A deployment without workspaces is no longer asked for one: when `FLYBOT_INSTANCE_IMAGE` is empty, the dashboard's first-run checklist marks the workspace step done and stops blocking the first job on it, and the primary next action becomes running the repository's first job. Deployments that set an image keep the step and the blocker, and the blocker now says workspace instead of instance. diff --git a/docs/architecture.md b/docs/architecture.md index eadedee8..279ec0a4 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -260,7 +260,12 @@ and a skipped check never read the same. The writer of that field is the drill's step's state is read from the database on the request, so a cookie, a second browser or a cleared store cannot change which step is next. The pure state machine decides the single primary action; a step whose prerequisite is - missing states the reason instead of offering a control. The model-provider + missing states the reason instead of offering a control. The workspace step + answers the deployment, not only the rows: with an empty + `FLYBOT_INSTANCE_IMAGE` the deployment runs no per-repository workspaces, so + that step reads done and the first job is not blocked on it; a deployment that + sets an image keeps the step and the blocker until a workspace is ready. The + model-provider step is optional while the platform model is configured (`PLATFORM_LLM_BASE_URL` and `PLATFORM_LLM_KEY`) and the account's platform quota is not exhausted: it reads as satisfied by the platform quota, keeps the diff --git a/docs/images/1281/after-en.png b/docs/images/1281/after-en.png new file mode 100644 index 00000000..d05bd6e9 Binary files /dev/null and b/docs/images/1281/after-en.png differ diff --git a/docs/images/1281/after-zh.png b/docs/images/1281/after-zh.png new file mode 100644 index 00000000..e285f504 Binary files /dev/null and b/docs/images/1281/after-zh.png differ diff --git a/docs/images/1281/before-en.png b/docs/images/1281/before-en.png new file mode 100644 index 00000000..42632476 Binary files /dev/null and b/docs/images/1281/before-en.png differ diff --git a/docs/images/1281/before-zh.png b/docs/images/1281/before-zh.png new file mode 100644 index 00000000..30892d63 Binary files /dev/null and b/docs/images/1281/before-zh.png differ diff --git a/src/app.ts b/src/app.ts index eeb09d28..e19b12b9 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1650,6 +1650,7 @@ export async function buildApp(options: BuildOptions): Promise { platformQuotaUnlimited: setupQuota.unlimited, platformQuotaComfortCny: config.quota.comfortCny, instanceReady: allRepos.some((repo) => store.getRepoInstance(repo.id)?.status === 'ready'), + instancesUsed: config.flybot.instanceImage !== '', jobs: setupJobsTotal, firstJobStatus: firstJob?.status ?? null, firstPrUrl: firstJob?.pr_url ?? null, diff --git a/src/views/checklist.ts b/src/views/checklist.ts index e521adff..d0e171da 100644 --- a/src/views/checklist.ts +++ b/src/views/checklist.ts @@ -8,7 +8,14 @@ import type { Translate } from '../i18n.js' export type SetupStepKey = 'repo' | 'role' | 'model' | 'instance' | 'job' -export interface SetupState { +/** + * Whether this deployment runs per-repository workspaces at all. An empty + * `FLYBOT_INSTANCE_IMAGE` means it runs without containers, so a workspace + * cannot be started and must be neither a step nor a blocker (#1281). + */ +export interface SetupWorkspaces { instancesUsed: boolean } + +export interface SetupState extends SetupWorkspaces { repos: number roleChosen: boolean // A provider with at least one model exists, but it may not be selected by a @@ -141,7 +148,7 @@ export function setupChecklist(state: SetupState, t: Translate): SetupChecklist { key: 'instance', title: t('启动工作区', 'Start workspace'), - done: state.instanceReady, + done: !state.instancesUsed || state.instanceReady, action: { href: repoHref, label: t('打开仓库启动', 'Open the repository') }, blocked: !state.modelConfigured && !state.platformAvailable ? state.providerConfigured @@ -154,7 +161,7 @@ export function setupChecklist(state: SetupState, t: Translate): SetupChecklist title: t('运行第一个任务', 'Run the first job'), done: state.jobs > 0, action: { href: repoHref, label: t('运行任务', 'Run a job') }, - blocked: !state.instanceReady ? t('先启动实例。', 'Start the instance first.') : null, + blocked: state.instancesUsed && !state.instanceReady ? t('先启动工作区。', 'Start the workspace first.') : null, }, ] const done = steps.filter((step) => step.done).length diff --git a/test/layout.test.ts b/test/layout.test.ts index d34752d6..016b4877 100644 --- a/test/layout.test.ts +++ b/test/layout.test.ts @@ -443,6 +443,7 @@ test('no control is a typed glyph, and every drawn icon keeps its label', () => platformQuotaUnlimited: false, platformQuotaComfortCny: 50, instanceReady: false, + instancesUsed: true, jobs: 0, firstJobStatus: null, firstPrUrl: null, @@ -578,6 +579,7 @@ test('the console keeps its card count below the measured base on every page', ( platformQuotaUnlimited: false, platformQuotaComfortCny: 50, instanceReady: false, + instancesUsed: true, jobs: 0, firstJobStatus: null, firstPrUrl: null, diff --git a/test/nextAction.test.ts b/test/nextAction.test.ts index a191da73..be113bd1 100644 --- a/test/nextAction.test.ts +++ b/test/nextAction.test.ts @@ -33,6 +33,7 @@ const completeSetup: SetupState = { platformQuotaRemainingCny: 50, platformQuotaUnlimited: false, platformQuotaComfortCny: 50, instanceReady: true, + instancesUsed: true, jobs: 1, firstJobStatus: 'succeeded', firstPrUrl: null, @@ -249,7 +250,7 @@ test('an account with every repository switched off leads with the lock, not the }) test('an unfinished first run keeps exactly one primary action, in the next-action block', () => { - const setup: SetupState = { repos: 1, roleChosen: false, providerConfigured: false, modelConfigured: false, platformAvailable: false, platformQuotaRemainingCny: 0, platformQuotaUnlimited: false, platformQuotaComfortCny: 50, instanceReady: false, jobs: 0, firstJobStatus: null, firstPrUrl: null, repoHref: '/repos/repo_1' } + const setup: SetupState = { repos: 1, roleChosen: false, providerConfigured: false, modelConfigured: false, platformAvailable: false, platformQuotaRemainingCny: 0, platformQuotaUnlimited: false, platformQuotaComfortCny: 50, instanceReady: false, instancesUsed: true, jobs: 0, firstJobStatus: null, firstPrUrl: null, repoHref: '/repos/repo_1' } const html = render('en', { setup }) const section = nextActionBlock(html) assert.match(section, /data-next-action="setup"/) @@ -263,7 +264,7 @@ test('an unfinished first run keeps exactly one primary action, in the next-acti }) test('platform quota satisfies the model step, so the next action is the instance', () => { - const setup: SetupState = { repos: 1, roleChosen: true, providerConfigured: false, modelConfigured: false, platformAvailable: true, platformQuotaRemainingCny: 50, platformQuotaUnlimited: false, platformQuotaComfortCny: 50, instanceReady: false, jobs: 0, firstJobStatus: null, firstPrUrl: null, repoHref: '/repos/repo_1' } + const setup: SetupState = { repos: 1, roleChosen: true, providerConfigured: false, modelConfigured: false, platformAvailable: true, platformQuotaRemainingCny: 50, platformQuotaUnlimited: false, platformQuotaComfortCny: 50, instanceReady: false, instancesUsed: true, jobs: 0, firstJobStatus: null, firstPrUrl: null, repoHref: '/repos/repo_1' } const html = render('en', { setup }) const section = nextActionBlock(html) assert.match(section, /data-next-action="setup"/) @@ -273,14 +274,14 @@ test('platform quota satisfies the model step, so the next action is the instanc }) test('without platform quota the missing model is still the next action', () => { - const setup: SetupState = { repos: 1, roleChosen: true, providerConfigured: false, modelConfigured: false, platformAvailable: false, platformQuotaRemainingCny: 0, platformQuotaUnlimited: false, platformQuotaComfortCny: 50, instanceReady: false, jobs: 0, firstJobStatus: null, firstPrUrl: null, repoHref: '/repos/repo_1' } + const setup: SetupState = { repos: 1, roleChosen: true, providerConfigured: false, modelConfigured: false, platformAvailable: false, platformQuotaRemainingCny: 0, platformQuotaUnlimited: false, platformQuotaComfortCny: 50, instanceReady: false, instancesUsed: true, jobs: 0, firstJobStatus: null, firstPrUrl: null, repoHref: '/repos/repo_1' } const section = nextActionBlock(render('en', { setup })) assert.match(section, /data-next-action="setup"/) assert.match(section, /Add a model provider/) }) test('an own repository model keeps the quota card out of the next action', () => { - const setup: SetupState = { repos: 1, roleChosen: true, providerConfigured: true, modelConfigured: true, platformAvailable: false, platformQuotaRemainingCny: 0, platformQuotaUnlimited: false, platformQuotaComfortCny: 50, instanceReady: true, jobs: 1, firstJobStatus: 'succeeded', firstPrUrl: null, repoHref: '/repos/repo_1' } + const setup: SetupState = { repos: 1, roleChosen: true, providerConfigured: true, modelConfigured: true, platformAvailable: false, platformQuotaRemainingCny: 0, platformQuotaUnlimited: false, platformQuotaComfortCny: 50, instanceReady: true, instancesUsed: true, jobs: 1, firstJobStatus: 'succeeded', firstPrUrl: null, repoHref: '/repos/repo_1' } const html = render('en', { setup }, (store, user) => { store.setUserQuota(user.id, 0) }) const section = nextActionBlock(html) assert.doesNotMatch(section, /data-next-action="quota"/, 'a selected repository model is not platform-funded') @@ -288,7 +289,7 @@ test('an own repository model keeps the quota card out of the next action', () = }) test('without an own model the exhausted quota is still the next action', () => { - const setup: SetupState = { repos: 1, roleChosen: true, providerConfigured: false, modelConfigured: false, platformAvailable: false, platformQuotaRemainingCny: 0, platformQuotaUnlimited: false, platformQuotaComfortCny: 50, instanceReady: false, jobs: 0, firstJobStatus: null, firstPrUrl: null, repoHref: '/repos/repo_1' } + const setup: SetupState = { repos: 1, roleChosen: true, providerConfigured: false, modelConfigured: false, platformAvailable: false, platformQuotaRemainingCny: 0, platformQuotaUnlimited: false, platformQuotaComfortCny: 50, instanceReady: false, instancesUsed: true, jobs: 0, firstJobStatus: null, firstPrUrl: null, repoHref: '/repos/repo_1' } const section = nextActionBlock(render('en', { setup }, (store, user) => { store.setUserQuota(user.id, 0) })) assert.match(section, /data-next-action="quota"/) }) @@ -323,7 +324,7 @@ test('secondary sections collapse into one disclosure and lose nothing', () => { }) test('the disclosure opens when the next action points inside it', () => { - const setup: SetupState = { repos: 0, roleChosen: false, providerConfigured: false, modelConfigured: false, platformAvailable: false, platformQuotaRemainingCny: 0, platformQuotaUnlimited: false, platformQuotaComfortCny: 50, instanceReady: false, jobs: 0, firstJobStatus: null, firstPrUrl: null, repoHref: null } + const setup: SetupState = { repos: 0, roleChosen: false, providerConfigured: false, modelConfigured: false, platformAvailable: false, platformQuotaRemainingCny: 0, platformQuotaUnlimited: false, platformQuotaComfortCny: 50, instanceReady: false, instancesUsed: true, jobs: 0, firstJobStatus: null, firstPrUrl: null, repoHref: null } const html = render('en', { setup }) const section = nextActionBlock(html) assert.deepEqual(targets(section), ['#add-repo'], 'the first step is adding a repository') diff --git a/test/pages.test.ts b/test/pages.test.ts index cb3f2e6b..cd3528d6 100644 --- a/test/pages.test.ts +++ b/test/pages.test.ts @@ -3045,6 +3045,7 @@ const quotaBannerSetup = (modelConfigured: boolean) => ({ platformQuotaUnlimited: false, platformQuotaComfortCny: 50, instanceReady: true, + instancesUsed: true, jobs: 3, firstJobStatus: 'merged', firstPrUrl: 'https://github.com/o/r/pull/1', diff --git a/test/setupChecklist.test.ts b/test/setupChecklist.test.ts index 4ec27f23..e490bba7 100644 --- a/test/setupChecklist.test.ts +++ b/test/setupChecklist.test.ts @@ -28,6 +28,7 @@ function state(patch: Partial = {}): SetupState { platformQuotaUnlimited: false, platformQuotaComfortCny: 50, instanceReady: false, + instancesUsed: true, jobs: 0, firstJobStatus: null, firstPrUrl: null, @@ -154,6 +155,7 @@ test('the quota comfort threshold comes from config, not a second constant', () test('the dashboard shows platform quota instead of a model requirement when the platform can fund the run', async () => { const config = testConfig() + config.flybot.instanceImage = 'ghcr.io/example/flybot:latest' config.llm.baseUrl = 'https://platform.example/v1' config.llm.key = 'platform-key' const store = new Store(':memory:') @@ -179,6 +181,79 @@ test('the dashboard shows platform quota instead of a model requirement when the } }) +test('a deployment without workspaces does not ask for one', async () => { + const config = testConfig() + config.llm.baseUrl = 'https://platform.example/v1' + config.llm.key = 'platform-key' + const store = new Store(':memory:') + const built = await buildApp({ config, store, mailer: new MemoryMailer(), runner: new MockRunner(), startScheduler: false }) + try { + const user = makeUser(store, { login: 'no-workspaces', status: 'approved' }) + const session = sessionFor(built, user) + store.createRepo({ id: 'repo_no_ws', userId: user.id, owner: 'o', name: 'no-ws', defaultBranch: 'main', tokenEnc: 'x', permission: 'admin', repoRole: 'maintainer', goal: '', autoIterate: false, intervalMinutes: 1440 }) + const page = await built.app.inject({ method: 'GET', url: '/dashboard', headers: { cookie: `${session.cookie}; fledge_lang=en` } }) + assert.equal(page.statusCode, 200) + assert.match(page.body, /data-setup-next="job"/, 'an empty FLYBOT_INSTANCE_IMAGE makes the first job the next step') + assert.match(page.body, /
  • { + const config = testConfig() + config.flybot.instanceImage = 'ghcr.io/example/flybot:latest' + config.llm.baseUrl = 'https://platform.example/v1' + config.llm.key = 'platform-key' + const store = new Store(':memory:') + const built = await buildApp({ config, store, mailer: new MemoryMailer(), runner: new MockRunner(), startScheduler: false }) + try { + const user = makeUser(store, { login: 'with-workspaces', status: 'approved' }) + const session = sessionFor(built, user) + store.createRepo({ id: 'repo_ws', userId: user.id, owner: 'o', name: 'ws', defaultBranch: 'main', tokenEnc: 'x', permission: 'admin', repoRole: 'maintainer', goal: '', autoIterate: false, intervalMinutes: 1440 }) + const page = await built.app.inject({ method: 'GET', url: '/dashboard', headers: { cookie: `${session.cookie}; fledge_lang=en` } }) + assert.equal(page.statusCode, 200) + assert.match(page.body, /data-setup-next="instance"/, 'a deployment with workspaces still asks for one') + const instanceStep = page.body.match(/]*data-setup-step="instance"[\s\S]*?<\/li>/)?.[0] ?? '' + assert.ok(instanceStep !== '', 'the workspace step renders') + assert.doesNotMatch(instanceStep, /is-done/, 'no ready workspace: the step stays unmet') + const jobStep = page.body.match(/]*data-setup-step="job"[\s\S]*?<\/li>/)?.[0] ?? '' + assert.match(jobStep, /setup-blocked/, 'the first job is still blocked') + } finally { + await built.app.close() + store.close() + } +}) + +test('the first-job blocker names the workspace, not the instance', async () => { + const config = testConfig() + config.flybot.instanceImage = 'ghcr.io/example/flybot:latest' + config.llm.baseUrl = 'https://platform.example/v1' + config.llm.key = 'platform-key' + const store = new Store(':memory:') + const built = await buildApp({ config, store, mailer: new MemoryMailer(), runner: new MockRunner(), startScheduler: false }) + try { + const user = makeUser(store, { login: 'blocker-wording', status: 'approved' }) + const session = sessionFor(built, user) + store.createRepo({ id: 'repo_wording', userId: user.id, owner: 'o', name: 'wording', defaultBranch: 'main', tokenEnc: 'x', permission: 'admin', repoRole: 'maintainer', goal: '', autoIterate: false, intervalMinutes: 1440 }) + const page = await built.app.inject({ method: 'GET', url: '/dashboard', headers: { cookie: `${session.cookie}; fledge_lang=en` } }) + const jobStep = page.body.match(/]*data-setup-step="job"[\s\S]*?<\/li>/)?.[0] ?? '' + assert.match(jobStep, /Start the workspace first/, 'the blocker names the workspace') + assert.doesNotMatch(jobStep, /Start the instance first/, 'the blocker no longer names the instance') + const chinese = await built.app.inject({ method: 'GET', url: '/dashboard', headers: { cookie: `${session.cookie}; fledge_lang=zh` } }) + const zhJobStep = chinese.body.match(/]*data-setup-step="job"[\s\S]*?<\/li>/)?.[0] ?? '' + assert.match(zhJobStep, /先启动工作区/, 'the zh blocker names the workspace') + assert.doesNotMatch(zhJobStep, /先启动实例/, 'the zh blocker no longer names the instance') + } finally { + await built.app.close() + store.close() + } +}) + test('a comfortable platform balance only names the remaining quota', async () => { const config = testConfig() config.llm.baseUrl = 'https://platform.example/v1' @@ -324,7 +399,7 @@ test('the route detects the step from rows, so a second browser or a cleared coo store.setRepoModelSelection('repo_route', [model.id], model.id) const withSelection = await built.app.inject({ method: 'GET', url: '/dashboard', headers: { cookie } }) - assert.match(withSelection.body, /data-setup-next="instance"/, 'a selected repository model completes the model step') + assert.match(withSelection.body, /data-setup-next="job"/, 'a selected repository model completes the model step; with no workspaces the first job is next') } finally { await built.app.close() store.close()