fix(codex): use precise selector for read command

This commit is contained in:
jackwener committed 2026-03-18 17:14:47 +08:00
1 parent 4ce0345c9a
commit cd6f7a1f7e
1 file changed
+7 -2
+7 -2
View File
@@ -11,9 +11,14 @@ export const readCommand = cli({
func: async (page) => {
const historyText = await page.evaluate(`
(function() {
// Precise Codex selector for chat messages
const turns = Array.from(document.querySelectorAll('[data-content-search-turn-key]'));
if (turns.length > 0) {
return turns.map(t => t.innerText || t.textContent).join('\\n\\n---\\n\\n');
}
// Fallback robust scraping heuristic for chat history panes
// We look for large scrolling areas or generic message lists
const threadContainer = document.querySelector('[role="log"], [data-testid="conversation"], main, .thread-container, .messages-list');
const threadContainer = document.querySelector('[role="log"], [data-testid="conversation"], .thread-container, .messages-list, main');
if (threadContainer) {
return threadContainer.innerText || threadContainer.textContent;