Add theme options and timed agent dividers
This commit is contained in:
@@ -256,6 +256,26 @@ function createAgentRuntime(deps) {
|
||||
return JSON.stringify(truncateObj(item, 1200));
|
||||
}
|
||||
|
||||
function formatAgentMessageDividerTime(date = new Date()) {
|
||||
const pad = (value) => String(value).padStart(2, '0');
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
||||
}
|
||||
|
||||
function createAgentMessageDivider() {
|
||||
const time = formatAgentMessageDividerTime();
|
||||
return `<div class="agent-message-divider" data-divider-time="${time}"><span>${time}</span></div>`;
|
||||
}
|
||||
|
||||
function hasAgentMessageBoundaryAtEnd(text) {
|
||||
return /\n\s*(?:---|\*\*\*|___)\s*$/.test(text)
|
||||
|| /(?:^|\n)\s*<div\s+class=["']agent-message-divider["'][\s\S]*?<\/div>\s*$/.test(text);
|
||||
}
|
||||
|
||||
function hasAgentMessageBoundaryAtStart(text) {
|
||||
return /^\s*(?:---|\*\*\*|___)\s*\n/.test(text)
|
||||
|| /^\s*<div\s+class=["']agent-message-divider["'][\s\S]*?<\/div>\s*/.test(text);
|
||||
}
|
||||
|
||||
function sendRuntime(entry, sessionId, payload) {
|
||||
wsSend(entry.ws, { ...payload, sessionId });
|
||||
}
|
||||
@@ -266,9 +286,9 @@ function createAgentRuntime(deps) {
|
||||
|
||||
const currentText = entry.fullText || '';
|
||||
const hasExistingText = /\S/.test(currentText);
|
||||
const hasVisualBoundary = /\n\s*(?:---|\*\*\*|___)\s*$/.test(currentText) || /^\s*(?:---|\*\*\*|___)\s*\n/.test(nextText);
|
||||
const hasVisualBoundary = hasAgentMessageBoundaryAtEnd(currentText) || hasAgentMessageBoundaryAtStart(nextText);
|
||||
const separator = hasExistingText && !hasVisualBoundary
|
||||
? (/\n\s*$/.test(currentText) ? '\n---\n\n' : '\n\n---\n\n')
|
||||
? (/\n\s*$/.test(currentText) ? `\n${createAgentMessageDivider()}\n\n` : `\n\n${createAgentMessageDivider()}\n\n`)
|
||||
: '';
|
||||
const chunk = separator + nextText;
|
||||
entry.fullText += chunk;
|
||||
|
||||
@@ -18,6 +18,26 @@ function createCodexAppRuntime(deps = {}) {
|
||||
wsSend(entry.ws, { ...payload, sessionId });
|
||||
}
|
||||
|
||||
function formatAgentMessageDividerTime(date = new Date()) {
|
||||
const pad = (value) => String(value).padStart(2, '0');
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
||||
}
|
||||
|
||||
function createAgentMessageDivider() {
|
||||
const time = formatAgentMessageDividerTime();
|
||||
return `<div class="agent-message-divider" data-divider-time="${time}"><span>${time}</span></div>`;
|
||||
}
|
||||
|
||||
function hasAgentMessageBoundaryAtEnd(text) {
|
||||
return /\n\s*(?:---|\*\*\*|___)\s*$/.test(text)
|
||||
|| /(?:^|\n)\s*<div\s+class=["']agent-message-divider["'][\s\S]*?<\/div>\s*$/.test(text);
|
||||
}
|
||||
|
||||
function hasAgentMessageBoundaryAtStart(text) {
|
||||
return /^\s*(?:---|\*\*\*|___)\s*\n/.test(text)
|
||||
|| /^\s*<div\s+class=["']agent-message-divider["'][\s\S]*?<\/div>\s*/.test(text);
|
||||
}
|
||||
|
||||
function itemKind(item) {
|
||||
switch (item?.type) {
|
||||
case 'commandExecution':
|
||||
@@ -263,8 +283,8 @@ function createCodexAppRuntime(deps = {}) {
|
||||
if (entry.agentMessageItems?.get(itemId)) return '';
|
||||
const currentText = entry.fullText || '';
|
||||
if (!/\S/.test(currentText)) return '';
|
||||
const hasVisualBoundary = /\n\s*(?:---|\*\*\*|___)\s*$/.test(currentText) || /^\s*(?:---|\*\*\*|___)\s*\n/.test(String(nextText || ''));
|
||||
return hasVisualBoundary ? '' : '\n\n---\n\n';
|
||||
const hasVisualBoundary = hasAgentMessageBoundaryAtEnd(currentText) || hasAgentMessageBoundaryAtStart(String(nextText || ''));
|
||||
return hasVisualBoundary ? '' : `\n\n${createAgentMessageDivider()}\n\n`;
|
||||
}
|
||||
|
||||
function updateToolResult(entry, sessionId, itemId, result, done = false, patch = {}) {
|
||||
|
||||
Reference in New Issue
Block a user