{"record":{"id":"4b744b2e830d5396","repo":"zed-industries/zed","slug":"terminal-with-id-not-found","errorCode":null,"errorMessage":"Terminal with id `{}` not found","messagePattern":"Terminal with id `(.+?)` not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/acp_thread/src/acp_thread.rs","lineNumber":1844,"sourceCode":"                    &language_registry,\n                    path_style,\n                    cx,\n                )),\n            )),\n            acp::ToolCallContent::Diff(diff) => Ok(Some(Self::Diff(cx.new(|cx| {\n                Diff::finalized(\n                    diff.path.to_string_lossy().into_owned(),\n                    diff.old_text,\n                    diff.new_text,\n                    language_registry,\n                    cx,\n                )\n            })))),\n            acp::ToolCallContent::Terminal(acp::Terminal { terminal_id, .. }) => terminals\n                .get(&terminal_id)\n                .cloned()\n                .map(|terminal| Some(Self::Terminal(terminal)))\n                .ok_or_else(|| anyhow::anyhow!(\"Terminal with id `{}` not found\", terminal_id)),\n            _ => Ok(None),\n        }\n    }\n\n    pub fn update_from_acp(\n        &mut self,\n        new: acp::ToolCallContent,\n        language_registry: Arc<LanguageRegistry>,\n        path_style: PathStyle,\n        terminals: &HashMap<acp::TerminalId, Entity<Terminal>>,\n        cx: &mut App,\n    ) -> Result<bool> {\n        // Update streaming text in place so the rendered markdown element is\n        // reused across snapshots instead of being recreated (which flickers).\n        if let (\n            Self::ContentBlock(block),\n            acp::ToolCallContent::Content(acp::Content { content, .. }),\n        ) = (&mut *self, &new)","sourceCodeStart":1826,"sourceCodeEnd":1862,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/acp_thread/src/acp_thread.rs#L1826-L1862","documentation":"Converting acp::ToolCallContent::Terminal into the local representation requires the terminal_id to be present in the terminals map passed to the conversion. When the referenced terminal is not tracked there, conversion fails with the missing id.","triggerScenarios":"A tool-call content event referencing a terminal id that was never registered in the HashMap — events arriving before the terminal is created, from another window, or after the terminal was removed; replaying persisted threads whose terminals were not restored.","commonSituations":"Deserializing recorded/replayed sessions without recreating terminals; ordering races between terminal creation and tool-call content events; multi-window setups.","solutions":["Populate the terminals map (keyed by acp::TerminalId) before forwarding or replaying tool-call content that references terminals.","When an unknown id is seen, defer or drop that content block instead of failing the entire conversion.","When replaying persisted threads, recreate terminals under their persisted ids or strip Terminal blocks first."],"exampleFix":"// before\nlet content = ToolCallContent::from_acp(raw, registry, path_style, &terminals, cx)?; // fails on unknown id\n\n// after\nif let acp::ToolCallContent::Terminal(t) = &raw {\n    if !terminals.contains_key(&t.terminal_id) {\n        return Ok(None); // skip block instead of erroring\n    }\n}\nlet content = ToolCallContent::from_acp(raw, registry, path_style, &terminals, cx)?;","handlingStrategy":"validation","validationCode":"if let acp::ToolCallContent::Terminal(acp::Terminal { terminal_id, .. }) = &content {\n    if !terminals.contains_key(terminal_id) {\n        // skip or defer this block; do not attempt conversion\n        return Ok(None);\n    }\n}","typeGuard":"fn terminal_is_tracked(\n    terminal_id: &acp::TerminalId,\n    terminals: &HashMap<acp::TerminalId, Entity<Terminal>>,\n) -> bool {\n    terminals.contains_key(terminal_id)\n}","tryCatchPattern":"match ToolCallContent::from_acp(raw, registry, path_style, &terminals, cx) {\n    Ok(content) => { /* render */ }\n    Err(e) if e.to_string().starts_with(\"Terminal with id\") => {\n        // unknown terminal: drop the block, keep the rest of the tool call\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Register terminals in the map before replaying tool-call content that references them.","When replaying persisted threads, recreate terminals by persisted id or strip Terminal blocks."],"tags":["rust","zed","acp","terminal","replay","ordering"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}