-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Summary
Add a new isToolUpdatingRepl state (separate from isAiUpdating) that tracks specifically when the updateRepl tool is executing. This state should:
- Show the "AI updating" overlay on the REPL
- Block user edits to the editor during the update
Background
Currently the "AI updating" overlay shows based on isAiUpdating, which is set whenever the AI is generating any response (thinking, text, any tool call). The overlay should only appear when the updateRepl tool is actively running.
Note: We're creating a new state rather than modifying isAiUpdating because other parts of the code may depend on isAiUpdating for different purposes.
Current Behavior
isAiUpdatingis set based on Tambo'sgenerationStageinsrc/app/chat/page.tsx(lines 186-191)- The overlay shows whenever AI is doing anything
Desired Behavior
- New
isToolUpdatingReplstate that is only true when theupdateRepltool is executing - Overlay uses
isToolUpdatingReplinstead ofisAiUpdating - Editor edits are blocked while
isToolUpdatingReplis true isAiUpdatingcontinues to work as before (other features may depend on it)
Technical Implementation
1. Add isToolUpdatingRepl to StrudelService (src/strudel/lib/service.ts)
// Add private state
private _isToolUpdatingRepl = false;
private toolUpdatingReplCallbacks: ((isUpdating: boolean) => void)[] = [];
// Add getter
get isToolUpdatingRepl(): boolean {
return this._isToolUpdatingRepl;
}
// Add setter with notifications
setToolUpdatingRepl(value: boolean): void {
this._isToolUpdatingRepl = value;
this.toolUpdatingReplCallbacks.forEach(cb => cb(value));
}
// Add subscription method
onToolUpdatingReplChange(callback: (isUpdating: boolean) => void): () => void {
this.toolUpdatingReplCallbacks.push(callback);
return () => {
this.toolUpdatingReplCallbacks = this.toolUpdatingReplCallbacks.filter(cb => cb !== callback);
};
}2. Update validateAndUpdateRepl tool (src/strudel/tools/validateAndUpdateRepl.ts)
export const validateAndUpdateRepl: TamboTool = {
// ... existing config
tool: async (code: string) => {
const service = StrudelService.instance();
service.setToolUpdatingRepl(true);
try {
await service.init();
// ... existing validation logic
const result = await service.updateAndPlay(code, { source: "ai" });
return result;
} finally {
service.setToolUpdatingRepl(false);
}
},
// ...
};3. Update StrudelProvider (src/strudel/context/strudel-provider.tsx)
- Add
isToolUpdatingReplto context type - Add useState for
isToolUpdatingRepl - Subscribe to service's
onToolUpdatingReplChangein useEffect - Expose in provider value
4. Update overlay component to use new state
- The component that renders the overlay should use
isToolUpdatingReplinstead ofisAiUpdating
5. Block editor edits when updating
- When
isToolUpdatingReplis true, the editor should be read-only or have edits blocked - This prevents race conditions where user edits conflict with AI updates
Relevant Files
src/strudel/lib/service.ts- Add new state and methodssrc/strudel/tools/validateAndUpdateRepl.ts- Set/clear state around tool executionsrc/strudel/context/strudel-provider.tsx- Expose new state via context- Component that renders the overlay (needs to be identified and updated)
- Editor component - needs to respect
isToolUpdatingReplto block edits
Acceptance Criteria
- New
isToolUpdatingReplstate added toStrudelService -
validateAndUpdateRepltool sets state to true at start, false when complete - State is exposed through
StrudelContext - Overlay uses
isToolUpdatingReplinstead ofisAiUpdating - Editor edits are blocked while
isToolUpdatingReplis true -
isAiUpdatingcontinues to work unchanged for other features - Overlay only appears when
updateRepltool is running (not during AI thinking/text responses)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels