jackwener/OpenCLI · error · EmptyResultError
No conversation history found in Trae CN.
Error message
No conversation history found in Trae CN.
What it means
readTraeMessages evaluates an in-page script to collect Trae CN conversation history and throws EmptyResultError when the page yields no messages. This signals the automation reached the UI but found no readable conversation turns, not a crash.
Source
Thrown at clis/trae-cn/utils.js:673
export function responseAfterScript(beforeCount, maxChars = 0) {
return `
(function() {
const turns = Array.from(document.querySelectorAll('${TRAE_CN_TURN_SELECTOR}'));
const after = turns.slice(${JSON.stringify(beforeCount)});
const assistant = after.reverse().find(turn => (turn.getAttribute('data-role') || '').toLowerCase() === 'assistant' || turn.classList.contains('assistant'));
if (!assistant) return null;
const read = ${readMessagesScript(1, maxChars)};
const rows = read;
const last = rows[rows.length - 1];
return last && last.Role === 'Assistant' ? last : null;
})()
`;
}
export async function readTraeMessages(page, limit = 20, maxChars = 0) {
const messages = await page.evaluate(readMessagesScript(limit, maxChars));
if (!messages || messages.length === 0) {
throw new EmptyResultError('trae-cn read', 'No conversation history found in Trae CN.');
}
return messages;
}
export async function sendTraePrompt(page, text) {
const prompt = ensurePrompt(text);
const beforeCount = await page.evaluate(countTurnsScript());
const injected = await page.evaluate(injectPromptScript(prompt));
if (!injected?.ok) throw selectorError('Trae CN chat input');
await page.wait(0.3);
const submitted = await page.evaluate(submitPromptScript());
let mode = submitted?.mode || 'unknown';
if (!submitted?.ok) {
if (submitted?.reason === 'send_button_disabled' && typeof page.pressKey === 'function') {
await page.pressKey('Enter');
await page.wait(0.8);
mode = 'keyboard';
} else {View on GitHub (pinned to 49907e53dc)
Solutions
- Start a conversation in Trae CN before running read
- Wait for the chat panel to fully load, then retry
- Verify the Trae CN version is still compatible with this library's selectors
Example fix
// before const msgs = await readTraeMessages(page); // after await page.wait(1.5); // let panel render const msgs = await readTraeMessages(page);
Defensive patterns
Strategy: try-catch
Validate before calling
const info = await page.evaluate(inspectTraeShellScript());
if (!info || info.hasConversation === false) throw new SkipError('no conversation present; skipping read'); Type guard
const hasMessages = (m) => Array.isArray(m) && m.length > 0;
Try / catch
try { messages = await readTraeMessages(page, limit); } catch (e) { if (e instanceof EmptyResultError) { messages = []; console.warn('No Trae CN history yet'); } else throw e; } Prevention
- Ensure a conversation exists in the workspace before reading
- Wait for the chat panel to render before scraping
- Re-verify selectors after Trae CN upgrades
When it happens
Trigger: Reading history in a fresh workspace with no conversation yet, a Trae CN UI update changing DOM selectors the readMessagesScript relies on, or reading before the chat panel has rendered.
Common situations: Newly opened projects, cleared chat history, or Trae CN version upgrades that altered the message markup.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- discord-app servers
- No messages found in /chat/${id}.
- No chat turns found on current page.
- No assistant message visible.
- opencli notebooklm open
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/efbc6cf1d0c35969.
Report an issue: GitHub.