Spaces:
Sleeping
Sleeping
created submit/stop toggle buttons
Browse files- web/src/App.css +18 -0
- web/src/App.tsx +31 -10
web/src/App.css
CHANGED
|
@@ -1173,6 +1173,24 @@ details.tool-section[open] summary::before { transform: rotate(90deg); }
|
|
| 1173 |
.send-btn:active:not(:disabled) { transform: scale(0.95); }
|
| 1174 |
.send-btn:disabled { background: var(--bg-hover); color: var(--text-muted); cursor: not-allowed; box-shadow: none; }
|
| 1175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1176 |
.input-footer {
|
| 1177 |
text-align: center;
|
| 1178 |
font-size: 0.7rem;
|
|
|
|
| 1173 |
.send-btn:active:not(:disabled) { transform: scale(0.95); }
|
| 1174 |
.send-btn:disabled { background: var(--bg-hover); color: var(--text-muted); cursor: not-allowed; box-shadow: none; }
|
| 1175 |
|
| 1176 |
+
.stop-btn {
|
| 1177 |
+
width: 34px;
|
| 1178 |
+
height: 34px;
|
| 1179 |
+
background: #e53e3e;
|
| 1180 |
+
border: none;
|
| 1181 |
+
color: #fff;
|
| 1182 |
+
border-radius: 50%;
|
| 1183 |
+
cursor: pointer;
|
| 1184 |
+
display: flex;
|
| 1185 |
+
align-items: center;
|
| 1186 |
+
justify-content: center;
|
| 1187 |
+
transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
|
| 1188 |
+
flex-shrink: 0;
|
| 1189 |
+
box-shadow: 0 2px 8px rgba(229, 62, 62, 0.4);
|
| 1190 |
+
}
|
| 1191 |
+
.stop-btn:hover { background: #c53030; box-shadow: 0 4px 12px rgba(229, 62, 62, 0.5); }
|
| 1192 |
+
.stop-btn:active { transform: scale(0.95); }
|
| 1193 |
+
|
| 1194 |
.input-footer {
|
| 1195 |
text-align: center;
|
| 1196 |
font-size: 0.7rem;
|
web/src/App.tsx
CHANGED
|
@@ -658,6 +658,15 @@ function App() {
|
|
| 658 |
}
|
| 659 |
}, [responseComplete]);
|
| 660 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 661 |
const handleSendMessage = async () => {
|
| 662 |
if (!input.trim() || isLoading) return;
|
| 663 |
|
|
@@ -1711,16 +1720,28 @@ function App() {
|
|
| 1711 |
>
|
| 1712 |
{selectedModel === 'deepseek-chat' ? 'V3' : 'R1'}
|
| 1713 |
</button>
|
| 1714 |
-
|
| 1715 |
-
|
| 1716 |
-
|
| 1717 |
-
|
| 1718 |
-
|
| 1719 |
-
|
| 1720 |
-
|
| 1721 |
-
|
| 1722 |
-
|
| 1723 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1724 |
</div>
|
| 1725 |
</div>
|
| 1726 |
<div className="input-footer">Press Enter to send 路 Shift+Enter for new line</div>
|
|
|
|
| 658 |
}
|
| 659 |
}, [responseComplete]);
|
| 660 |
|
| 661 |
+
const handleStopGeneration = () => {
|
| 662 |
+
if (abortControllerRef.current) {
|
| 663 |
+
abortControllerRef.current.abort();
|
| 664 |
+
abortControllerRef.current = null;
|
| 665 |
+
}
|
| 666 |
+
setIsLoading(false);
|
| 667 |
+
setStatusMessage('');
|
| 668 |
+
};
|
| 669 |
+
|
| 670 |
const handleSendMessage = async () => {
|
| 671 |
if (!input.trim() || isLoading) return;
|
| 672 |
|
|
|
|
| 1720 |
>
|
| 1721 |
{selectedModel === 'deepseek-chat' ? 'V3' : 'R1'}
|
| 1722 |
</button>
|
| 1723 |
+
{isLoading ? (
|
| 1724 |
+
<button
|
| 1725 |
+
onClick={handleStopGeneration}
|
| 1726 |
+
className="stop-btn"
|
| 1727 |
+
title="Stop generation"
|
| 1728 |
+
>
|
| 1729 |
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor">
|
| 1730 |
+
<rect x="4" y="4" width="16" height="16" rx="2"/>
|
| 1731 |
+
</svg>
|
| 1732 |
+
</button>
|
| 1733 |
+
) : (
|
| 1734 |
+
<button
|
| 1735 |
+
onClick={handleSendMessage}
|
| 1736 |
+
disabled={!input.trim()}
|
| 1737 |
+
className="send-btn"
|
| 1738 |
+
title="Send (Enter)"
|
| 1739 |
+
>
|
| 1740 |
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
| 1741 |
+
<path d="M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
| 1742 |
+
</svg>
|
| 1743 |
+
</button>
|
| 1744 |
+
)}
|
| 1745 |
</div>
|
| 1746 |
</div>
|
| 1747 |
<div className="input-footer">Press Enter to send 路 Shift+Enter for new line</div>
|