generated from nhcarrigan/template
feat: detect prompt-too-long errors and offer compact action
Closes #158 - Detect "Prompt is too long" in assistant text blocks in wsl_bridge - Emit error line type instead of assistant for better visibility - Emit compact-prompt event after the error line - Render a compact-prompt line as an action button in the terminal - Clicking the button sends /compact to the active session - Add getLineClass/getLinePrefix tests for compact-prompt type
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { claudeStore, type TerminalLine } from "$lib/stores/claude";
|
||||
import { afterUpdate, tick, onMount, onDestroy } from "svelte";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
import ConversationTabs from "./ConversationTabs.svelte";
|
||||
import Markdown from "./Markdown.svelte";
|
||||
@@ -95,6 +96,8 @@
|
||||
return "terminal-thinking";
|
||||
case "rate-limit":
|
||||
return "terminal-rate-limit";
|
||||
case "compact-prompt":
|
||||
return "terminal-compact-prompt";
|
||||
default:
|
||||
return "terminal-default";
|
||||
}
|
||||
@@ -193,6 +196,11 @@
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
async function handleCompact() {
|
||||
if (!currentConversationId) return;
|
||||
await invoke("send_prompt", { conversationId: currentConversationId, message: "/compact" });
|
||||
}
|
||||
|
||||
// Collapsible tool lines
|
||||
const TOOL_COLLAPSE_THRESHOLD = 60;
|
||||
let expandedToolLines: Record<string, boolean> = {};
|
||||
@@ -283,7 +291,11 @@
|
||||
{#if line.toolName}
|
||||
<span class="terminal-tool-name mr-2">[{line.toolName}]</span>
|
||||
{/if}
|
||||
{#if line.type === "assistant" || line.type === "user"}
|
||||
{#if line.type === "compact-prompt"}
|
||||
<button class="compact-action-btn" onclick={handleCompact}>
|
||||
⚡ Compact Conversation
|
||||
</button>
|
||||
{:else if line.type === "assistant" || line.type === "user"}
|
||||
<div class="message-content-wrapper">
|
||||
<Markdown
|
||||
content={maskPaths(line.content, hidePaths)}
|
||||
@@ -370,6 +382,30 @@
|
||||
color: var(--terminal-rate-limit, #fb923c);
|
||||
}
|
||||
|
||||
.terminal-compact-prompt {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.compact-action-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4em;
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--terminal-error, #f87171);
|
||||
color: var(--terminal-error, #f87171);
|
||||
padding: 0.3em 0.8em;
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
font-size: 0.9em;
|
||||
font-family: inherit;
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
.compact-action-btn:hover {
|
||||
background: color-mix(in srgb, var(--terminal-error, #f87171) 15%, transparent);
|
||||
color: var(--terminal-error, #f87171);
|
||||
}
|
||||
|
||||
.terminal-default {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user