Compare commits
2 Commits
ec32c6c8a9
...
feat/wire-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9370c04ac5 | ||
| c46306e3ee |
@@ -66,7 +66,7 @@ test('Inbox renders', async ({ app, window }) => {
|
|||||||
|
|
||||||
test('Capture: braindump prompt', async ({ app, window }) => {
|
test('Capture: braindump prompt', async ({ app, window }) => {
|
||||||
await app.nav('Capture').click()
|
await app.nav('Capture').click()
|
||||||
await expect(window.getByText("Tell me what you're planning")).toBeVisible()
|
await expect(window.getByText('Do tell me what you are planning')).toBeVisible()
|
||||||
await app.screenshot('capture')
|
await app.screenshot('capture')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
"tailwindcss": "^3.4.17",
|
"tailwindcss": "^3.4.17",
|
||||||
"tsx": "^4",
|
"tsx": "^4",
|
||||||
"typescript": "^5.7.3",
|
"typescript": "^5.7.3",
|
||||||
"vite": "^6.1.0"
|
"vite": "^6.1.0",
|
||||||
|
"vitest": "^3.0.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,10 @@ import {
|
|||||||
applySchemaLabels,
|
applySchemaLabels,
|
||||||
createGiteaClient,
|
createGiteaClient,
|
||||||
discoverRepos,
|
discoverRepos,
|
||||||
|
enqueueWrite,
|
||||||
ensurePmStateRepo,
|
ensurePmStateRepo,
|
||||||
GiteaApiError,
|
GiteaApiError,
|
||||||
|
replayQueue,
|
||||||
type DirectiveEntry,
|
type DirectiveEntry,
|
||||||
type GiteaClient,
|
type GiteaClient,
|
||||||
type GiteaConfig,
|
type GiteaConfig,
|
||||||
@@ -46,6 +48,7 @@ import {
|
|||||||
const isDemo = (): boolean => process.env.COMMITEA_E2E === '1'
|
const isDemo = (): boolean => process.env.COMMITEA_E2E === '1'
|
||||||
|
|
||||||
import { type AppConfig, clearConfig, loadConfig, publicConfig, saveConfig } from './config-store.js'
|
import { type AppConfig, clearConfig, loadConfig, publicConfig, saveConfig } from './config-store.js'
|
||||||
|
import { loadQueue, saveQueue } from './queue-store.js'
|
||||||
import { loadSnapshot, saveSnapshot } from './snapshot-store.js'
|
import { loadSnapshot, saveSnapshot } from './snapshot-store.js'
|
||||||
|
|
||||||
/** Walk up from cwd looking for a .env.local with a GITEA_TOKEN (dev convenience). */
|
/** Walk up from cwd looking for a .env.local with a GITEA_TOKEN (dev convenience). */
|
||||||
@@ -241,6 +244,59 @@ async function resolveLabelIds(client: GiteaClient, names: string[]): Promise<nu
|
|||||||
return names.map((n) => byName.get(n)).filter((id): id is number => id != null)
|
return names.map((n) => byName.get(n)).filter((id): id is number => id != null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The result of a live write — a label swap returns its plan, a field write the fresh issue. */
|
||||||
|
type LiveApplyResult = { ok: true; plan?: ReturnType<typeof planIssueChange>; issue: Awaited<ReturnType<GiteaClient['getIssue']>> }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply one approved change against gitea (the guarded write path, used both
|
||||||
|
* online and when draining the offline queue). Label swaps (est/p) read → plan →
|
||||||
|
* set; field writes (assign, milestone) write directly and return the fresh
|
||||||
|
* issue. A replay is idempotent — a change already reflected server-side no-ops
|
||||||
|
* (label plan.noop; assignee/milestone re-set to the same value). Throws on a
|
||||||
|
* network failure (queued upstream) or a GiteaApiError (surfaced, never queued).
|
||||||
|
*/
|
||||||
|
async function applyChangeLive(client: GiteaClient, change: IssueChange): Promise<LiveApplyResult> {
|
||||||
|
if (isLabelChange(change)) {
|
||||||
|
const current = await client.getIssue(change.issue)
|
||||||
|
const plan = planIssueChange(current.labels, change)
|
||||||
|
if (plan.noop) return { ok: true, plan, issue: current }
|
||||||
|
const ids = await resolveLabelIds(client, plan.labels)
|
||||||
|
await client.setIssueLabels(change.issue, ids)
|
||||||
|
const issue = await client.getIssue(change.issue)
|
||||||
|
return { ok: true, plan, issue }
|
||||||
|
}
|
||||||
|
const issue =
|
||||||
|
change.kind === 'assign'
|
||||||
|
? await client.setIssueAssignees(change.issue, change.assignee ? [change.assignee] : [])
|
||||||
|
: await client.setIssueMilestone(change.issue, change.milestone)
|
||||||
|
return { ok: true, issue }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Queue a write made while offline, coalescing by (issue, axis). Returns the new pending count. */
|
||||||
|
function queueOffline(change: IssueChange): number {
|
||||||
|
const next = enqueueWrite(loadQueue(), change, new Date().toISOString())
|
||||||
|
saveQueue(next)
|
||||||
|
return next.length
|
||||||
|
}
|
||||||
|
|
||||||
|
/** How many writes are waiting to replay (shown as a queued badge). */
|
||||||
|
function pendingCount(): number {
|
||||||
|
return loadQueue().length
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replay the offline queue against gitea once we know it's reachable. Drained
|
||||||
|
* writes are removed; any that still fail stay queued. Returns how many drained
|
||||||
|
* (so the caller can invalidate + re-read the snapshot) and what remains.
|
||||||
|
*/
|
||||||
|
async function drainQueue(client: GiteaClient): Promise<{ drainedCount: number; remainingCount: number }> {
|
||||||
|
const queue = loadQueue()
|
||||||
|
if (queue.length === 0) return { drainedCount: 0, remainingCount: 0 }
|
||||||
|
const { drained, remaining } = await replayQueue(queue, (change) => applyChangeLive(client, change))
|
||||||
|
saveQueue(remaining)
|
||||||
|
return { drainedCount: drained.length, remainingCount: remaining.length }
|
||||||
|
}
|
||||||
|
|
||||||
export function registerGiteaIpc(): void {
|
export function registerGiteaIpc(): void {
|
||||||
ipcMain.handle('gitea:status', () => {
|
ipcMain.handle('gitea:status', () => {
|
||||||
const cfg = resolveConfig()
|
const cfg = resolveConfig()
|
||||||
@@ -253,24 +309,33 @@ export function registerGiteaIpc(): void {
|
|||||||
|
|
||||||
// Instant boot: the last persisted snapshot, shown before the fresh reconcile lands.
|
// Instant boot: the last persisted snapshot, shown before the fresh reconcile lands.
|
||||||
ipcMain.handle('gitea:boot', () => {
|
ipcMain.handle('gitea:boot', () => {
|
||||||
if (isDemo()) return { configured: true, cached: true, ...DEMO_SNAPSHOT, savedAt: DEMO_TODAY }
|
if (isDemo()) return { configured: true, cached: true, pending: 0, ...DEMO_SNAPSHOT, savedAt: DEMO_TODAY }
|
||||||
if (!getGiteaClient()) return { configured: false }
|
if (!getGiteaClient()) return { configured: false }
|
||||||
const persisted = bootSnapshot()
|
const persisted = bootSnapshot()
|
||||||
return persisted ? { configured: true, cached: true, ...persisted } : { configured: true, cached: false }
|
return persisted
|
||||||
|
? { configured: true, cached: true, pending: pendingCount(), ...persisted }
|
||||||
|
: { configured: true, cached: false }
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.handle('gitea:reconcile', async () => {
|
ipcMain.handle('gitea:reconcile', async () => {
|
||||||
if (isDemo()) return { configured: true, stale: false, ...DEMO_SNAPSHOT }
|
if (isDemo()) return { configured: true, stale: false, pending: 0, ...DEMO_SNAPSHOT }
|
||||||
const client = getGiteaClient()
|
const client = getGiteaClient()
|
||||||
if (!client) return { configured: false, issues: [], milestones: [], deps: [], timelines: {} }
|
if (!client) return { configured: false, issues: [], milestones: [], deps: [], timelines: {} }
|
||||||
try {
|
try {
|
||||||
// explicit UI sync — force fresh, and warm the cache for agent tool calls
|
// explicit UI sync — force fresh, and warm the cache for agent tool calls
|
||||||
const snap = await getSnapshot(client, { maxAgeMs: 0 })
|
let snap = await getSnapshot(client, { maxAgeMs: 0 })
|
||||||
return { configured: true, stale: false, ...snap }
|
// A successful reconcile proves gitea is reachable: drain any writes queued
|
||||||
|
// while offline. If any drained, re-read so the board reflects the replays.
|
||||||
|
const { drainedCount, remainingCount } = await drainQueue(client)
|
||||||
|
if (drainedCount > 0) {
|
||||||
|
invalidateSnapshot()
|
||||||
|
snap = await getSnapshot(client, { maxAgeMs: 0 })
|
||||||
|
}
|
||||||
|
return { configured: true, stale: false, pending: remainingCount, ...snap }
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// offline / gitea down — serve the last persisted snapshot rather than error out
|
// offline / gitea down — serve the last persisted snapshot rather than error out
|
||||||
const persisted = bootSnapshot()
|
const persisted = bootSnapshot()
|
||||||
if (persisted) return { configured: true, stale: true, ...persisted }
|
if (persisted) return { configured: true, stale: true, pending: pendingCount(), ...persisted }
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -288,25 +353,18 @@ export function registerGiteaIpc(): void {
|
|||||||
ipcMain.handle('gitea:applyChange', async (_event, change: IssueChange) => {
|
ipcMain.handle('gitea:applyChange', async (_event, change: IssueChange) => {
|
||||||
const client = getGiteaClient()
|
const client = getGiteaClient()
|
||||||
if (!client) return { ok: false as const, reason: 'unconfigured' as const }
|
if (!client) return { ok: false as const, reason: 'unconfigured' as const }
|
||||||
|
try {
|
||||||
if (isLabelChange(change)) {
|
const result = await applyChangeLive(client, change)
|
||||||
const current = await client.getIssue(change.issue)
|
invalidateSnapshot() // the board + forecast must reflect the write
|
||||||
const plan = planIssueChange(current.labels, change)
|
return result
|
||||||
if (plan.noop) return { ok: true as const, plan, issue: current }
|
} catch (e) {
|
||||||
const ids = await resolveLabelIds(client, plan.labels)
|
// A GiteaApiError is a genuine rejection (bad label, gone issue) — surface
|
||||||
await client.setIssueLabels(change.issue, ids)
|
// it; queueing would only replay a doomed write forever. Anything else is
|
||||||
const issue = await client.getIssue(change.issue)
|
// unreachability: queue the intent so it replays on reconnect (#33).
|
||||||
invalidateSnapshot()
|
if (e instanceof GiteaApiError) throw e
|
||||||
return { ok: true as const, plan, issue }
|
const pending = queueOffline(change)
|
||||||
|
return { ok: true as const, queued: true as const, pending }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Field writes — the client returns the updated issue.
|
|
||||||
const issue =
|
|
||||||
change.kind === 'assign'
|
|
||||||
? await client.setIssueAssignees(change.issue, change.assignee ? [change.assignee] : [])
|
|
||||||
: await client.setIssueMilestone(change.issue, change.milestone)
|
|
||||||
invalidateSnapshot()
|
|
||||||
return { ok: true as const, issue }
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// capture_work filing: open each approved issue with its est/* + p/* labels.
|
// capture_work filing: open each approved issue with its est/* + p/* labels.
|
||||||
|
|||||||
87
apps/desktop/src/main/queue-store.test.ts
Normal file
87
apps/desktop/src/main/queue-store.test.ts
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/**
|
||||||
|
* Durable offline write-queue store (#33). The invariant mirrors the snapshot
|
||||||
|
* store's purity: the queue file is a convenience mirror, and a missing or corrupt
|
||||||
|
* file must degrade to "empty queue", never a crash — losing a queued write is
|
||||||
|
* bad, but crashing the whole write path is worse. These tests also exercise the
|
||||||
|
* store together with core's coalescing/replay so the round-trip an offline edit
|
||||||
|
* takes (enqueue → persist → reload → replay → drain) is covered end to end.
|
||||||
|
*/
|
||||||
|
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
||||||
|
import { tmpdir } from 'node:os'
|
||||||
|
import { join } from 'node:path'
|
||||||
|
|
||||||
|
import { enqueueWrite, replayQueue, type IssueChange } from '@commitea/core'
|
||||||
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||||
|
|
||||||
|
// electron can't be imported outside the Electron runtime; the store only needs
|
||||||
|
// app.getPath for its default path, which every test overrides with an injected path.
|
||||||
|
vi.mock('electron', () => ({ app: { getPath: () => tmpdir() } }))
|
||||||
|
|
||||||
|
import { loadQueue, saveQueue } from './queue-store.js'
|
||||||
|
|
||||||
|
const estChange = (issue: number, estimate = 'est/5d'): IssueChange =>
|
||||||
|
({ kind: 'reestimate', issue, estimate }) as IssueChange
|
||||||
|
const assignChange = (issue: number, assignee: string | null): IssueChange =>
|
||||||
|
({ kind: 'assign', issue, assignee }) as IssueChange
|
||||||
|
|
||||||
|
describe('queue-store (#33)', () => {
|
||||||
|
let dir: string | null = null
|
||||||
|
const path = () => {
|
||||||
|
if (!dir) dir = mkdtempSync(join(tmpdir(), 'commitea-queue-'))
|
||||||
|
return join(dir, 'commitea-write-queue.json')
|
||||||
|
}
|
||||||
|
afterEach(() => {
|
||||||
|
if (dir) rmSync(dir, { recursive: true, force: true })
|
||||||
|
dir = null
|
||||||
|
})
|
||||||
|
|
||||||
|
it('round-trips a persisted queue', () => {
|
||||||
|
const p = path()
|
||||||
|
const queue = enqueueWrite([], estChange(1), '2026-07-11T00:00:00Z')
|
||||||
|
saveQueue(queue, p)
|
||||||
|
expect(loadQueue(p)).toEqual(queue)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('a missing file degrades to an empty queue (never a crash)', () => {
|
||||||
|
// nothing written yet — load must return [] so the write path stays alive
|
||||||
|
expect(loadQueue(path())).toEqual([])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('a corrupt or wrong-shape file is treated as an empty queue', () => {
|
||||||
|
const p = path()
|
||||||
|
writeFileSync(p, '{ not json', 'utf8')
|
||||||
|
expect(loadQueue(p)).toEqual([])
|
||||||
|
// valid JSON but not an array (drift) is also rejected
|
||||||
|
writeFileSync(p, JSON.stringify({ nope: true }), 'utf8')
|
||||||
|
expect(loadQueue(p)).toEqual([])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('persisted queue coalesces by (issue, axis) across saves — the later intent wins', () => {
|
||||||
|
const p = path()
|
||||||
|
// two estimates for the same issue, queued while offline: only the last survives
|
||||||
|
saveQueue(enqueueWrite(loadQueue(p), estChange(1, 'est/2d'), '2026-07-11T00:00:00Z'), p)
|
||||||
|
saveQueue(enqueueWrite(loadQueue(p), estChange(1, 'est/8d'), '2026-07-11T00:01:00Z'), p)
|
||||||
|
// a different axis on the same issue coexists
|
||||||
|
saveQueue(enqueueWrite(loadQueue(p), assignChange(1, 'ana'), '2026-07-11T00:02:00Z'), p)
|
||||||
|
|
||||||
|
const queue = loadQueue(p)
|
||||||
|
expect(queue).toHaveLength(2)
|
||||||
|
expect(queue.map((w) => w.change)).toEqual([estChange(1, 'est/8d'), assignChange(1, 'ana')])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('reloads and replays the queue, draining what applies and keeping what fails', async () => {
|
||||||
|
const p = path()
|
||||||
|
saveQueue(enqueueWrite(loadQueue(p), estChange(1), '2026-07-11T00:00:00Z'), p)
|
||||||
|
saveQueue(enqueueWrite(loadQueue(p), assignChange(2, 'ana'), '2026-07-11T00:01:00Z'), p)
|
||||||
|
|
||||||
|
// Simulate reconnect: replay through an apply that fails only for issue #2
|
||||||
|
// (still unreachable / rejected). The successful write drains; the other stays.
|
||||||
|
const { drained, remaining } = await replayQueue(loadQueue(p), async (c) =>
|
||||||
|
c.issue === 2 ? { ok: false } : { ok: true },
|
||||||
|
)
|
||||||
|
saveQueue(remaining, p)
|
||||||
|
|
||||||
|
expect(drained.map((w) => w.change.issue)).toEqual([1])
|
||||||
|
expect(loadQueue(p).map((w) => w.change.issue)).toEqual([2])
|
||||||
|
})
|
||||||
|
})
|
||||||
39
apps/desktop/src/main/queue-store.ts
Normal file
39
apps/desktop/src/main/queue-store.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* Durable write-queue store — persists propose-approved writes made while gitea
|
||||||
|
* is unreachable, so they survive a restart and replay on reconnect (#33). A
|
||||||
|
* plain JSON array of QueuedWrite, mirroring the snapshot store: the queue is
|
||||||
|
* tiny (one entry per (issue, axis)), so a file is plenty. Never throws — a
|
||||||
|
* missing or corrupt file degrades to "empty queue", never a crash.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { readFileSync, writeFileSync } from 'node:fs'
|
||||||
|
import { join } from 'node:path'
|
||||||
|
|
||||||
|
import type { QueuedWrite } from '@commitea/core'
|
||||||
|
import { app } from 'electron'
|
||||||
|
|
||||||
|
function queuePath(): string {
|
||||||
|
return join(app.getPath('userData'), 'commitea-write-queue.json')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the persisted write-queue, or [] if absent/corrupt. `path` is injectable
|
||||||
|
* for tests; production uses the userData file.
|
||||||
|
*/
|
||||||
|
export function loadQueue(path: string = queuePath()): QueuedWrite[] {
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(readFileSync(path, 'utf8')) as unknown
|
||||||
|
return Array.isArray(parsed) ? (parsed as QueuedWrite[]) : []
|
||||||
|
} catch {
|
||||||
|
return [] // missing file, bad JSON, or drift — treat as empty
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Persist the write-queue. Best-effort — a write failure never breaks the caller. */
|
||||||
|
export function saveQueue(queue: readonly QueuedWrite[], path: string = queuePath()): void {
|
||||||
|
try {
|
||||||
|
writeFileSync(path, JSON.stringify(queue), 'utf8')
|
||||||
|
} catch {
|
||||||
|
// disk full / permissions — the in-memory result of this call still holds
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -74,6 +74,7 @@ export function AppShell() {
|
|||||||
// cache) only when gitea is unreachable. No manual toggle — this is the truth.
|
// cache) only when gitea is unreachable. No manual toggle — this is the truth.
|
||||||
const offline = backlog.status === 'error' || (backlog.status === 'ready' && backlog.stale)
|
const offline = backlog.status === 'error' || (backlog.status === 'ready' && backlog.stale)
|
||||||
const staleSince = backlog.status === 'ready' ? backlog.savedAt : undefined
|
const staleSince = backlog.status === 'ready' ? backlog.savedAt : undefined
|
||||||
|
const pending = backlog.status === 'ready' ? backlog.pending : 0
|
||||||
const capacityMembers = useCapacity()
|
const capacityMembers = useCapacity()
|
||||||
const workers = capacityWorkers(capacityMembers)
|
const workers = capacityWorkers(capacityMembers)
|
||||||
const boardColumns =
|
const boardColumns =
|
||||||
@@ -182,10 +183,12 @@ export function AppShell() {
|
|||||||
// issue immediately, and re-reconcile so the board + forecast catch up.
|
// issue immediately, and re-reconcile so the board + forecast catch up.
|
||||||
const applyChange = async (change: IssueChange) => {
|
const applyChange = async (change: IssueChange) => {
|
||||||
const res = await window.commitea.gitea.applyChange(change)
|
const res = await window.commitea.gitea.applyChange(change)
|
||||||
if (res.ok) {
|
if (res.ok && !res.queued) {
|
||||||
setIssue((cur) => (cur && cur.id === res.issue.number ? { ...cur, labels: res.issue.labels } : cur))
|
setIssue((cur) => (cur && cur.id === res.issue.number ? { ...cur, labels: res.issue.labels } : cur))
|
||||||
refetchBacklog()
|
|
||||||
}
|
}
|
||||||
|
// Re-sync either way: an applied write to refresh the board, a queued one to
|
||||||
|
// pick up the new pending count (the reconcile reports it while offline).
|
||||||
|
if (res.ok) refetchBacklog()
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,7 +448,7 @@ export function AppShell() {
|
|||||||
gap: 14,
|
gap: 14,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{offline ? <OfflineBanner /> : null}
|
{offline ? <OfflineBanner queued={pending} /> : null}
|
||||||
{renderScreen()}
|
{renderScreen()}
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -55,10 +55,11 @@ export function EmptyState({ icon, title, line, action, onAction, compact }: Emp
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface OfflineBannerProps {
|
export interface OfflineBannerProps {
|
||||||
retryIn?: string
|
/** Writes approved while offline, held for replay on reconnect. */
|
||||||
|
queued?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export function OfflineBanner({ retryIn }: OfflineBannerProps) {
|
export function OfflineBanner({ queued = 0 }: OfflineBannerProps) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
@@ -75,10 +76,12 @@ export function OfflineBanner({ retryIn }: OfflineBannerProps) {
|
|||||||
<Icon name="triangle-alert" size={15} />
|
<Icon name="triangle-alert" size={15} />
|
||||||
</span>
|
</span>
|
||||||
<span style={{ font: 'var(--text-small)', color: 'var(--ink-1)', flex: 1 }}>
|
<span style={{ font: 'var(--text-small)', color: 'var(--ink-1)', flex: 1 }}>
|
||||||
Gitea isn’t answering. I’ll keep trying and say nothing more about it.
|
{queued > 0
|
||||||
|
? `Gitea isn’t answering. I’m holding ${queued} ${queued === 1 ? 'change' : 'changes'} and shall apply ${queued === 1 ? 'it' : 'them'} on reconnect.`
|
||||||
|
: 'Gitea isn’t answering. I’ll keep trying and say nothing more about it.'}
|
||||||
</span>
|
</span>
|
||||||
<span style={{ font: '400 11.5px var(--font-mono)', color: 'var(--ink-2)', whiteSpace: 'nowrap' }}>
|
<span style={{ font: '400 11.5px var(--font-mono)', color: 'var(--ink-2)', whiteSpace: 'nowrap' }}>
|
||||||
retry in {retryIn || '0:12'} · reads from cache
|
{queued > 0 ? `${queued} queued · reads from cache` : 'reads from cache'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
6
apps/desktop/src/renderer/src/global.d.ts
vendored
6
apps/desktop/src/renderer/src/global.d.ts
vendored
@@ -17,8 +17,10 @@ import type {
|
|||||||
/** The result of a write through the bridge. */
|
/** The result of a write through the bridge. */
|
||||||
export type ApplyChangeResult =
|
export type ApplyChangeResult =
|
||||||
| { ok: false; reason: 'unconfigured' }
|
| { ok: false; reason: 'unconfigured' }
|
||||||
|
// Offline: the write was queued for replay on reconnect. `pending` is the queue depth.
|
||||||
|
| { ok: true; queued: true; pending: number }
|
||||||
// `plan` is present for label swaps (est/p); absent for field writes (assign, milestone).
|
// `plan` is present for label swaps (est/p); absent for field writes (assign, milestone).
|
||||||
| { ok: true; plan?: LabelPlan; issue: GiteaIssue }
|
| { ok: true; queued?: false; plan?: LabelPlan; issue: GiteaIssue }
|
||||||
|
|
||||||
/** The result of filing captured issues. */
|
/** The result of filing captured issues. */
|
||||||
export type CreateIssuesResult =
|
export type CreateIssuesResult =
|
||||||
@@ -42,6 +44,8 @@ export interface SnapshotPayload {
|
|||||||
stale?: boolean
|
stale?: boolean
|
||||||
/** ISO time the persisted snapshot was reconciled (present on cached reads). */
|
/** ISO time the persisted snapshot was reconciled (present on cached reads). */
|
||||||
savedAt?: string
|
savedAt?: string
|
||||||
|
/** Writes queued while offline, awaiting replay on reconnect. */
|
||||||
|
pending?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Boot payload — the persisted snapshot, or a marker that there's none yet. */
|
/** Boot payload — the persisted snapshot, or a marker that there's none yet. */
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ export type BacklogState =
|
|||||||
stale: boolean
|
stale: boolean
|
||||||
/** ISO time the shown snapshot was reconciled, when stale. */
|
/** ISO time the shown snapshot was reconciled, when stale. */
|
||||||
savedAt?: string
|
savedAt?: string
|
||||||
|
/** Writes queued while offline, awaiting replay on reconnect. */
|
||||||
|
pending: number
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,6 +52,7 @@ export function useBacklog(): [BacklogState, () => void] {
|
|||||||
timelines: b.timelines,
|
timelines: b.timelines,
|
||||||
stale: true,
|
stale: true,
|
||||||
savedAt: b.savedAt,
|
savedAt: b.savedAt,
|
||||||
|
pending: b.pending ?? 0,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -70,6 +73,7 @@ export function useBacklog(): [BacklogState, () => void] {
|
|||||||
timelines: r.timelines,
|
timelines: r.timelines,
|
||||||
stale: r.stale ?? false,
|
stale: r.stale ?? false,
|
||||||
savedAt: r.savedAt,
|
savedAt: r.savedAt,
|
||||||
|
pending: r.pending ?? 0,
|
||||||
}
|
}
|
||||||
: { status: 'unconfigured' },
|
: { status: 'unconfigured' },
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -141,9 +141,11 @@ export function useChat(onApplyChange?: (change: IssueChange) => Promise<{ ok: b
|
|||||||
...c,
|
...c,
|
||||||
{
|
{
|
||||||
from: 'agent',
|
from: 'agent',
|
||||||
text: res.ok
|
text: !res.ok
|
||||||
? `Very good. #${p.change.issue}: ${p.summary}. The plan has been re-run.`
|
? `Regrettably that did not take; #${p.change.issue} remains unchanged.`
|
||||||
: `Regrettably that did not take; #${p.change.issue} remains unchanged.`,
|
: 'queued' in res && res.queued
|
||||||
|
? `We are offline, so I have set #${p.change.issue}: ${p.summary} aside; I shall apply it the moment gitea is within reach.`
|
||||||
|
: `Very good. #${p.change.issue}: ${p.summary}. The plan has been re-run.`,
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user