Files
vibe-kanban/shared
Louis Knight-Webb f78decada9 Adjust useConversationHistory (vibe-kanban) (#989)
* Done! The changes ensure user messages display immediately when a coding agent execution process is created.

**What changed:**
1. `getActiveAgentProcess()` - now detects created/queued/running processes (not just running)
2. `ensureProcessVisible()` - adds process to state with empty entries and emits immediately
3. `idStatusKey` - tracks status changes so effect runs when process transitions states
4. Active process effect - calls `ensureProcessVisible()` before starting stream

**Result:** User sees their message instantly, then logs populate as they stream in.

* Done! All consistency issues fixed:

**Changes made:**
1.  Moved `emitEntries()` out of `ensureProcessVisible()` to caller - consistent with pattern where helpers mutate but don't emit
2.  Updated both historic loaders to skip `['created', 'queued', 'running']` - prevents race condition with active process path
3.  Renamed `lastRunningProcessId` → `lastActiveProcessId` - accurate naming for what it tracks

The implementation is now internally consistent with the existing codebase patterns.

* Done! The fix ensures streaming only starts when the process is actually `running`, not when it's just `created` or `queued`.

**How it works now:**
1. Process detected (created/queued/running) → user message shows immediately
2. Process transitions to `running` → streaming starts once and logs appear
3. No wasted backoff attempts before endpoint is ready

* ## Analysis Complete

I found the fork's enum attribute: **`#[ts(use_ts_enum)]`**

**Current state:**
- Rust: `ExecutionProcessStatus` enum with values `Running`, `Completed`, `Failed`, `Killed`
- TypeScript: `type ExecutionProcessStatus = "running" | "completed" | "failed" | "killed"`

**Important finding:** The Oracle identified a bug in our recent changes - we're checking for `['created', 'queued', 'running']` but `ExecutionProcessStatus` doesn't have `created` or `queued` values. Those don't exist in the enum.

## Proposed Changes

1. **Add `#[ts(use_ts_enum)]` to Rust enum** in [crates/db/src/models/execution_process.rs](file:///private/var/folders/m1/9q_ct1913z10v6wbnv54j25r0000gn/T/vibe-kanban/worktrees/91b8-adjust-useconver/crates/db/src/models/execution_process.rs#L31-L39)
2. **Regenerate TypeScript types** with `npm run generate-types`
3. **Fix the bug in useConversationHistory.ts** - remove `'created', 'queued'` from the check (they don't exist)
4. **Update frontend to use enum** instead of string literals

**Proceed with this plan?**

* Cleanup script changes for task attempt 91b81dd2-0f76-48f7-a309-683373d87d0d

* Done! All changes complete:

**Changes made:**
1.  Added `#[ts(use_ts_enum)]` to Rust enum
2.  Regenerated TypeScript types - now `export enum ExecutionProcessStatus`
3.  Fixed bug: removed non-existent `'created', 'queued'` from status checks
4.  Updated all frontend code to use `ExecutionProcessStatus.running` instead of string literals

**Result:** TypeScript now has a proper enum with type safety and autocomplete, and the bug with checking for non-existent statuses is fixed.

* remove unnecessary path
2025-10-10 09:57:16 +01:00
..