Add better messages for intent processing and update in progress
This commit is contained in:
@@ -43,7 +43,11 @@ export function broadcastReload(reason: string, data?: Record<string, unknown>):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdateStatusPhase = 'request_received' | 'update_started' | 'update_done';
|
export type UpdateStatusPhase =
|
||||||
|
| 'request_received'
|
||||||
|
| 'intent_processing'
|
||||||
|
| 'updating'
|
||||||
|
| 'update_done';
|
||||||
|
|
||||||
export function broadcastUpdateStatus(phase: UpdateStatusPhase, data?: Record<string, unknown>): void {
|
export function broadcastUpdateStatus(phase: UpdateStatusPhase, data?: Record<string, unknown>): void {
|
||||||
if (!wss) return;
|
if (!wss) return;
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ export function createEditQueue(): EditQueue {
|
|||||||
while (jobs.length > 0 && !shuttingDown) {
|
while (jobs.length > 0 && !shuttingDown) {
|
||||||
const job = jobs.shift()!;
|
const job = jobs.shift()!;
|
||||||
logger.info({ event: 'job.started', kind: job.kind, id: job.id }, 'Processing job');
|
logger.info({ event: 'job.started', kind: job.kind, id: job.id }, 'Processing job');
|
||||||
broadcastUpdateStatus('update_started', { jobKind: job.kind, jobId: job.id });
|
|
||||||
try {
|
try {
|
||||||
await processor!(job);
|
await processor!(job);
|
||||||
logger.info({ event: 'job.completed', kind: job.kind, id: job.id }, 'Job completed');
|
logger.info({ event: 'job.completed', kind: job.kind, id: job.id }, 'Job completed');
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { buildSectionManifest, type ManifestEntry } from './manifest.js';
|
|||||||
import { sendSms } from '../sms/reply.js';
|
import { sendSms } from '../sms/reply.js';
|
||||||
import { SMS_TEMPLATES } from '../sms/templates.js';
|
import { SMS_TEMPLATES } from '../sms/templates.js';
|
||||||
import { logger } from '../logger.js';
|
import { logger } from '../logger.js';
|
||||||
|
import { broadcastUpdateStatus } from '../live-reload.js';
|
||||||
|
|
||||||
const REPO_ROOT = process.env.REPO_ROOT || '.';
|
const REPO_ROOT = process.env.REPO_ROOT || '.';
|
||||||
const AUTO_APPLY = process.env.AUTO_APPLY_EDITS === 'true';
|
const AUTO_APPLY = process.env.AUTO_APPLY_EDITS === 'true';
|
||||||
@@ -55,6 +56,7 @@ async function handlePropose(job: Extract<EditJobPayload, { kind: 'propose' }>)
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Step 0: Classify message intent (edit, info, or help)
|
// Step 0: Classify message intent (edit, info, or help)
|
||||||
|
broadcastUpdateStatus('intent_processing', { jobKind: job.kind, jobId: job.id, source: job.source });
|
||||||
const classification = await classifyMessageIntent({ userMessage: job.message });
|
const classification = await classifyMessageIntent({ userMessage: job.message });
|
||||||
log.info({ event: 'classification.result', intent: classification.intent, reason: classification.reason }, 'Message classified');
|
log.info({ event: 'classification.result', intent: classification.intent, reason: classification.reason }, 'Message classified');
|
||||||
|
|
||||||
@@ -77,6 +79,7 @@ async function handlePropose(job: Extract<EditJobPayload, { kind: 'propose' }>)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ── EDIT intent: proceed with existing edit flow ──
|
// ── EDIT intent: proceed with existing edit flow ──
|
||||||
|
broadcastUpdateStatus('updating', { jobKind: job.kind, jobId: job.id, source: job.source });
|
||||||
|
|
||||||
// Step 1: Route — determine which file the edit targets
|
// Step 1: Route — determine which file the edit targets
|
||||||
let repoRelativePath = job.repo_relative_path;
|
let repoRelativePath = job.repo_relative_path;
|
||||||
@@ -190,6 +193,7 @@ async function handlePropose(job: Extract<EditJobPayload, { kind: 'propose' }>)
|
|||||||
async function handleApply(job: Extract<EditJobPayload, { kind: 'apply' }>) {
|
async function handleApply(job: Extract<EditJobPayload, { kind: 'apply' }>) {
|
||||||
const log = logger.child({ jobId: job.id, kind: 'apply', proposalId: job.proposal_id });
|
const log = logger.child({ jobId: job.id, kind: 'apply', proposalId: job.proposal_id });
|
||||||
|
|
||||||
|
broadcastUpdateStatus('updating', { jobKind: job.kind, jobId: job.id, source: job.source, proposalId: job.proposal_id });
|
||||||
const proposal = getProposal(job.proposal_id);
|
const proposal = getProposal(job.proposal_id);
|
||||||
|
|
||||||
if (!proposal) {
|
if (!proposal) {
|
||||||
|
|||||||
@@ -191,7 +191,8 @@ const wsUrl = (process.env.PUBLIC_LIVE_RELOAD_WS_URL ?? import.meta.env.PUBLIC_L
|
|||||||
|
|
||||||
if (msg.type === 'update_status') {
|
if (msg.type === 'update_status') {
|
||||||
if (msg.phase === 'request_received') setBanner(true, 'Processing update request');
|
if (msg.phase === 'request_received') setBanner(true, 'Processing update request');
|
||||||
else if (msg.phase === 'update_started') setBanner(true, 'Updating website');
|
else if (msg.phase === 'intent_processing') setBanner(true, 'Processing update request');
|
||||||
|
else if (msg.phase === 'updating') setBanner(true, 'Updating website');
|
||||||
else if (msg.phase === 'update_done') setBanner(false);
|
else if (msg.phase === 'update_done') setBanner(false);
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user