fix: minor UI enhancements.
This commit is contained in:
@@ -34,18 +34,18 @@ const AssistantMessage: React.FC<AssistantMessageProps> = ({ content, isStreamin
|
|||||||
const renderContent = () => {
|
const renderContent = () => {
|
||||||
// Handle special abort link for streaming messages
|
// Handle special abort link for streaming messages
|
||||||
if (isStreaming && onAbort && content.includes('click here to abort')) {
|
if (isStreaming && onAbort && content.includes('click here to abort')) {
|
||||||
const hasProcessingWave = content.includes('<span class="processing-wave">Processing...</span>');
|
const hasProcessingWave = content.includes('<span class="processing-wave">Thinking...</span>');
|
||||||
|
|
||||||
if (hasProcessingWave) {
|
if (hasProcessingWave) {
|
||||||
const parts = content.split('click here to abort');
|
const parts = content.split('click here to abort');
|
||||||
const beforeAbort = parts[0].replace(
|
const beforeAbort = parts[0].replace(
|
||||||
'<span class="processing-wave">Processing...</span>',
|
'<span class="processing-wave">Thinking...</span>',
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
<span className="processing-wave">Processing...</span>
|
<span className="processing-wave">Thinking...</span>
|
||||||
{beforeAbort}
|
{beforeAbort}
|
||||||
<button onClick={onAbort} className="abort-link">
|
<button onClick={onAbort} className="abort-link">
|
||||||
click here to abort
|
click here to abort
|
||||||
|
|||||||
@@ -29,8 +29,9 @@ export const useStreamProcessor = (options: StreamProcessorOptions): StreamProce
|
|||||||
setAbortController(controller);
|
setAbortController(controller);
|
||||||
|
|
||||||
// Track the current streaming message ID (mutable)
|
// Track the current streaming message ID (mutable)
|
||||||
let currentStreamingId = createStreamingMessage().id;
|
const initialStreamingMsg = createStreamingMessage();
|
||||||
onMessageAdd({ id: currentStreamingId, role: 'assistant', content: '', isStreaming: true, tokenCount: 0 } as ChatMessage);
|
let currentStreamingId = initialStreamingMsg.id;
|
||||||
|
onMessageAdd(initialStreamingMsg);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const agentCore = AgentCore.instance();
|
const agentCore = AgentCore.instance();
|
||||||
@@ -54,7 +55,7 @@ export const useStreamProcessor = (options: StreamProcessorOptions): StreamProce
|
|||||||
|
|
||||||
onMessageUpdate(currentStreamingId, (msg) => ({
|
onMessageUpdate(currentStreamingId, (msg) => ({
|
||||||
...msg,
|
...msg,
|
||||||
content: `<span class="processing-wave">Processing...</span> ${tokenCount} tokens received. click here to abort.`,
|
content: `<span class="processing-wave">Thinking...</span>${tokenCount > 0 ? ` ${tokenCount} tokens received.` : ''} click here to abort.`,
|
||||||
tokenCount
|
tokenCount
|
||||||
}));
|
}));
|
||||||
} else if (chunk.type === 'tool_call' && chunk.toolCall) {
|
} else if (chunk.type === 'tool_call' && chunk.toolCall) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export const createMessage = (role: 'user' | 'assistant', content: string): Chat
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createStreamingMessage = (content: string = '<span class="processing-wave">Processing...</span> 0 tokens received. click here to abort.'): ChatMessage => {
|
export const createStreamingMessage = (content: string = '<span class="processing-wave">Thinking...</span> click here to abort.'): ChatMessage => {
|
||||||
return {
|
return {
|
||||||
id: generateMessageId(),
|
id: generateMessageId(),
|
||||||
role: 'assistant',
|
role: 'assistant',
|
||||||
|
|||||||
Reference in New Issue
Block a user