diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..d508289 --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,4 @@ +allowBuilds: + esbuild: set this to true or false +onlyBuiltDependencies: + - esbuild diff --git a/src-tauri/src/runtime_state.rs b/src-tauri/src/runtime_state.rs index 253cdc2..e6b9c4b 100644 --- a/src-tauri/src/runtime_state.rs +++ b/src-tauri/src/runtime_state.rs @@ -15,6 +15,7 @@ pub enum PetStateId { Waiting, Running, Review, + Thinking, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] @@ -52,6 +53,7 @@ impl DerivedPetState { const MIN_DWELL_MS: u64 = 200; const TEMP_STATE_IDLE_AFTER_MS: u64 = 1_500; +const THINKING_IDLE_AFTER_MS: u64 = 30_000; pub struct EventStateEngine { current: DerivedPetState, @@ -80,7 +82,12 @@ impl EventStateEngine { return self.request_idle(now_ms); } - self.set_state(next, now_ms, Some(now_ms + TEMP_STATE_IDLE_AFTER_MS)) + let idle_after = if next == PetStateId::Thinking { + Some(now_ms + THINKING_IDLE_AFTER_MS) + } else { + Some(now_ms + TEMP_STATE_IDLE_AFTER_MS) + }; + self.set_state(next, now_ms, idle_after) } pub fn advance_time(&mut self, now_ms: u64) -> DerivedPetState { @@ -100,7 +107,7 @@ impl EventStateEngine { return self.current(); } - if !matches!(self.current.state, PetStateId::Running | PetStateId::Review) { + if !matches!(self.current.state, PetStateId::Running | PetStateId::Review | PetStateId::Thinking) { return self.set_state(PetStateId::Idle, now_ms, None); } @@ -236,6 +243,7 @@ fn map_event_to_state(event: &RuntimeEvent) -> Option { "permission.waiting" | "session.waiting" => Some(PetStateId::Waiting), "session.stop" | "session.end" => Some(PetStateId::Waving), "session.error" => Some(PetStateId::Failed), + "thinking" => Some(PetStateId::Thinking), _ => None, } } diff --git a/src/hooks/useAgentState.ts b/src/hooks/useAgentState.ts index ce23a2f..56a20e7 100644 --- a/src/hooks/useAgentState.ts +++ b/src/hooks/useAgentState.ts @@ -28,6 +28,8 @@ function translate(petState: PetStateId, agentMessages: AgentMessage[]): AgentSt return { kind: "awaitingApproval", agent }; case "waving": return { kind: "celebrating", agent }; + case "thinking": + return { kind: "thinking", agent }; case "failed": return { kind: "hurt", agent }; case "idle": diff --git a/src/hooks/usePetSounds.ts b/src/hooks/usePetSounds.ts index d0e2e9b..3b6f648 100644 --- a/src/hooks/usePetSounds.ts +++ b/src/hooks/usePetSounds.ts @@ -15,6 +15,7 @@ export type AgentSoundKey = keyof PetAgentSounds; export function agentSoundKeyForPetState(state: PetStateId): AgentSoundKey | null { switch (state) { case "jumping": + case "thinking": return "thinking"; case "running": return "editing"; diff --git a/src/lib/appTypes.ts b/src/lib/appTypes.ts index 3fba798..bca4b7e 100644 --- a/src/lib/appTypes.ts +++ b/src/lib/appTypes.ts @@ -7,7 +7,8 @@ export type PetStateId = | "failed" | "waiting" | "running" - | "review"; + | "review" + | "thinking"; export type PetState = { id: PetStateId; diff --git a/src/lib/petAnimation.ts b/src/lib/petAnimation.ts index 1149e87..a12e031 100644 --- a/src/lib/petAnimation.ts +++ b/src/lib/petAnimation.ts @@ -65,7 +65,7 @@ function baseSpriteRow(_state: BaseState): PetStateId { function agentSpriteRow(state: AgentState): PetStateId { switch (state.kind) { case "thinking": - return "waiting"; + return "review"; case "editing": return "running"; case "inspecting":