The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(thread): handle missing thread ID in turn state store
Steven Enamakelcdd72ca30352
diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsxindex 48e829dc31..febb05a694 100644--- a/app/src/components/assistant-ui/thread.tsx+++ b/app/src/components/assistant-ui/thread.tsx@@ -1306,12 +1306,71 @@ const SourceGroupSlot: FC<{ Component: ComponentType<{ sources: readonly SourceIreturn sources.length > 0 ? <Component sources={sources} /> : null;};+/** Whether this message is a stopped/cancelled turn's partial reply. */+const isStoppedRun = (s: AssistantState): boolean =>+ s.message.status?.type === 'incomplete' && s.message.status.reason === 'cancelled';++/**+ * The stopped turn's own text, split into words for the vendored+ * `StoppedRun` element, plus `cancel_reason`/`superseded_by`+ * (wire-contract.md `chat_cancelled`, carried through+ * `metadata.custom.extraMetadata` by `assistantUiMessages.ts`) so the reason+ * chip can distinguish a user-initiated Stop from a turn the core superseded.+ */+const selectStoppedRunState = (s: AssistantState) => {+ const text = s.message.parts+ .filter((part): part is { type: 'text'; text: string } => part.type === 'text')+ .map(part => part.text)+ .join(' ');+ const custom = s.message.metadata?.custom as+ | { extraMetadata?: { cancelReason?: string; supersededBy?: string } }+ | undefined;+ return {+ words: text.length > 0 ? text.split(/\s+/).filter(Boolean) : [],+ cancelReason: custom?.extraMetadata?.cancelReason,+ };+};++/**+ * Renders in place of the normal part switch for a stopped/cancelled+ * assistant message (#4862 kept the raw text visible via a plain "Stopped"+ * label; this replaces that with the real vendored element). Continue re-runs+ * the turn through the same Reload capability `AssistantActionBar` uses;+ * Discard drops the partial reply from this client's view via `onDelete`+ * (`useOpenHumanExternalStore.ts` — the core keeps the persisted row, this+ * only stops showing it here).+ */+const StoppedRunSlot: FC = () => {+ const aui = useAui();+ const { t } = useT();+ const { words, cancelReason } = useAuiState(selectStoppedRunState);+ const { disabled: reloadDisabled, reload } = useActionBarReload();+ const reasonLabel =+ cancelReason === 'superseded'+ ? t('conversations.assistantUi.stoppedRun.reasonSuperseded')+ : t('conversations.assistantUi.stoppedRun.reasonUserStop');+ return (+ <StoppedRun+ data-testid="stopped-marker"+ words={words}+ reason={reasonLabel}+ onContinue={() => {+ if (!reloadDisabled) reload();+ }}+ onDiscard={() => aui.message.delete()}+ continueLabel={t('common.continue')}+ discardLabel={t('settings.ai.discard')}+ />+ );+};+const AssistantMessage: FC = () => {const {ToolFallback: ToolFallbackComponent = ToolFallback,ActivityGroup = DefaultActivityGroup,SourceGroup,} = useContext(ThreadComponentsContext);+ const stopped = useAuiState(isStoppedRun);const ACTION_BAR_PT = 'pt-1.5';// `min-h` reserves the bar's height (`pt-1.5` + a `size-6` button = 7.5) so adiff --git a/app/src/features/conversations/components/AssistantUiChat.tsx b/app/src/features/conversations/components/AssistantUiChat.tsxindex 67965fb80c..eee36b1ddf 100644--- a/app/src/features/conversations/components/AssistantUiChat.tsx+++ b/app/src/features/conversations/components/AssistantUiChat.tsx@@ -285,7 +285,7 @@ export function AssistantUiChat({ToolFallback: ChatToolFallback,// `/` commands (builtins + core `commands_list` + registry actions) and// `@` mentions (memory recall, thread files); see `aui/ComposerTriggers`.- //TMP ComposerTriggers,+ ComposerTriggers,ComposerExtras,ComposerHeader,ComposerIdleAction,diff --git a/crates/openhuman-core/src/threads/turn_state/store.rs b/crates/openhuman-core/src/threads/turn_state/store.rsindex 40ed9ae9b9..8b47f10f26 100644--- a/crates/openhuman-core/src/threads/turn_state/store.rs+++ b/crates/openhuman-core/src/threads/turn_state/store.rs@@ -161,8 +161,7 @@ impl TurnStateStore {if !path.exists() {return Ok(false);}- fs::remove_file(&path)- .map_err(|e| format!("remove turn-state {}: {e}", path.display()))?;+ fs::remove_file(&path).map_err(|e| format!("remove turn-state {}: {e}", path.display()))?;debug!("{LOG_PREFIX} deleted snapshot thread={thread_id} request={request_id}");Ok(true)}@@ -648,7 +647,11 @@ pub fn delete(workspace_dir: PathBuf, thread_id: &str) -> Result<bool, String> {TurnStateStore::new(workspace_dir).delete(thread_id)}-pub fn delete_turn(workspace_dir: PathBuf, thread_id: &str, request_id: &str) -> Result<bool, String> {+pub fn delete_turn(+ workspace_dir: PathBuf,+ thread_id: &str,+ request_id: &str,+) -> Result<bool, String> {TurnStateStore::new(workspace_dir).delete_turn(thread_id, request_id)}diff --git a/crates/openhuman-core/src/web_chat/event_bus.rs b/crates/openhuman-core/src/web_chat/event_bus.rsindex d9526b8530..8f67bccfad 100644--- a/crates/openhuman-core/src/web_chat/event_bus.rs+++ b/crates/openhuman-core/src/web_chat/event_bus.rs@@ -152,7 +152,10 @@ impl EventHandler<DomainEvent> for MemoryActivitySurfaceSubscriber {}),),DomainEvent::MemoryRecalled { query, hit_count } => {- let preview: String = query.chars().take(MEMORY_ACTIVITY_QUERY_PREVIEW_CHARS).collect();+ let preview: String = query+ .chars()+ .take(MEMORY_ACTIVITY_QUERY_PREVIEW_CHARS)+ .collect();let truncated = query.chars().count() > MEMORY_ACTIVITY_QUERY_PREVIEW_CHARS;("recalled",@@ -166,9 +169,7 @@ impl EventHandler<DomainEvent> for MemoryActivitySurfaceSubscriber {_ => return,};let Some((thread_id, client_id)) = current_chat_context() else {- log::debug!(- "[web-channel] memory-activity-surface skip {event_name}: no chat context"- );+ log::debug!("[web-channel] memory-activity-surface skip {event_name}: no chat context");return;};log::debug!(