|
|
@@ -45,33 +45,42 @@
|
|
|
}
|
|
|
|
|
|
function appendEntry(log, entry) {
|
|
|
+ // Only render bash entries — llm-comment entries duplicate
|
|
|
+ // the # lines already present in the bash command_text
|
|
|
var type = entry.type || 'command';
|
|
|
+ if (type !== 'bash' && type !== 'command') return;
|
|
|
|
|
|
- if (type === 'llm-comment' || (entry.command && entry.command.charAt(0) === '#')) {
|
|
|
- var c = document.createElement('span');
|
|
|
- c.className = 'term-comment';
|
|
|
- c.textContent = (entry.command || entry.output || '') + '\n';
|
|
|
- log.appendChild(c);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
+ // stdin: the LLM's response sent to bash — render per-line
|
|
|
if (entry.command && entry.command.length > 0) {
|
|
|
- var cmd = document.createElement('span');
|
|
|
- cmd.className = 'term-cmd';
|
|
|
- cmd.textContent = '$ ' + entry.command + '\n';
|
|
|
- log.appendChild(cmd);
|
|
|
+ var lines = entry.command.split('\n');
|
|
|
+ for (var i = 0; i < lines.length; i++) {
|
|
|
+ var line = lines[i];
|
|
|
+ if (line.length === 0) continue;
|
|
|
+ var span = document.createElement('span');
|
|
|
+ if (line.charAt(0) === '#') {
|
|
|
+ span.className = 'term-think';
|
|
|
+ span.textContent = line + '\n';
|
|
|
+ } else {
|
|
|
+ span.className = 'term-stdin';
|
|
|
+ span.textContent = '$ ' + line + '\n';
|
|
|
+ }
|
|
|
+ log.appendChild(span);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ // piped input (saddle query)
|
|
|
if (entry.input && entry.input.length > 0) {
|
|
|
var inp = document.createElement('span');
|
|
|
- inp.className = 'term-input-text';
|
|
|
+ inp.className = 'term-stdin';
|
|
|
inp.textContent = entry.input + '\n';
|
|
|
log.appendChild(inp);
|
|
|
}
|
|
|
|
|
|
+ // stdout/stderr
|
|
|
if (entry.output && entry.output.length > 0) {
|
|
|
var out = document.createElement('span');
|
|
|
- out.className = 'term-out';
|
|
|
+ out.className = (entry.exit_code !== 0 && entry.exit_code !== -1)
|
|
|
+ ? 'term-stderr' : 'term-stdout';
|
|
|
out.textContent = entry.output + '\n';
|
|
|
log.appendChild(out);
|
|
|
}
|