Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qjclaw-dmg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AI-甘富林
qjclaw-dmg
Commits
5ce517c7
Commit
5ce517c7
authored
May 18, 2026
by
edy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(ui): clear completed assistant stream state
parent
bdb82411
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
8 deletions
+68
-8
chat-utils.ts
apps/ui/src/lib/chat-utils.ts
+12
-8
chatUtils.test.ts
apps/ui/test/chatUtils.test.ts
+55
-0
tsconfig.json
apps/ui/tsconfig.json
+1
-0
No files found.
apps/ui/src/lib/chat-utils.ts
View file @
5ce517c7
...
...
@@ -5,7 +5,7 @@ import {
COMPOSER_TEXTAREA_MAX_RATIO
,
COMPOSER_TEXTAREA_MIN_RATIO
,
COMPOSER_TEXTAREA_SAFE_MIN_HEIGHT
}
from
"./constants"
}
from
"./constants
.ts
"
export
type
MessageStreamState
=
"streaming"
|
"error"
...
...
@@ -92,14 +92,18 @@ export function mergeSessionHistory(current: UiChatMessage[], nextMessages: UiCh
return
message
}
return
{
...
message
,
content
:
local
.
content
.
length
>
message
.
content
.
length
?
local
.
content
:
message
.
content
,
createdAt
:
message
.
createdAt
||
local
.
createdAt
,
streamState
:
local
.
streamState
??
message
.
streamState
,
statusLabel
:
local
.
statusLabel
??
message
.
statusLabel
,
statusDetail
:
local
.
statusDetail
??
message
.
statusDetail
if
(
local
.
streamState
===
"streaming"
&&
local
.
content
.
length
>
message
.
content
.
length
)
{
return
{
...
message
,
content
:
local
.
content
,
createdAt
:
message
.
createdAt
||
local
.
createdAt
,
streamState
:
local
.
streamState
??
message
.
streamState
,
statusLabel
:
local
.
statusLabel
??
message
.
statusLabel
,
statusDetail
:
local
.
statusDetail
??
message
.
statusDetail
}
}
return
message
})
const
nextIds
=
new
Set
(
nextMessages
.
map
((
message
)
=>
message
.
id
))
const
localOnlyMessages
=
current
.
filter
((
message
)
=>
!
nextIds
.
has
(
message
.
id
))
...
...
apps/ui/test/chatUtils.test.ts
0 → 100644
View file @
5ce517c7
import
test
from
"node:test"
import
assert
from
"node:assert/strict"
import
type
{
UiChatMessage
}
from
"../src/lib/chat-utils.ts"
import
{
mergeSessionHistory
}
from
"../src/lib/chat-utils.ts"
test
(
"mergeSessionHistory clears local assistant transient state when server has final content"
,
()
=>
{
const
current
:
UiChatMessage
[]
=
[{
id
:
"assistant-1"
,
role
:
"assistant"
,
content
:
"Final answer"
,
createdAt
:
"2026-05-18T08:00:00.000Z"
,
streamState
:
"streaming"
,
statusLabel
:
"Thinking"
,
statusDetail
:
"Using tools"
}]
const
nextMessages
:
UiChatMessage
[]
=
[{
id
:
"assistant-1"
,
role
:
"assistant"
,
content
:
"Final answer"
,
createdAt
:
"2026-05-18T08:00:01.000Z"
}]
const
[
message
]
=
mergeSessionHistory
(
current
,
nextMessages
)
assert
.
equal
(
message
.
content
,
"Final answer"
)
assert
.
equal
(
message
.
streamState
,
undefined
)
assert
.
equal
(
message
.
statusLabel
,
undefined
)
assert
.
equal
(
message
.
statusDetail
,
undefined
)
})
test
(
"mergeSessionHistory preserves active local streaming state when server content is stale"
,
()
=>
{
const
current
:
UiChatMessage
[]
=
[{
id
:
"assistant-1"
,
role
:
"assistant"
,
content
:
"Streaming answer with more text"
,
createdAt
:
"2026-05-18T08:00:00.000Z"
,
streamState
:
"streaming"
,
statusLabel
:
"Thinking"
,
statusDetail
:
"Drafting"
}]
const
nextMessages
:
UiChatMessage
[]
=
[{
id
:
"assistant-1"
,
role
:
"assistant"
,
content
:
"Streaming answer"
,
createdAt
:
"2026-05-18T08:00:01.000Z"
}]
const
[
message
]
=
mergeSessionHistory
(
current
,
nextMessages
)
assert
.
equal
(
message
.
content
,
"Streaming answer with more text"
)
assert
.
equal
(
message
.
streamState
,
"streaming"
)
assert
.
equal
(
message
.
statusLabel
,
"Thinking"
)
assert
.
equal
(
message
.
statusDetail
,
"Drafting"
)
})
apps/ui/tsconfig.json
View file @
5ce517c7
...
...
@@ -3,6 +3,7 @@
"compilerOptions"
:
{
"module"
:
"ESNext"
,
"moduleResolution"
:
"Bundler"
,
"allowImportingTsExtensions"
:
true
,
"jsx"
:
"react-jsx"
,
"lib"
:
[
"ES2022"
,
"DOM"
,
"DOM.Iterable"
],
"types"
:
[
"vite/client"
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment