@defrex/autobuild 0.14.0 → 1.0.0-beta.1
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/README.md +13 -6
- package/SPEC.md +657 -100
- package/docs/architecture.md +230 -5
- package/docs/assets/headline-wide.png +0 -0
- package/docs/configuration.md +118 -14
- package/docs/hosted-service.md +18 -0
- package/docs/integration-tree.md +117 -0
- package/docs/landing-policy.md +150 -0
- package/docs/mcp.md +24 -0
- package/docs/migration-1.0.md +68 -0
- package/docs/operator-api.md +19 -8
- package/docs/remote-store-protocol.md +30 -7
- package/docs/remote-ticket-protocol.md +26 -5
- package/docs/restacking.md +79 -0
- package/docs/setup.md +53 -6
- package/docs/ticket-dependencies.md +69 -0
- package/docs/ticket-migration.md +8 -0
- package/package.json +3 -3
- package/packages/core/src/cli/attention.ts +25 -2
- package/packages/core/src/cli/build-control.ts +65 -41
- package/packages/core/src/cli/context.ts +54 -2
- package/packages/core/src/cli/dashboard/actions.ts +6 -3
- package/packages/core/src/cli/dashboard/landing-display.ts +6 -0
- package/packages/core/src/cli/dashboard/live.ts +5 -0
- package/packages/core/src/cli/dashboard/model.ts +142 -18
- package/packages/core/src/cli/dashboard/poll.ts +15 -9
- package/packages/core/src/cli/dashboard/refresh.ts +183 -0
- package/packages/core/src/cli/dashboard/render.ts +78 -28
- package/packages/core/src/cli/dashboard/repository-poll.ts +57 -0
- package/packages/core/src/cli/dashboard/selection.ts +7 -1
- package/packages/core/src/cli/dashboard/tree.ts +107 -0
- package/packages/core/src/cli/dispatch-frontend.ts +156 -105
- package/packages/core/src/cli/dispatch.ts +257 -139
- package/packages/core/src/cli/dispatcher-liveness.ts +15 -2
- package/packages/core/src/cli/help.ts +52 -33
- package/packages/core/src/cli/init-validation.ts +43 -2
- package/packages/core/src/cli/keyboard.ts +6 -0
- package/packages/core/src/cli/landings.ts +18 -0
- package/packages/core/src/cli/main.ts +49 -15
- package/packages/core/src/cli/mcp.ts +9 -0
- package/packages/core/src/cli/publication-settlement.ts +168 -2
- package/packages/core/src/cli/repository-status.ts +11 -0
- package/packages/core/src/cli/status.ts +72 -5
- package/packages/core/src/cli/terminal-restore.ts +54 -0
- package/packages/core/src/cli/terminal.ts +16 -2
- package/packages/core/src/cli/terminals.ts +98 -79
- package/packages/core/src/cli/ticket-editor.ts +10 -3
- package/packages/core/src/cli/ticket.ts +113 -18
- package/packages/core/src/cli/upgrade-commit.ts +4 -0
- package/packages/core/src/cli/upgrade-compatibility.ts +2 -2
- package/packages/core/src/cli/upgrade-landing.ts +69 -0
- package/packages/core/src/cli/upgrade.ts +16 -0
- package/packages/core/src/cli/wait.ts +115 -19
- package/packages/core/src/cli/watch.ts +51 -12
- package/packages/core/src/config/landing.ts +22 -0
- package/packages/core/src/config/live.ts +1 -0
- package/packages/core/src/config/schema.ts +3 -0
- package/packages/core/src/events/catalog.ts +48 -3
- package/packages/core/src/events/payloads.ts +295 -6
- package/packages/core/src/events/repository.ts +31 -0
- package/packages/core/src/integration/harness.ts +10 -0
- package/packages/core/src/kernel/__snapshots__/reducer-registry.test.ts.snap +1030 -239
- package/packages/core/src/kernel/auto-merge-default.ts +1 -0
- package/packages/core/src/kernel/auto-merge.ts +12 -3
- package/packages/core/src/kernel/build-identity.ts +94 -0
- package/packages/core/src/kernel/change-presence.ts +179 -0
- package/packages/core/src/kernel/dispatch-status.ts +17 -1
- package/packages/core/src/kernel/engine.ts +89 -2
- package/packages/core/src/kernel/generators/build-log.ts +23 -0
- package/packages/core/src/kernel/generators/leaf-restack-log.ts +110 -0
- package/packages/core/src/kernel/generators/node-restack-log.ts +94 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +11 -0
- package/packages/core/src/kernel/integration-completeness.ts +81 -0
- package/packages/core/src/kernel/integration-landing.ts +263 -0
- package/packages/core/src/kernel/integration-stack.ts +36 -0
- package/packages/core/src/kernel/integration-state.ts +135 -0
- package/packages/core/src/kernel/landing-policy.ts +47 -0
- package/packages/core/src/kernel/landing-publication.ts +41 -0
- package/packages/core/src/kernel/landing-readiness.ts +67 -0
- package/packages/core/src/kernel/landing-state.ts +96 -0
- package/packages/core/src/kernel/leaf-restack-completion.ts +24 -0
- package/packages/core/src/kernel/leaf-restack-state.ts +73 -0
- package/packages/core/src/kernel/log-index.ts +35 -5
- package/packages/core/src/kernel/node-landing.ts +439 -0
- package/packages/core/src/kernel/node-parent.ts +184 -0
- package/packages/core/src/kernel/node-restack-state.ts +191 -0
- package/packages/core/src/kernel/node-restack-transaction.ts +210 -0
- package/packages/core/src/kernel/node-restack.ts +274 -0
- package/packages/core/src/kernel/read-facts.ts +70 -3
- package/packages/core/src/kernel/reconcile-head.ts +51 -0
- package/packages/core/src/kernel/reconcile-restack.ts +560 -0
- package/packages/core/src/kernel/reducer-registry.ts +16 -0
- package/packages/core/src/kernel/reducer.ts +121 -6
- package/packages/core/src/kernel/snapshot-parent.ts +33 -0
- package/packages/core/src/ontology.ts +9 -1
- package/packages/core/src/operator/annotations.ts +12 -0
- package/packages/core/src/operator/control.ts +6 -0
- package/packages/core/src/operator/index.ts +4 -0
- package/packages/core/src/operator/landings.ts +35 -0
- package/packages/core/src/operator/presentation.ts +1 -0
- package/packages/core/src/operator/protocol.ts +12 -3
- package/packages/core/src/operator/query.ts +3 -1
- package/packages/core/src/operator/registry.ts +48 -19
- package/packages/core/src/operator/requests.ts +1 -8
- package/packages/core/src/operator/tickets.ts +55 -9
- package/packages/core/src/plugins/load.ts +3 -4
- package/packages/core/src/ports/forge/contract.ts +91 -3
- package/packages/core/src/ports/forge/fake.ts +142 -4
- package/packages/core/src/ports/forge/git-rewrite.ts +232 -0
- package/packages/core/src/ports/forge/github-readiness.ts +421 -0
- package/packages/core/src/ports/forge/github.ts +631 -35
- package/packages/core/src/ports/forge/local-git.ts +119 -5
- package/packages/core/src/ports/forge/readiness.ts +99 -0
- package/packages/core/src/ports/tickets/contract.ts +41 -0
- package/packages/core/src/ports/tickets/create.ts +8 -1
- package/packages/core/src/ports/tickets/fake.ts +32 -1
- package/packages/core/src/ports/tickets/file-codec.ts +7 -0
- package/packages/core/src/ports/tickets/file.ts +18 -1
- package/packages/core/src/ports/tickets/hosted-index.ts +2 -0
- package/packages/core/src/ports/tickets/linear.ts +124 -4
- package/packages/core/src/ports/tickets/migration.ts +25 -1
- package/packages/core/src/ports/tickets/operations.ts +7 -2
- package/packages/core/src/ports/tickets/remote-protocol.ts +19 -0
- package/packages/core/src/ports/tickets/remote.ts +10 -1
- package/packages/core/src/ports/tickets/revision.ts +3 -1
- package/packages/core/src/ports/tickets/tree.ts +148 -0
- package/packages/core/src/ports/tickets/update.ts +15 -2
- package/packages/core/src/ports/types.ts +135 -5
- package/packages/core/src/ports/workspace/git-worktree.ts +2 -1
- package/packages/core/src/ports/workspace/provider-capabilities.ts +1 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +60 -3
- package/packages/core/src/processes/build-runner.ts +530 -23
- package/packages/core/src/processes/dispatcher-selectors.ts +15 -9
- package/packages/core/src/processes/dispatcher.ts +2145 -203
- package/packages/core/src/processes/execution-no-progress.ts +46 -1
- package/packages/core/src/processes/publication-state.ts +30 -5
- package/packages/core/src/processes/repo-view.ts +21 -2
- package/packages/core/src/store/build-scope.ts +18 -0
- package/packages/core/src/store/contract.ts +658 -0
- package/packages/core/src/store/digest.ts +52 -4
- package/packages/core/src/store/local/schema.ts +25 -13
- package/packages/core/src/store/local/store.ts +117 -1
- package/packages/core/src/store/memory.ts +62 -1
- package/packages/core/src/store/phase-session.ts +17 -0
- package/packages/core/src/store/reduced-reads.ts +2 -1
- package/packages/core/src/store/reducer-value-shapes.json +10707 -6440
- package/packages/core/src/store/remote/client.ts +45 -0
- package/packages/core/src/store/remote/compatibility.ts +25 -9
- package/packages/core/src/store/remote/protocol.ts +11 -0
- package/packages/core/src/store/repo-state-events.ts +2 -0
- package/packages/core/src/store/session-handle.ts +15 -0
- package/packages/core/src/store/subscribe.ts +1 -1
- package/packages/core/src/store/types.ts +34 -4
- package/packages/core/src/testing/index.ts +2 -0
- package/packages/core/src/testing/reduced-read-budget.ts +48 -8
- package/packages/core/src/testing/refresh-scheduler.ts +32 -0
- package/skills/guide/SKILL.md +117 -64
- package/skills/guide/references/integration-tree.md +117 -0
- package/skills/guide/references/landing-policy.md +150 -0
- package/skills/guide/references/migration-1.0.md +68 -0
- package/skills/guide/references/operator-api.md +12 -5
- package/skills/guide/references/plugin-authoring.md +42 -3
- package/skills/guide/references/remote-store-protocol.md +30 -7
- package/skills/guide/references/remote-ticket-protocol.md +26 -5
- package/skills/guide/references/restacking.md +79 -0
- package/skills/guide/references/setup.md +53 -6
- package/skills/guide/references/ticket-dependencies.md +69 -0
- package/skills/guide/references/ticket-migration.md +8 -0
- package/skills/operate/SKILL.md +55 -5
- package/skills/reconcile/SKILL.md +55 -48
- package/skills/spec/SKILL.md +67 -1
- package/skills/tickets/SKILL.md +55 -2
- package/templates/autobuild.toml +3 -0
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import { forgeReadinessWarnings } from '../kernel/dispatch-status'
|
|
2
|
+
import { RepositoryPollCache } from './dashboard/repository-poll'
|
|
3
|
+
import {
|
|
4
|
+
DashboardRefresh,
|
|
5
|
+
interactionRead,
|
|
6
|
+
presentationReader,
|
|
7
|
+
type RefreshScheduler,
|
|
8
|
+
} from './dashboard/refresh'
|
|
9
|
+
import { FOCUS_REPORTING_MODE, installPresentationSuspension } from './terminal-restore'
|
|
1
10
|
import { DispatchRepositoryFeed } from './dispatch-repository-feed'
|
|
2
11
|
import { StandbyIdentityResolver } from './dispatcher-liveness'
|
|
3
12
|
import { configSchema, type Config } from '../config/schema'
|
|
@@ -25,7 +34,7 @@ import {
|
|
|
25
34
|
type DashboardSelection,
|
|
26
35
|
type DashboardView,
|
|
27
36
|
} from './dashboard/model'
|
|
28
|
-
import { DashboardBuildPollCache } from './dashboard/poll'
|
|
37
|
+
import { DashboardBuildPollCache, type DashboardPollSnapshot } from './dashboard/poll'
|
|
29
38
|
import {
|
|
30
39
|
dashboardContentWidth,
|
|
31
40
|
detailScrollLimit,
|
|
@@ -48,9 +57,10 @@ import {
|
|
|
48
57
|
type DispatchChildOptions,
|
|
49
58
|
} from './dispatch-process'
|
|
50
59
|
|
|
51
|
-
|
|
60
|
+
import type { TicketSource } from '../ports/types'
|
|
61
|
+
|
|
52
62
|
const PAINT_MS = 250
|
|
53
|
-
const ABORTABLE_STATUSES = new Set(['queued', 'running', 'paused', 'blocked'])
|
|
63
|
+
const ABORTABLE_STATUSES = new Set(['queued', 'running', 'collecting', 'paused', 'blocked'])
|
|
54
64
|
|
|
55
65
|
function validAbortConfirmation(state: BuildState | undefined): boolean {
|
|
56
66
|
return (
|
|
@@ -84,6 +94,7 @@ export interface DispatchFrontendOptions {
|
|
|
84
94
|
checkout?: string
|
|
85
95
|
storeRef: string
|
|
86
96
|
store: BuildStore
|
|
97
|
+
ticketSource?: () => Promise<TicketSource>
|
|
87
98
|
env: Record<string, string | undefined>
|
|
88
99
|
terminal: TerminalOut
|
|
89
100
|
input: TerminalInput
|
|
@@ -92,6 +103,7 @@ export interface DispatchFrontendOptions {
|
|
|
92
103
|
intervalMs?: number
|
|
93
104
|
intake?: boolean
|
|
94
105
|
defaultAutoMerge?: boolean
|
|
106
|
+
refreshScheduler?: RefreshScheduler
|
|
95
107
|
clock?: Clock
|
|
96
108
|
resolveDashboardRenderer?: DashboardRendererResolver
|
|
97
109
|
launchChild?: (input: {
|
|
@@ -134,18 +146,19 @@ export class DispatchFrontend {
|
|
|
134
146
|
private abortConfirmation: { slug: string } | undefined
|
|
135
147
|
private accepting = false
|
|
136
148
|
private cleanupInput: (() => void) | undefined
|
|
137
|
-
private
|
|
149
|
+
private refresh: DashboardRefresh | undefined
|
|
150
|
+
private suspension: ReturnType<typeof installPresentationSuspension> | undefined
|
|
151
|
+
private readonly reader: BuildStore
|
|
138
152
|
private paintTimer: ReturnType<typeof setInterval> | undefined
|
|
139
|
-
private polling = false
|
|
140
|
-
private pollInFlight: Promise<void> | undefined
|
|
141
153
|
private actionTail: Promise<void> = Promise.resolve()
|
|
142
154
|
private presentationRestored = false
|
|
143
155
|
private operatorStopRequested = false
|
|
144
156
|
|
|
145
157
|
constructor(private readonly opts: DispatchFrontendOptions) {
|
|
158
|
+
this.reader = presentationReader(opts.store, () => this.refresh?.admitted ?? true)
|
|
146
159
|
this.clock = opts.clock ?? systemClock
|
|
147
|
-
this.repositoryFeed = new DispatchRepositoryFeed(
|
|
148
|
-
this.standbyResolver = new StandbyIdentityResolver(
|
|
160
|
+
this.repositoryFeed = new DispatchRepositoryFeed(this.reader, opts.repo, this.clock)
|
|
161
|
+
this.standbyResolver = new StandbyIdentityResolver(this.reader, opts.repo, {
|
|
149
162
|
allowLookup: () => this.repositoryFeed.incompleteIdentities,
|
|
150
163
|
remember: (events, complete) => this.repositoryFeed.remember(events, complete),
|
|
151
164
|
})
|
|
@@ -180,8 +193,10 @@ export class DispatchFrontend {
|
|
|
180
193
|
})
|
|
181
194
|
}
|
|
182
195
|
|
|
183
|
-
private queue(operation: () => Promise<void
|
|
184
|
-
const result = this.actionTail.then(
|
|
196
|
+
private queue(operation: () => Promise<void>, interaction = true): void {
|
|
197
|
+
const result = this.actionTail.then(() =>
|
|
198
|
+
interaction ? interactionRead(operation) : operation(),
|
|
199
|
+
)
|
|
185
200
|
this.actionTail = result.then(
|
|
186
201
|
() => undefined,
|
|
187
202
|
async (error) => {
|
|
@@ -190,7 +205,7 @@ export class DispatchFrontend {
|
|
|
190
205
|
`dashboard action failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
191
206
|
'warning',
|
|
192
207
|
)
|
|
193
|
-
await this.renderOnce()
|
|
208
|
+
await this.renderOnce(interaction)
|
|
194
209
|
} catch {
|
|
195
210
|
// The next poll remains the recovery boundary.
|
|
196
211
|
}
|
|
@@ -254,6 +269,7 @@ export class DispatchFrontend {
|
|
|
254
269
|
}
|
|
255
270
|
|
|
256
271
|
private paint(): void {
|
|
272
|
+
if (this.refresh !== undefined && !this.refresh.painting) return
|
|
257
273
|
if (this.model === undefined) return
|
|
258
274
|
const renderer = this.opts.resolveDashboardRenderer?.() ?? renderDashboard
|
|
259
275
|
this.region.update(
|
|
@@ -269,7 +285,7 @@ export class DispatchFrontend {
|
|
|
269
285
|
private async loadConfig(kind: string, rev: number): Promise<Config> {
|
|
270
286
|
const key = `${kind}@${rev}`
|
|
271
287
|
if (this.config !== undefined && this.configRef === key) return this.config
|
|
272
|
-
const artifact = await this.
|
|
288
|
+
const artifact = await this.reader.getRepoArtifact(this.opts.repo, kind, rev)
|
|
273
289
|
if (artifact === null) throw new Error(`effective config ${key} is not retrievable`)
|
|
274
290
|
const parsed = configSchema.parse(JSON.parse(new TextDecoder().decode(artifact.content)))
|
|
275
291
|
this.config = parsed
|
|
@@ -278,33 +294,69 @@ export class DispatchFrontend {
|
|
|
278
294
|
return parsed
|
|
279
295
|
}
|
|
280
296
|
|
|
281
|
-
private async renderOnce(): Promise<void> {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
297
|
+
private async renderOnce(interaction = true): Promise<void> {
|
|
298
|
+
if (this.refresh !== undefined) return this.refresh.request(interaction)
|
|
299
|
+
return this.readFrame()
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
private readonly repositoryPoll = new RepositoryPollCache<{
|
|
303
|
+
repositoryEvents: RepositoryEvent[]
|
|
304
|
+
status: DispatchStatus
|
|
305
|
+
config: Config
|
|
306
|
+
observationCount: number
|
|
307
|
+
snapshot: DashboardPollSnapshot
|
|
308
|
+
}>()
|
|
309
|
+
|
|
310
|
+
private async readFrame(): Promise<void> {
|
|
311
|
+
if (this.refresh !== undefined && !this.refresh.admitted) return
|
|
312
|
+
const frame = await this.repositoryPoll.refresh({
|
|
313
|
+
position: () => this.reader.getRepoChangePosition(this.opts.repo),
|
|
314
|
+
now: () => this.clock().getTime(),
|
|
315
|
+
revision: 0,
|
|
316
|
+
enabled: !this.opts.once,
|
|
317
|
+
valid: (frame) => this.cache?.isCurrent(frame.snapshot) ?? false,
|
|
318
|
+
admitted: () => this.refresh === undefined || this.refresh.admitted,
|
|
319
|
+
nextPollMs: this.refresh?.intervalMs ?? 0,
|
|
320
|
+
read: async ({ fullEnrichment }) => {
|
|
321
|
+
const repositoryEvents = await this.events()
|
|
322
|
+
const status = this.dispatchStatus
|
|
323
|
+
const ref = status.effectiveConfig
|
|
324
|
+
if (ref === undefined) {
|
|
325
|
+
if (status.health === 'failed' && status.warningNotice !== undefined)
|
|
326
|
+
this.region.update([status.warningNotice])
|
|
327
|
+
// Startup is incomplete: retry at the same position.
|
|
328
|
+
return undefined
|
|
329
|
+
}
|
|
330
|
+
const config = await this.loadConfig(ref.kind, ref.rev)
|
|
331
|
+
let observationCount: number
|
|
332
|
+
try {
|
|
333
|
+
observationCount = unclaimedObservationCount({
|
|
334
|
+
digests: await this.reader.getRepoBuildDigests(this.opts.repo),
|
|
335
|
+
harvestEvents: repositoryEvents,
|
|
336
|
+
})
|
|
337
|
+
} catch {
|
|
338
|
+
// Incomplete snapshots never acknowledge the sampled position.
|
|
339
|
+
this.syncControls()
|
|
340
|
+
this.paint()
|
|
341
|
+
return undefined
|
|
342
|
+
}
|
|
343
|
+
this.cache ??= new DashboardBuildPollCache(this.reader, this.opts.repo, config)
|
|
344
|
+
const snapshot = await this.cache.refresh(config, this.configRevision, fullEnrichment)
|
|
345
|
+
if (!this.opts.once)
|
|
346
|
+
await this.standbyResolver.refresh(this.runId, status.yieldedHolder, this.clock())
|
|
347
|
+
await this.repositoryFeed.save()
|
|
348
|
+
if (!this.cache.isCurrent(snapshot)) return undefined
|
|
349
|
+
return { repositoryEvents, status, config, observationCount, snapshot }
|
|
350
|
+
},
|
|
351
|
+
})
|
|
352
|
+
if (frame === undefined) return
|
|
353
|
+
let { repositoryEvents, status } = frame
|
|
354
|
+
const { config, snapshot } = frame
|
|
355
|
+
const standby = this.opts.once
|
|
356
|
+
? undefined
|
|
357
|
+
: this.standbyResolver.current(this.runId, status.yieldedHolder, this.clock())
|
|
358
|
+
this.observationCount = frame.observationCount
|
|
359
|
+
this.refresh?.activity(snapshot.states.size > 0)
|
|
308
360
|
|
|
309
361
|
if (this.resumePrompt !== undefined) {
|
|
310
362
|
const state = snapshot.states.get(this.resumePrompt.slug)
|
|
@@ -325,11 +377,9 @@ export class DispatchFrontend {
|
|
|
325
377
|
const previous = this.model === undefined ? [] : dashboardSelections(this.model)
|
|
326
378
|
const warningLines = [
|
|
327
379
|
...status.roleWarnings,
|
|
380
|
+
...forgeReadinessWarnings(status),
|
|
328
381
|
...(status.warningNotice !== undefined ? [status.warningNotice] : []),
|
|
329
382
|
]
|
|
330
|
-
const standby = this.opts.once
|
|
331
|
-
? undefined
|
|
332
|
-
: await this.standbyResolver.refresh(this.runId, status.yieldedHolder, this.clock())
|
|
333
383
|
const projected = buildDashboardFromProjected(
|
|
334
384
|
snapshot.builds,
|
|
335
385
|
{
|
|
@@ -337,7 +387,7 @@ export class DispatchFrontend {
|
|
|
337
387
|
...(standby !== undefined ? { standby } : {}),
|
|
338
388
|
queued: status.queued ?? 0,
|
|
339
389
|
activeCount: [...snapshot.states.values()].filter(
|
|
340
|
-
(state) => state.status !== 'done' && state.status !== 'aborted',
|
|
390
|
+
(state) => state.kind !== 'node' && state.status !== 'done' && state.status !== 'aborted',
|
|
341
391
|
).length,
|
|
342
392
|
capacity: config.capacity,
|
|
343
393
|
observationCount: this.observationCount,
|
|
@@ -356,7 +406,6 @@ export class DispatchFrontend {
|
|
|
356
406
|
) {
|
|
357
407
|
this.view = undefined
|
|
358
408
|
}
|
|
359
|
-
await this.repositoryFeed.save()
|
|
360
409
|
this.model = projected
|
|
361
410
|
this.syncControls()
|
|
362
411
|
this.paint()
|
|
@@ -483,7 +532,7 @@ export class DispatchFrontend {
|
|
|
483
532
|
follow: true,
|
|
484
533
|
scroll: 0,
|
|
485
534
|
}
|
|
486
|
-
this.sessionFeed = new SessionStreamFeed(this.
|
|
535
|
+
this.sessionFeed = new SessionStreamFeed(this.reader, captured.slug)
|
|
487
536
|
this.syncControls()
|
|
488
537
|
this.paint()
|
|
489
538
|
// Kick the first read immediately rather than waiting one interval.
|
|
@@ -540,6 +589,7 @@ export class DispatchFrontend {
|
|
|
540
589
|
* feed's identity+cursor fence — the same pattern the DispatchLoop path
|
|
541
590
|
* uses, from the same shared feed module. */
|
|
542
591
|
private pollSessionFeed(): void {
|
|
592
|
+
if (this.refresh !== undefined && !this.refresh.admitted) return
|
|
543
593
|
const view = this.view
|
|
544
594
|
if (view?.kind !== 'session') return
|
|
545
595
|
if (view.status !== 'open' && view.error === undefined) {
|
|
@@ -574,7 +624,7 @@ export class DispatchFrontend {
|
|
|
574
624
|
}
|
|
575
625
|
this.syncControls()
|
|
576
626
|
this.paint()
|
|
577
|
-
})
|
|
627
|
+
}, false)
|
|
578
628
|
})
|
|
579
629
|
.catch(() => {
|
|
580
630
|
// The feed contains its own failures; the next poll retries.
|
|
@@ -616,7 +666,7 @@ export class DispatchFrontend {
|
|
|
616
666
|
const ref = this.dispatchStatus.effectiveConfig
|
|
617
667
|
if (ref === undefined) throw new Error('effective config is not available')
|
|
618
668
|
const config = await this.loadConfig(ref.kind, ref.rev)
|
|
619
|
-
this.cache ??= new DashboardBuildPollCache(this.
|
|
669
|
+
this.cache ??= new DashboardBuildPollCache(this.reader, this.opts.repo, config)
|
|
620
670
|
let snapshot = await this.cache.refresh(config, this.configRevision)
|
|
621
671
|
while (!this.cache.isCurrent(snapshot)) {
|
|
622
672
|
snapshot = await this.cache.refresh(config, this.configRevision)
|
|
@@ -638,11 +688,12 @@ export class DispatchFrontend {
|
|
|
638
688
|
}
|
|
639
689
|
|
|
640
690
|
private async buildAction(
|
|
641
|
-
kind: 'pause' | 'resume' | 'discard' | '
|
|
691
|
+
kind: 'pause' | 'resume' | 'discard' | 'hold' | 'land' | 'abort',
|
|
642
692
|
slug: string,
|
|
643
693
|
): Promise<void> {
|
|
644
694
|
const result = await controlBuild({
|
|
645
695
|
store: this.opts.store,
|
|
696
|
+
ticketSource: this.opts.ticketSource,
|
|
646
697
|
repo: this.opts.repo,
|
|
647
698
|
slug,
|
|
648
699
|
env: this.opts.env,
|
|
@@ -672,9 +723,9 @@ export class DispatchFrontend {
|
|
|
672
723
|
? `build ${slug}: discard requested`
|
|
673
724
|
: result.command === 'abort'
|
|
674
725
|
? `build ${slug}: abort requested`
|
|
675
|
-
: result.command === '
|
|
676
|
-
? `build ${slug}:
|
|
677
|
-
: `build ${slug}:
|
|
726
|
+
: result.command === 'land'
|
|
727
|
+
? `build ${slug}: landing consent requested`
|
|
728
|
+
: `build ${slug}: landing hold requested`
|
|
678
729
|
await this.report(message)
|
|
679
730
|
await this.renderOnce()
|
|
680
731
|
}
|
|
@@ -691,18 +742,6 @@ export class DispatchFrontend {
|
|
|
691
742
|
await this.renderOnce()
|
|
692
743
|
}
|
|
693
744
|
|
|
694
|
-
private async toggleDefaultAutoMerge(): Promise<void> {
|
|
695
|
-
const event = await toggleRepositorySetting({
|
|
696
|
-
store: this.opts.store,
|
|
697
|
-
repo: this.opts.repo,
|
|
698
|
-
user: buildControlUser(this.opts.env),
|
|
699
|
-
setting: 'auto-merge-default',
|
|
700
|
-
run: this.runId,
|
|
701
|
-
})
|
|
702
|
-
await this.report(`dispatcher auto-merge default ${event.enabled ? 'ON' : 'OFF'}`)
|
|
703
|
-
await this.renderOnce()
|
|
704
|
-
}
|
|
705
|
-
|
|
706
745
|
private async bulk(direction: 'pause' | 'resume'): Promise<void> {
|
|
707
746
|
const summary = await bulkControlRepository({
|
|
708
747
|
store: this.opts.store,
|
|
@@ -794,6 +833,7 @@ export class DispatchFrontend {
|
|
|
794
833
|
}
|
|
795
834
|
|
|
796
835
|
private onInput(input: TerminalInputEvent): void {
|
|
836
|
+
this.refresh?.interaction()
|
|
797
837
|
if (!this.accepting) return
|
|
798
838
|
if (input.type === 'interrupt') {
|
|
799
839
|
this.requestOperatorStop()
|
|
@@ -840,7 +880,7 @@ export class DispatchFrontend {
|
|
|
840
880
|
if (enter) {
|
|
841
881
|
// List/detail identity is captured synchronously before any Store read;
|
|
842
882
|
// a later selection move cannot retarget this navigation.
|
|
843
|
-
void this.openSelected().catch((error) =>
|
|
883
|
+
void interactionRead(() => this.openSelected()).catch((error) =>
|
|
844
884
|
this.report(
|
|
845
885
|
`dashboard open action failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
846
886
|
'warning',
|
|
@@ -858,13 +898,13 @@ export class DispatchFrontend {
|
|
|
858
898
|
if (this.selection?.kind === 'global' && this.view === undefined)
|
|
859
899
|
this.queue(() => this.toggleIntake())
|
|
860
900
|
break
|
|
861
|
-
case '
|
|
901
|
+
case 'o':
|
|
902
|
+
case 'l': {
|
|
862
903
|
const slug = this.selectedSlug()
|
|
863
|
-
if (
|
|
864
|
-
this.queue(() =>
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
}
|
|
904
|
+
if (slug !== undefined)
|
|
905
|
+
this.queue(() =>
|
|
906
|
+
this.buildAction(input.text.toLowerCase() === 'o' ? 'hold' : 'land', slug),
|
|
907
|
+
)
|
|
868
908
|
break
|
|
869
909
|
}
|
|
870
910
|
case 'p': {
|
|
@@ -909,38 +949,53 @@ export class DispatchFrontend {
|
|
|
909
949
|
}
|
|
910
950
|
}
|
|
911
951
|
|
|
912
|
-
private
|
|
913
|
-
this.accepting = true
|
|
952
|
+
private listen(): void {
|
|
914
953
|
this.cleanupInput = this.opts.input.start((input) => this.onInput(input), {
|
|
915
954
|
onListening: () => this.keyboard.query(),
|
|
916
955
|
onKeyboardFlags: (flags) => this.keyboard.reported(flags),
|
|
917
956
|
onDeviceAttributes: () => this.keyboard.deviceAttributes(),
|
|
957
|
+
onFocus: (focused) => this.refresh?.focus(focused),
|
|
958
|
+
onInteraction: () => this.refresh?.interaction(),
|
|
959
|
+
onSuspend: () => this.suspension?.suspend(),
|
|
918
960
|
})
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
private startPresentation(): void {
|
|
964
|
+
this.accepting = true
|
|
965
|
+
this.refresh = new DashboardRefresh(
|
|
966
|
+
async () => {
|
|
967
|
+
try {
|
|
968
|
+
await this.readFrame()
|
|
969
|
+
} catch (error) {
|
|
970
|
+
if (this.refresh?.admitted)
|
|
925
971
|
await this.report(
|
|
926
972
|
`dashboard render failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
927
973
|
'warning',
|
|
928
974
|
)
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
975
|
+
throw error
|
|
976
|
+
}
|
|
977
|
+
},
|
|
978
|
+
this.opts.refreshScheduler,
|
|
979
|
+
this.opts.store.networkReads,
|
|
980
|
+
)
|
|
981
|
+
this.listen()
|
|
982
|
+
this.opts.terminal.modes.enter(FOCUS_REPORTING_MODE)
|
|
983
|
+
this.suspension = installPresentationSuspension(
|
|
984
|
+
this.opts.terminal.modes,
|
|
985
|
+
() => {
|
|
986
|
+
this.refresh?.suspend()
|
|
987
|
+
this.cleanupInput?.()
|
|
988
|
+
this.cleanupInput = undefined
|
|
989
|
+
},
|
|
990
|
+
() => {
|
|
991
|
+
this.listen()
|
|
992
|
+
this.region.invalidate()
|
|
993
|
+
this.refresh?.resume()
|
|
994
|
+
},
|
|
995
|
+
)
|
|
940
996
|
this.paintTimer = setInterval(() => this.paint(), PAINT_MS)
|
|
941
|
-
this.pollTimer.unref?.()
|
|
942
997
|
this.paintTimer.unref?.()
|
|
943
|
-
|
|
998
|
+
void this.refresh.request()
|
|
944
999
|
}
|
|
945
1000
|
|
|
946
1001
|
private requestOperatorStop(): void {
|
|
@@ -959,13 +1014,14 @@ export class DispatchFrontend {
|
|
|
959
1014
|
if (this.presentationRestored) return
|
|
960
1015
|
this.presentationRestored = true
|
|
961
1016
|
this.accepting = false
|
|
1017
|
+
this.refresh?.stop()
|
|
1018
|
+
this.suspension?.close()
|
|
1019
|
+
this.opts.terminal.modes.leave(FOCUS_REPORTING_MODE)
|
|
962
1020
|
try {
|
|
963
1021
|
this.cleanupInput?.()
|
|
964
1022
|
} finally {
|
|
965
1023
|
this.cleanupInput = undefined
|
|
966
|
-
if (this.pollTimer !== undefined) clearInterval(this.pollTimer)
|
|
967
1024
|
if (this.paintTimer !== undefined) clearInterval(this.paintTimer)
|
|
968
|
-
this.pollTimer = undefined
|
|
969
1025
|
this.paintTimer = undefined
|
|
970
1026
|
this.region.finish()
|
|
971
1027
|
}
|
|
@@ -974,22 +1030,24 @@ export class DispatchFrontend {
|
|
|
974
1030
|
private async finishPresentation(): Promise<void> {
|
|
975
1031
|
if (!this.presentationRestored) {
|
|
976
1032
|
this.accepting = false
|
|
1033
|
+
this.refresh?.stop()
|
|
1034
|
+
this.suspension?.close()
|
|
1035
|
+
this.opts.terminal.modes.leave(FOCUS_REPORTING_MODE)
|
|
977
1036
|
try {
|
|
978
1037
|
this.cleanupInput?.()
|
|
979
1038
|
} finally {
|
|
980
1039
|
this.cleanupInput = undefined
|
|
981
1040
|
}
|
|
982
|
-
if (this.pollTimer !== undefined) clearInterval(this.pollTimer)
|
|
983
1041
|
if (this.paintTimer !== undefined) clearInterval(this.paintTimer)
|
|
984
|
-
this.pollTimer = undefined
|
|
985
1042
|
this.paintTimer = undefined
|
|
986
1043
|
}
|
|
987
1044
|
try {
|
|
988
|
-
await this.
|
|
1045
|
+
await this.refresh?.join()
|
|
989
1046
|
await this.actionTail
|
|
990
|
-
await this.
|
|
1047
|
+
if (this.opts.once) await this.readFrame()
|
|
1048
|
+
else if (!this.presentationRestored) await this.refresh?.finalRefresh()
|
|
991
1049
|
} catch {
|
|
992
|
-
//
|
|
1050
|
+
// Final presentation remains best-effort.
|
|
993
1051
|
} finally {
|
|
994
1052
|
this.region.finish()
|
|
995
1053
|
}
|
|
@@ -1005,13 +1063,6 @@ export class DispatchFrontend {
|
|
|
1005
1063
|
payload: { enabled: this.opts.intake, run: this.runId },
|
|
1006
1064
|
})
|
|
1007
1065
|
}
|
|
1008
|
-
if (this.opts.defaultAutoMerge !== undefined) {
|
|
1009
|
-
await this.opts.store.appendRepo(this.opts.repo, {
|
|
1010
|
-
actor,
|
|
1011
|
-
type: 'dispatcher.auto-merge-default-set',
|
|
1012
|
-
payload: { enabled: this.opts.defaultAutoMerge, run: this.runId },
|
|
1013
|
-
})
|
|
1014
|
-
}
|
|
1015
1066
|
|
|
1016
1067
|
try {
|
|
1017
1068
|
const delta = await this.repositoryFeed.warm()
|