Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/1281.fixed.md
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 6 additions & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added docs/images/1281/after-en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/1281/after-zh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/1281/before-en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/1281/before-zh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,7 @@ export async function buildApp(options: BuildOptions): Promise<BuiltApp> {
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,
Expand Down
13 changes: 10 additions & 3 deletions src/views/checklist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test/layout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 7 additions & 6 deletions test/nextAction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const completeSetup: SetupState = {
platformQuotaRemainingCny: 50,
platformQuotaUnlimited: false, platformQuotaComfortCny: 50,
instanceReady: true,
instancesUsed: true,
jobs: 1,
firstJobStatus: 'succeeded',
firstPrUrl: null,
Expand Down Expand Up @@ -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"/)
Expand All @@ -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"/)
Expand All @@ -273,22 +274,22 @@ 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')
assert.match(section, /Nothing needs you/, 'the exhausted platform quota is not the user\'s problem')
})

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"/)
})
Expand Down Expand Up @@ -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')
Expand Down
1 change: 1 addition & 0 deletions test/pages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
77 changes: 76 additions & 1 deletion test/setupChecklist.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function state(patch: Partial<SetupState> = {}): SetupState {
platformQuotaUnlimited: false,
platformQuotaComfortCny: 50,
instanceReady: false,
instancesUsed: true,
jobs: 0,
firstJobStatus: null,
firstPrUrl: null,
Expand Down Expand Up @@ -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:')
Expand All @@ -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, /<li class="setup-step is-done[^"]*" data-setup-step="instance"/, 'the workspace step is done when the deployment has none')
assert.doesNotMatch(page.body, /Start the instance first|Start the workspace first/, 'the first job is not blocked on a workspace this deployment cannot start')
const chinese = await built.app.inject({ method: 'GET', url: '/dashboard', headers: { cookie: `${session.cookie}; fledge_lang=zh` } })
assert.doesNotMatch(chinese.body, /先启动实例|先启动工作区/, 'the zh render asks for no workspace either')
} finally {
await built.app.close()
store.close()
}
})

test('a deployment with workspaces still blocks the first job on a stopped workspace', 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: '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(/<li[^>]*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(/<li[^>]*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(/<li[^>]*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(/<li[^>]*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'
Expand Down Expand Up @@ -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()
Expand Down
Loading