Line

You are reading docs for v0.8. See latest (v0.9)

ui/server/src/autoCommit

Commit-on-save for the Cockpit — the trigger half, which is ui/ (proprietary-future) because it is policy and lifecycle, not computation.

Cockpit server, v0.8. Source: ui/server/src/autoCommit.mjs.

Classes#

AutoCommitError#

Defined in: ui/server/src/autoCommit.mjs:38

Extends#

  • Error

Constructors#

Constructor

new AutoCommitError(message, status?): AutoCommitError

Defined in: ui/server/src/autoCommit.mjs:39

Parameters
message

any

status?

number = 400

Returns

AutoCommitError

Overrides

Error.constructor

Properties#

name

name: string

Defined in: ui/server/src/autoCommit.mjs:41

Inherited from

Error.name

status

status: number

Defined in: ui/server/src/autoCommit.mjs:42

Variables#

DIRTY_ANSWERS#

const DIRTY_ANSWERS: string[]

Defined in: ui/server/src/autoCommit.mjs:33


MAX_COALESCE_MS#

const MAX_COALESCE_MS: number

Defined in: ui/server/src/autoCommit.mjs:36

Upper bound on the coalescing window: a day-long window is indistinguishable from manual and would quietly lose the audit trail the feature exists to produce.

Functions#

answerDirtyPrompt()#

answerDirtyPrompt(root, __namedParameters?): object

Defined in: ui/server/src/autoCommit.mjs:201

Answer the dirty-tree prompt. remember stores it for this project until the server restarts.

Parameters#

root

any

__namedParameters?
remember?

boolean = false

Returns#

object

committed

committed: boolean = false

status

status: any = reason


endSession()#

endSession(root): void

Defined in: ui/server/src/autoCommit.mjs:94

Forget the session for one project (e.g. the user switched projectDir). Never touches git.

Parameters#

root

any

Returns#

void


flushSession()#

flushSession(root): object

Defined in: ui/server/src/autoCommit.mjs:235

Commit now: the Commit button in manual, and the "don't wait for the window" action.

Parameters#

root

any

Returns#

object

committed

committed: boolean = false

status

status: any = reason


getCommitConfig()#

getCommitConfig(): object

Defined in: ui/server/src/autoCommit.mjs:54

Returns#

object

branchPrefix

branchPrefix: "cockpit" = 'cockpit'

branchSuffix

branchSuffix: "" = ''

coalesceMs

coalesceMs: 30000 = DEFAULT_COALESCE_MS

enabled

enabled: true = true

maxCoalesceMs

maxCoalesceMs: number = MAX_COALESCE_MS

messagePrefix

messagePrefix: "CON" = 'CON'

mode

mode: "coalesce" = 'coalesce'

modes

modes: string[]


getSessionStatus()#

getSessionStatus(root): object

Defined in: ui/server/src/autoCommit.mjs:316

Everything the Cockpit needs to render the auto-commit indicator and the dirty-tree prompt.

Parameters#

root

any

Returns#

object

branch

branch: any

config

config: object

config.branchPrefix

branchPrefix: "cockpit" = 'cockpit'

config.branchSuffix

branchSuffix: "" = ''

config.coalesceMs

coalesceMs: 30000 = DEFAULT_COALESCE_MS

config.enabled

enabled: true = true

config.maxCoalesceMs

maxCoalesceMs: number = MAX_COALESCE_MS

config.messagePrefix

messagePrefix: "CON" = 'CON'

config.mode

mode: "coalesce" = 'coalesce'

config.modes

modes: string[]

ok

ok: boolean = true

remembered

remembered: any

repo

repo: boolean

session

session: object

session.adopted

adopted: any = s.adopted

session.awaitingDecision

awaitingDecision: any = s.awaitingDecision

session.branch

branch: any = s.branch

session.commits

commits: any = s.commits

session.dirtyAnswer

dirtyAnswer: any = s.dirtyAnswer

session.dueInMs

dueInMs: number

session.lastCommit

lastCommit: any

session.pending

pending: any[]

session.sessionId

sessionId: any = s.sessionId

session.stash

stash: any


recordSave()#

recordSave(root, relPaths, opts?): any

Defined in: ui/server/src/autoCommit.mjs:177

Tell the auto-committer that the Cockpit just wrote a file. This is the single entry point every save route calls; it never throws for a non-git or non-project directory, because a save must succeed whether or not it can be committed.

Parameters#

root

string

project root

relPaths

string | string[]

project-relative path(s) just written

opts?
kind?

"add" | "update" | "delete" = 'update'

Returns#

any

one of: {status:'disabled'|'not-a-repo'}, {status:'manual'|'coalescing', pending}, {status:'needs-decision', dirty}, or {committed:true, commit}.


resetAutoCommit()#

resetAutoCommit(): void

Defined in: ui/server/src/autoCommit.mjs:86

Test seam, and the reset a project switch performs.

Returns#

void


setSessionPlan()#

setSessionPlan(root, __namedParameters?): object

Defined in: ui/server/src/autoCommit.mjs:139

Attach the plan/ticket a session is working from, which names the branch and lets the commit body state what was planned versus not. Optional — a session without one still works.

Parameters#

root

any

__namedParameters?
plan?

any = null

planTitle?

string = ''

Returns#

object

branch

branch: any

config

config: object

config.branchPrefix

branchPrefix: "cockpit" = 'cockpit'

config.branchSuffix

branchSuffix: "" = ''

config.coalesceMs

coalesceMs: 30000 = DEFAULT_COALESCE_MS

config.enabled

enabled: true = true

config.maxCoalesceMs

maxCoalesceMs: number = MAX_COALESCE_MS

config.messagePrefix

messagePrefix: "CON" = 'CON'

config.mode

mode: "coalesce" = 'coalesce'

config.modes

modes: string[]

ok

ok: boolean = true

remembered

remembered: any

repo

repo: boolean

session

session: object

session.adopted

adopted: any = s.adopted

session.awaitingDecision

awaitingDecision: any = s.awaitingDecision

session.branch

branch: any = s.branch

session.commits

commits: any = s.commits

session.dirtyAnswer

dirtyAnswer: any = s.dirtyAnswer

session.dueInMs

dueInMs: number

session.lastCommit

lastCommit: any

session.pending

pending: any[]

session.sessionId

sessionId: any = s.sessionId

session.stash

stash: any


updateCommitConfig()#

updateCommitConfig(patch?): object

Defined in: ui/server/src/autoCommit.mjs:59

Validate and apply a config patch. Throws (never silently ignores) on a bad value.

Parameters#

patch?

Returns#

object

branchPrefix

branchPrefix: "cockpit" = 'cockpit'

branchSuffix

branchSuffix: "" = ''

coalesceMs

coalesceMs: 30000 = DEFAULT_COALESCE_MS

enabled

enabled: true = true

maxCoalesceMs

maxCoalesceMs: number = MAX_COALESCE_MS

messagePrefix

messagePrefix: "CON" = 'CON'

mode

mode: "coalesce" = 'coalesce'

modes

modes: string[]