Fix session lifecycle: change initial status from 'ongoing' to 'created'
Update database schema and backend services to properly track session lifecycle: - Sessions now start with 'created' status - Frontend auto-start logic works when status is 'created' - Status transitions to 'ongoing' when session actually starts - Prevents issues with premature round execution 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
d52c0aef92
commit
85319b5ca6
@ -23,7 +23,7 @@ db.exec(`
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
initial_prompt TEXT NOT NULL,
|
||||
document_format TEXT DEFAULT 'md' CHECK(document_format IN ('md', 'txt')),
|
||||
status TEXT CHECK(status IN ('ongoing', 'completed', 'failed')) DEFAULT 'ongoing',
|
||||
status TEXT CHECK(status IN ('created', 'ongoing', 'completed', 'failed')) DEFAULT 'created',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
completed_at TIMESTAMP,
|
||||
final_document TEXT
|
||||
|
||||
@ -55,8 +55,8 @@ router.post('/:id/start', async (req, res) => {
|
||||
return res.status(404).json({ error: 'Session not found' });
|
||||
}
|
||||
|
||||
if (session.status !== 'ongoing') {
|
||||
return res.status(400).json({ error: 'Session is not in ongoing status' });
|
||||
if (session.status !== 'created') {
|
||||
return res.status(400).json({ error: 'Session has already been started or is no longer available' });
|
||||
}
|
||||
|
||||
// Start the session asynchronously
|
||||
|
||||
@ -58,7 +58,7 @@ class CollaborativeOrchestrator {
|
||||
const stmt = db.prepare(
|
||||
'INSERT INTO collaborative_sessions (initial_prompt, document_format, status) VALUES (?, ?, ?)'
|
||||
);
|
||||
const result = stmt.run(initialPrompt, documentFormat, 'ongoing');
|
||||
const result = stmt.run(initialPrompt, documentFormat, 'created');
|
||||
const sessionId = result.lastInsertRowid;
|
||||
|
||||
// Select the agents to use
|
||||
@ -145,6 +145,10 @@ class CollaborativeOrchestrator {
|
||||
throw new Error('Active session not found');
|
||||
}
|
||||
|
||||
// Update session status from 'created' to 'ongoing'
|
||||
const updateStmt = db.prepare('UPDATE collaborative_sessions SET status = ? WHERE id = ?');
|
||||
updateStmt.run('ongoing', sessionId);
|
||||
|
||||
activeSession.started = true;
|
||||
|
||||
// Broadcast session start
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user