feat(story-115): hot-reload project.toml agent config without server restart
- Extend `WatcherEvent` to an enum with `WorkItem` and `ConfigChanged` variants so the watcher can distinguish between pipeline-file changes and config changes - Watch `.story_kit/project.toml` at the project root (ignoring worktree copies) and broadcast `WatcherEvent::ConfigChanged` on modification - Forward `agent_config_changed` WebSocket message to connected clients; skip pipeline state refresh for config-only events - Add `is_config_file()` helper with unit tests covering root vs. worktree paths - Accept `configVersion` prop in `AgentPanel` and re-fetch the agent roster whenever it increments - Increment `agentConfigVersion` in `Chat` on receipt of `agent_config_changed` WS event via new `onAgentConfigChanged` handler in `ChatWebSocket` Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -79,7 +79,12 @@ function agentKey(storyId: string, agentName: string): string {
|
||||
return `${storyId}:${agentName}`;
|
||||
}
|
||||
|
||||
export function AgentPanel() {
|
||||
interface AgentPanelProps {
|
||||
/** Increment this to trigger a re-fetch of the agent roster. */
|
||||
configVersion?: number;
|
||||
}
|
||||
|
||||
export function AgentPanel({ configVersion = 0 }: AgentPanelProps) {
|
||||
const { hiddenRosterAgents } = useLozengeFly();
|
||||
const [agents, setAgents] = useState<Record<string, AgentState>>({});
|
||||
const [roster, setRoster] = useState<AgentConfigInfo[]>([]);
|
||||
@@ -90,13 +95,16 @@ export function AgentPanel() {
|
||||
const [editingEditor, setEditingEditor] = useState(false);
|
||||
const cleanupRefs = useRef<Record<string, () => void>>({});
|
||||
|
||||
// Load roster, existing agents, and editor preference on mount
|
||||
// Re-fetch roster whenever configVersion changes (triggered by agent_config_changed WS event).
|
||||
useEffect(() => {
|
||||
agentsApi
|
||||
.getAgentConfig()
|
||||
.then(setRoster)
|
||||
.catch((err) => console.error("Failed to load agent config:", err));
|
||||
}, [configVersion]);
|
||||
|
||||
// Load existing agents and editor preference on mount
|
||||
useEffect(() => {
|
||||
agentsApi
|
||||
.listAgents()
|
||||
.then((agentList) => {
|
||||
|
||||
Reference in New Issue
Block a user