fix(run): push initial projection so TUI shows active session

air run now pushes an initial SessionProjection snapshot
to the ProjectionClient before starting the TUI, so the
TUI shows the active session instead of "No session".

Also keep the process alive with an indefinite promise
instead of exiting immediately after TUI start.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
AirCoding
2026-06-05 13:50:34 +08:00
parent 4e91909a88
commit bc58bd6840

View File

@@ -1,5 +1,5 @@
/**
* RunCommand - Run the AirCoding project (spawns TUI)
* RunCommand - Start a session (spawns TUI)
* DD §17. Routes side effects through RuntimeApp.
*
* @module packages/cli/src/commands/run
@@ -11,11 +11,28 @@ import { TuiApp } from '@aircoding/tui'
export async function runCommand(project_path?: string): Promise<void> {
const config = loadConfig(project_path)
console.log(`Starting AirCoding for ${config.project_root || process.cwd()}`)
const project_root = config.project_root || process.cwd()
console.log(`Starting AirCoding for ${project_root}`)
const runtime = await createRuntime(config)
await runtime.start()
// Push initial projection snapshot so TUI shows the session
runtime.projection_client.receive_snapshot({
session_id: 'current',
project_id: '',
status: 'running',
title: project_root.split('/').pop() || 'AirCoding',
tasks: [],
agents: [],
tool_runs: [],
command_runs: [],
artifacts: [],
permission_prompts: [],
blockers: [],
updated_at: new Date().toISOString()
})
// Wire TUI to runtime's ProjectionClient (B15 fix)
const tui = new TuiApp({ client: runtime.projection_client })
await tui.start()
@@ -27,4 +44,8 @@ export async function runCommand(project_path?: string): Promise<void> {
await runtime.shutdown()
process.exit(0)
})
// Keep process alive for TUI interaction
console.log(`\nSession active. Press 'q' to quit, 'h' for help.`)
await new Promise(() => {}) // Wait forever until SIGINT
}