-
🌐 admin_panel.phpWeb, 1.54 kB⬇
-
🌐 api.jsWeb, 12.79 kB⬇
-
🌐 api.phpWeb, 7.79 kB⬇
-
🌐 app.jsWeb, 150.45 kB⬇
-
🌐 base.cssWeb, 2.23 kB⬇
-
🌐 context.jsWeb, 9.26 kB⬇
-
🌐 conversation-index.jsWeb, 10.34 kB⬇
-
🌐 conversation.jsWeb, 1.11 kB⬇
-
🌐 conversations.jsWeb, 23.87 kB⬇
-
🌐 diction.jsWeb, 935 B⬇
-
🌐 document.jsWeb, 947 B⬇
-
🌐 dynamic.phpWeb, 533 B⬇
-
📷 favicon-lg.pngImage, 9.11 kB⬇
-
📷 favicon.pngImage, 3.12 kB⬇
-
🌐 index.phpWeb, 30.31 kB⬇
-
🌐 indexjs.jsWeb, 580 B⬇
-
🌐 login.phpWeb, 876 B⬇
-
❓ manifest.webmanifestUnknown, 262 B⬇
-
🌐 memory.jsWeb, 407 B⬇
-
🌐 model-presets.jsonWeb, 7.89 kB⬇
-
🌐 models.jsonWeb, 12.83 kB⬇
-
🌐 notebook-index.jsWeb, 721 B⬇
-
⚠️ php.iniOS File, 356 B⬇
-
🌐 scratchpad-conversation.jsWeb, 2.70 kB⬇
-
🌐 scratchpad-index.jsWeb, 14.47 kB⬇
-
🌐 storage.jsWeb, 20.49 kB⬇
-
🌐 style.cssWeb, 49.16 kB⬇
-
🌐 users.jsWeb, 45.79 kB⬇
-
🌐 utility-models.jsonWeb, 1.46 kB⬇
import {
formatContentBlock,
formatAnnotationsBlock,
formatSuggestions,
formatCostSummary
} from './util/conversation-format-utils.js';
import { escapeHtml, formatThinkingBlockHtml } from './util/format-utils.js';
/**
* Class ScratchpadConversation
* Handles formatting and rendering specifically for scratchpad conversation items.
*/
class ScratchpadConversation {
/**
* Initializes a new instance of ScratchpadConversation.
*/
constructor() {
}
/**
* Formats a single scratchpad item as HTML.
* @param {Object} data - The data object for the scratchpad item.
* @param {number} index - The index of the item in history.
* @param {Object} [conversation_settings={}] - Settings for the conversation.
* @returns {string} The formatted HTML string.
*/
format_scratchpad_item(data, index, conversation_settings = {}) {
if (!data) return '';
let html = '';
if (!data.pending) {
html += `
<div class="div-chat-response-buttons div-chat-scrathpad-buttons">
<div class="div-chat-response-buttons-left">
<button class="btn-copy-scratchpad" data-index="${index}">Copy</button>
</div>
<div class="div-chat-response-buttons-right">
<button class="btn-redo-scratchpad" data-index="${index}">Redo</button>
<button class="btn-undo-scratchpad" data-index="${index}">Undo</button>
<button class="btn-delete-scratchpad" data-index="${index}">Delete</button>
</div>
</div>
`;
}
html += formatThinkingBlockHtml(data.thinking, !!data.pending, index);
if (data.pending) {
return html;
}
let response_html = formatContentBlock(data.content);
response_html += formatAnnotationsBlock(data.annotations);
html += `<div class="div-response-content" data-index="${index}">${response_html}</div>`;
html += formatSuggestions(data, conversation_settings);
html += formatCostSummary(data);
return html;
}
/**
* Renders an entire scratchpad conversation, displaying only the most recent revision.
* @param {Object} conversation - The conversation object containing HISTORY array.
* @param {Object} [options={}] - Render options (e.g. show_suggested, show_related).
* @returns {string} The complete HTML string for the scratchpad conversation.
*/
render(conversation, options = {}) {
if (!conversation) return '<p>Enter a query to get started.</p>';
const history = conversation.HISTORY || conversation.history || (Array.isArray(conversation) ? conversation : []);
if (!Array.isArray(history) || history.length === 0) return '<p>Enter a query to get started.</p>';
const lastIndex = history.length - 1;
const lastItem = history[lastIndex];
return this.format_scratchpad_item(lastItem, lastIndex, options);
}
}
export default ScratchpadConversation;
scratchpad-conversation.js
×
Type: Web, text/plain
2.70 Kilobytes
Last Modified 2026-09-23 02:24:57
⬇ Download File
Type: Web, text/plain
2.70 Kilobytes
Last Modified 2026-09-23 02:24:57
⬇ Download File