fix(workflow): resolve stale greeting and race condition in startup prompt#846
Conversation
…de startup prompt Clear workflowGreeting state unconditionally when activating a workflow, preventing stale greetings from persisting when switching to a workflow without a startupPrompt. Also gate queued workflow activation on ootbWorkflows being loaded and add it to the useEffect dependency array, preventing a race condition where the greeting could silently be dropped. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests that precisely validate the Critical fix from the PR #780 review: 1. Switching from a workflow WITH startupPrompt to one WITHOUT must clear workflowGreeting to null (not leave stale greeting displayed). 2. Empty-string startupPrompt must also clear the greeting. 3. Failed activation must not set any greeting. All 3 tests FAIL on the pre-patch code (conditional setWorkflowGreeting) and PASS on the fix (unconditional setWorkflowGreeting). Adds vitest + @testing-library/react as devDependencies and a minimal vitest.config.ts, matching the test infrastructure from PR #834. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude Code ReviewSummaryPR #846 delivers two targeted bug fixes to the workflow management system: (1) a stale greeting that persisted when switching from a workflow with a Issues by SeverityBlocker IssuesNone Critical IssuesNone Major Issues1.
Minor Issues1.
2. Redundant
3.
Positive Highlights
Recommendations
🤖 Reviewed by Claude Code using the Amber review system 🔍 View AI decision process (logs available for 90 days) 📋 View memory system files loaded (click to expand)What Amber Loaded for Code ReviewAmber automatically loaded these repository standards from the memory system:
Impact: This review used your repository's specific code quality standards, security patterns, and best practices from the memory system (PRs #359, #360) - not just generic code review guidelines. |
…tup greeting with review fixes Combines the workflow startup greeting feature (PR ambient-code#780) with review feedback fixes (PR ambient-code#846) into a single PR. Includes pre-commit formatting fixes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tup greeting with review fixes Combines the workflow startup greeting feature (PR ambient-code#780) with review feedback fixes (PR ambient-code#846) into a single PR. Includes pre-commit formatting fixes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ode#780 + ambient-code#846) Replaces the server-side workflow greeting round-trip with a client-side approach that provides instant feedback when users select a workflow. Backend: - Add `startupPrompt` and `greeting` fields to OOTBWorkflow struct - Parse both fields from ambient.json in workflow repos Frontend: - Display `greeting` text with typewriter streaming effect below tiles - Add `hidden` option to sendMessage for system-initiated messages - Remove 3-second hardcoded sleep after workflow activation - Remove server-side workflowGreeting state (no LLM round-trip needed) Runner: - Remove server-side greeting trigger logic (no longer needed) - Clean up unused imports (aiohttp, uuid, load_ambient_config) Tests: - Add vitest regression tests for stale greeting and race conditions - Add vitest.config.ts for frontend unit testing Companion: ambient-code/workflows#61 (ambient.json fixes) Supersedes ambient-code#780 and ambient-code#846. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Addresses Critical and Major review feedback from code review of #780:
Critical — Stale greeting persists when switching workflows:
setWorkflowGreetingwas only called whenstartupPromptwas truthy, so switching from a workflow with a greeting to one without left the old greeting displayed. Now clears unconditionally withsetWorkflowGreeting(workflow.startupPrompt || null).Major — Race condition drops greeting silently: The
useEffectthat activates queued workflows referencedootbWorkflowsbut didn't include it in the dependency array. If the OOTB workflows API response hadn't resolved when the session reached "Running" phase,fullWorkflowwould beundefinedandstartupPromptsilently lost. Now gates onootbWorkflows.length > 0and includesootbWorkflowsin the dependency array.Test plan
startupPrompt— greeting appears immediatelystartupPrompt— previous greeting is clearedGenerated with Claude Code