fraudTech commited on
Commit
da8d860
·
1 Parent(s): ff9dc95

fixed thinking panel

Browse files
Files changed (1) hide show
  1. web/src/App.tsx +14 -5
web/src/App.tsx CHANGED
@@ -1093,6 +1093,7 @@ function App() {
1093
  let localThinkingContent = '';
1094
  let finalBuffer = '';
1095
  let toolsUsed = false;
 
1096
 
1097
  // RAF batching for content_chunk / reasoning_chunk.
1098
  // Accumulate text locally; flush to React state at most once per frame.
@@ -1325,21 +1326,25 @@ function App() {
1325
  prev.map((msg) => {
1326
  if (msg.id !== assistantId) return msg;
1327
  if (!toolsUsed) {
 
 
1328
  // Pure V3 response without tools – show as normal content,
1329
  // no Thinking panel needed.
1330
  return {
1331
  ...msg,
1332
- content: localThinkingContent,
1333
- thinkingContent: undefined,
1334
- thinkingExpanded: undefined,
1335
  isStreaming: false,
1336
  };
1337
  }
1338
  // R1: content chunks were already routed to msg.content during
1339
  // streaming — just clear any residual thinkingContent and stop.
1340
  if (isR1) {
 
1341
  return {
1342
  ...msg,
 
1343
  thinkingContent: undefined,
1344
  thinkingExpanded: undefined,
1345
  isStreaming: false,
@@ -1361,9 +1366,11 @@ function App() {
1361
  ? (thinkingBase + '\n\n' + preamble.trimEnd())
1362
  : (thinkingBase || undefined);
1363
 
 
 
1364
  return {
1365
  ...msg,
1366
- content: answer,
1367
  thinkingContent: newThinking || undefined,
1368
  thinkingExpanded: !!newThinking,
1369
  isStreaming: false,
@@ -1388,6 +1395,8 @@ function App() {
1388
  : msg
1389
  )
1390
  );
 
 
1391
  }
1392
  }
1393
  }
@@ -2049,4 +2058,4 @@ function App() {
2049
  );
2050
  }
2051
 
2052
- export default App;
 
1093
  let localThinkingContent = '';
1094
  let finalBuffer = '';
1095
  let toolsUsed = false;
1096
+ let serverFinalContent = '';
1097
 
1098
  // RAF batching for content_chunk / reasoning_chunk.
1099
  // Accumulate text locally; flush to React state at most once per frame.
 
1326
  prev.map((msg) => {
1327
  if (msg.id !== assistantId) return msg;
1328
  if (!toolsUsed) {
1329
+ const authoritative = serverFinalContent || localThinkingContent;
1330
+ const keepThinking = !!serverFinalContent && localThinkingContent.trim().length > 0;
1331
  // Pure V3 response without tools – show as normal content,
1332
  // no Thinking panel needed.
1333
  return {
1334
  ...msg,
1335
+ content: authoritative,
1336
+ thinkingContent: keepThinking ? localThinkingContent : undefined,
1337
+ thinkingExpanded: keepThinking ? true : undefined,
1338
  isStreaming: false,
1339
  };
1340
  }
1341
  // R1: content chunks were already routed to msg.content during
1342
  // streaming — just clear any residual thinkingContent and stop.
1343
  if (isR1) {
1344
+ const authoritative = serverFinalContent || msg.content || '';
1345
  return {
1346
  ...msg,
1347
+ content: authoritative,
1348
  thinkingContent: undefined,
1349
  thinkingExpanded: undefined,
1350
  isStreaming: false,
 
1366
  ? (thinkingBase + '\n\n' + preamble.trimEnd())
1367
  : (thinkingBase || undefined);
1368
 
1369
+ const authoritative = serverFinalContent || answer;
1370
+
1371
  return {
1372
  ...msg,
1373
+ content: authoritative,
1374
  thinkingContent: newThinking || undefined,
1375
  thinkingExpanded: !!newThinking,
1376
  isStreaming: false,
 
1395
  : msg
1396
  )
1397
  );
1398
+ } else if (event === 'response') {
1399
+ serverFinalContent = data.content || '';
1400
  }
1401
  }
1402
  }
 
2058
  );
2059
  }
2060
 
2061
+ export default App;