Implement comprehensive tool call rendering with state persistence

- Implement tool-specific rendering for all 14 tool types (read, edit, write, bash, webfetch, todowrite, task, etc.)
- Each tool shows contextually relevant information (file previews, diffs, command output, todo lists)
- Add metadata-driven content display using preview, diff, output, and todos from tool state
- Implement status-based rendering (pending, running, completed, error) with animations
- Create global state store for expandable items (tool calls and reasoning sections)
- Fix state persistence: expanded tool calls and reasoning sections remain expanded when new messages arrive
- Fix scroll position preservation during live message updates
- Fix reasoning toggle loop by replacing native details element with custom expandable
- Add comprehensive documentation in TOOL_CALL_IMPLEMENTATION.md
- Reduce font sizes for better readability in expanded tool content
- Add proper keying to For loops to prevent component recreation
- Match TUI patterns for tool names, actions, and content formatting
This commit is contained in:
Shantur Rathore
2025-10-23 01:18:25 +01:00
parent fa77b4e82e
commit d7f619486e
15 changed files with 3059 additions and 106 deletions

View File

@@ -58,6 +58,41 @@ body {
overflow: hidden;
}
.connection-status {
display: flex;
justify-content: flex-end;
padding: 8px 16px;
background-color: var(--secondary-bg);
border-bottom: 1px solid var(--border-color);
}
.status-indicator {
display: flex;
align-items: center;
gap: 6px;
font-size: 12px;
color: var(--text-muted);
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
}
.status-indicator.connected .status-dot {
background-color: var(--success-color);
}
.status-indicator.connecting .status-dot {
background-color: var(--warning-color);
animation: pulse 1.5s ease-in-out infinite;
}
.status-indicator.disconnected .status-dot {
background-color: var(--error-color);
}
.message-stream {
flex: 1;
overflow-y: auto;
@@ -226,21 +261,33 @@ body {
background-color: var(--secondary-bg);
}
.message-reasoning details {
.reasoning-container {
padding: 8px 12px;
}
.message-reasoning summary {
.reasoning-header {
display: flex;
align-items: center;
gap: 6px;
font-size: 13px;
color: var(--text-muted);
cursor: pointer;
user-select: none;
}
.message-reasoning summary:hover {
.reasoning-header:hover {
color: var(--accent-color);
}
.reasoning-icon {
font-size: 10px;
transition: transform 150ms ease;
}
.reasoning-label {
font-weight: 500;
}
.tool-call {
border: 1px solid var(--border-color);
border-radius: 6px;
@@ -292,11 +339,32 @@ body {
border-left: 3px solid var(--error-color);
}
.tool-call-status-running,
.tool-call-status-pending {
.tool-call-status-running {
border-left: 3px solid var(--warning-color);
}
.tool-call-status-running .tool-call-status {
animation: pulse 1.5s ease-in-out infinite;
}
.tool-call-status-pending {
border-left: 3px solid var(--accent-color);
}
.tool-call-status-pending .tool-call-summary {
animation: shimmer 2s ease-in-out infinite;
}
@keyframes shimmer {
0%,
100% {
opacity: 0.6;
}
50% {
opacity: 1;
}
}
.tool-call-preview {
padding: 8px 12px;
background-color: var(--code-bg);
@@ -331,7 +399,8 @@ body {
background-color: var(--code-bg);
display: flex;
flex-direction: column;
gap: 12px;
gap: 8px;
font-size: 12px;
}
.tool-call-section h4 {
@@ -376,6 +445,98 @@ body {
background: var(--text-muted);
}
.tool-call-pending-message {
display: flex;
align-items: center;
gap: 8px;
padding: 12px;
color: var(--text-muted);
font-size: 12px;
font-style: italic;
}
.tool-call-emoji {
font-size: 16px;
margin-right: 4px;
}
.tool-call-bash,
.tool-call-diff {
margin: 8px 0;
}
.tool-call-content {
background-color: var(--secondary-bg);
border: 1px solid var(--border-color);
border-radius: 4px;
padding: 8px 12px;
font-family: monospace;
font-size: 12px;
line-height: 1.4;
overflow-x: auto;
margin: 0;
}
.tool-call-content code {
font-family: inherit;
background: none;
padding: 0;
font-size: inherit;
}
.tool-call-todos {
margin: 8px 0;
display: flex;
flex-direction: column;
gap: 4px;
}
.tool-call-todo-item {
font-family: monospace;
font-size: 12px;
line-height: 1.5;
}
.tool-call-todo-item code {
background-color: rgba(0, 100, 255, 0.1);
padding: 2px 4px;
border-radius: 2px;
font-family: monospace;
}
.tool-call-task-summary {
margin: 8px 0;
display: flex;
flex-direction: column;
gap: 6px;
}
.tool-call-task-item {
font-size: 12px;
line-height: 1.5;
padding-left: 8px;
border-left: 2px solid var(--border-color);
}
.tool-call-task-item::before {
content: "∟ ";
color: var(--text-muted);
}
.tool-call-error-content {
background-color: rgba(244, 67, 54, 0.1);
border-left: 3px solid var(--error-color);
padding: 12px;
margin: 8px 0;
border-radius: 4px;
color: var(--error-color);
font-size: 12px;
}
.tool-call-error-content strong {
font-weight: 600;
}
.scroll-to-bottom {
position: absolute;
bottom: 16px;
@@ -468,3 +629,127 @@ body {
transform: rotate(360deg);
}
}
.prompt-input-container {
display: flex;
flex-direction: column;
border-top: 1px solid var(--border-color);
background-color: var(--background);
}
.prompt-input-wrapper {
display: flex;
align-items: flex-end;
gap: 8px;
padding: 12px 16px;
}
.prompt-input {
flex: 1;
min-height: 40px;
max-height: 200px;
padding: 10px 12px;
border: 1px solid var(--border-color);
border-radius: 6px;
font-family: inherit;
font-size: 14px;
line-height: 1.5;
resize: none;
background-color: var(--background);
color: inherit;
outline: none;
transition: border-color 150ms ease;
}
.prompt-input:focus {
border-color: var(--accent-color);
}
.prompt-input:disabled {
opacity: 0.6;
cursor: not-allowed;
}
.prompt-input::placeholder {
color: var(--text-muted);
}
.send-button {
width: 40px;
height: 40px;
border-radius: 6px;
background-color: var(--accent-color);
color: white;
border: none;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition:
opacity 150ms ease,
transform 150ms ease;
flex-shrink: 0;
}
.send-button:hover:not(:disabled) {
opacity: 0.9;
transform: scale(1.05);
}
.send-button:active:not(:disabled) {
transform: scale(0.95);
}
.send-button:disabled {
opacity: 0.4;
cursor: not-allowed;
}
.send-icon {
font-size: 16px;
}
.spinner-small {
width: 16px;
height: 16px;
border: 2px solid rgba(255, 255, 255, 0.3);
border-top-color: white;
border-radius: 50%;
animation: spin 1s linear infinite;
}
.prompt-input-hints {
padding: 0 16px 8px 16px;
display: flex;
justify-content: space-between;
align-items: center;
}
.hint {
font-size: 12px;
color: var(--text-muted);
}
.hint kbd {
display: inline-block;
padding: 2px 6px;
font-size: 11px;
font-family: monospace;
background-color: var(--secondary-bg);
border: 1px solid var(--border-color);
border-radius: 3px;
margin: 0 2px;
}
.session-view {
display: flex;
flex-direction: column;
height: 100%;
}
.message-sending {
color: var(--text-muted);
font-size: 13px;
font-style: italic;
margin-top: 4px;
}