-
🌐 admin_panel.phpWeb, 1.54 kB⬇
-
🌐 api.jsWeb, 6.70 kB⬇
-
🌐 api.phpWeb, 6.80 kB⬇
-
🌐 app.jsWeb, 105.13 kB⬇
-
🌐 base.cssWeb, 2.23 kB⬇
-
🌐 context.jsWeb, 9.37 kB⬇
-
🌐 conversation-index.jsWeb, 10.19 kB⬇
-
🌐 conversation.jsWeb, 18.63 kB⬇
-
🌐 conversations.jsWeb, 16.57 kB⬇
-
🌐 diction.jsWeb, 935 B⬇
-
🌐 document.jsWeb, 947 B⬇
-
🌐 dynamic.phpWeb, 430 B⬇
-
📷 favicon-lg.pngImage, 9.11 kB⬇
-
📷 favicon.pngImage, 3.12 kB⬇
-
🌐 index.phpWeb, 20.30 kB⬇
-
🌐 indexjs.jsWeb, 572 B⬇
-
🌐 login.phpWeb, 787 B⬇
-
❓ manifest.webmanifestUnknown, 262 B⬇
-
🌐 memory.jsWeb, 407 B⬇
-
🌐 model-presets.jsonWeb, 4.27 kB⬇
-
🌐 models.jsonWeb, 3.42 kB⬇
-
🌐 notebook-index.jsWeb, 721 B⬇
-
⚠️ php.iniOS File, 356 B⬇
-
🌐 scratchpad-conversation.jsWeb, 2.89 kB⬇
-
🌐 scratchpad-index.jsWeb, 10.25 kB⬇
-
🌐 storage.jsWeb, 18.96 kB⬇
-
🌐 style.cssWeb, 23.14 kB⬇
-
🌐 theme_dark.jsonWeb, 360 B⬇
-
🌐 theme_light.jsonWeb, 361 B⬇
-
🌐 users.jsWeb, 23.71 kB⬇
import Conversation from './conversation.js';
import { escapeHtml } from './util/format-utils.js';
/**
* Class ScratchpadConversation
* Handles formatting and rendering specifically for scratchpad conversation items.
*/
class ScratchpadConversation {
#conversation;
/**
* Initializes a new instance of ScratchpadConversation.
*/
constructor() {
this.#conversation = new Conversation();
}
/**
* 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 = '';
const rawTitle = data['summary'] || data.title || data.query || 'Scratchpad Entry';
const titleText = escapeHtml(rawTitle);
html += `<h3 class="scratchpad-header">${titleText}</h3>`;
if (!data.pending) {
html += `
<div class="div-chat-response-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 += this.#conversation.format_thinking_block(data.thinking, !!data.pending, index);
if (data.pending) {
return html;
}
let response_html = this.#conversation.format_content_block(data.content);
response_html += this.#conversation.format_annotations_block(data.annotations);
html += `<div class="div-response-content" data-index="${index}">${response_html}</div>`;
html += this.#conversation.format_suggestions(data, conversation_settings);
html += this.#conversation.format_cost_summary(data);
return html;
}
/**
* Renders an entire scratchpad conversation's history turns into an HTML string.
* @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>';
let html = '';
history.forEach((data, index) => {
html += this.format_scratchpad_item(data, index, options);
});
return html;
}
}
export default ScratchpadConversation;
scratchpad-conversation.js
×
Type: Web, text/plain
2.89 Kilobytes
Last Modified 2026-09-05 05:32:11
⬇ Download File
Type: Web, text/plain
2.89 Kilobytes
Last Modified 2026-09-05 05:32:11
⬇ Download File