Revert "修复历史重读后旧消息追加到末尾的乱序"

This reverts commit 036395c6c9.
This commit is contained in:
2026-09-17 14:38:22 +08:00
parent d85622069d
commit dd339638cc
6 changed files with 3 additions and 46 deletions
+3 -4
View File
@@ -626,7 +626,7 @@ function claimInitialSupervisorMessageForPage(projectPath: string, scope = '') {
* **** messages latch user
* replace
*
* messages "非历史来源、运行时拥有、且回读结果里没有"
* messages "运行时拥有、且回读结果里没有"
*/
function mergeLoadedConversationWithPendingRuntimeMessages(
loaded: ChatMessage[],
@@ -644,7 +644,7 @@ function mergeLoadedConversationWithPendingRuntimeMessages(
loaded.map((message) => `${message.role}\u0000${message.text}`),
);
const pending = current.filter((message) => {
if (!message.runtimeOwned || message.fromHistory) {
if (!message.runtimeOwned) {
return false;
}
if (message.messageId) {
@@ -4202,7 +4202,7 @@ export function App({
const conversationMessages = mergeProjectSupervisorConversation(
resolvedProjectConversation.messages,
supervisorConversation?.messages ?? [],
).map((message) => ({ ...message, fromHistory: true }));
);
if (
conversationContainsProjectSupervisorResponseStream(
supervisorConversation?.messages ?? [],
@@ -12528,7 +12528,6 @@ export function App({
: ('assistant' as const),
text: message.content,
runtimeOwned: true,
fromHistory: true,
messageId: message.messageId,
updatedAt: message.updatedAt,
}));
@@ -999,8 +999,6 @@ export interface ChatMessage {
agentId?: string | null;
updatedAt?: number;
runtimeOwned?: boolean;
/** 来自历史回读,不作为尚未落盘的实时消息追加到新历史页末尾。 */
fromHistory?: boolean;
}
export type DesignAgentInput =
@@ -97,43 +97,6 @@ afterEach(() => {
});
describe('Direct 聊天历史分页集成', () => {
it('加载旧页后重读历史回到最新页,再翻页仍按原顺序且不重复', async () => {
const invoke = install((args) =>
args.beforeItemId
? page(messages.slice(0, 6), false)
: page(messages.slice(6), true),
);
mount();
await screen.findByText('历史正文 25');
fireEvent.click(earlier());
await screen.findByText('历史正文 0');
await setComposerText(screen.getByLabelText('陶泥儿对话内容'), '/history');
fireEvent.click(screen.getByRole('button', { name: '发送' }));
await act(async () => {
await Promise.resolve();
});
expect(screen.queryByText('历史正文 0')).toBeNull();
expect(screen.getByText('历史正文 25')).not.toBeNull();
fireEvent.click(earlier());
await screen.findByText('历史正文 0');
for (let index = 0; index < messages.length; index += 1) {
expect(screen.getAllByText(`历史正文 ${index}`)).toHaveLength(1);
if (index > 0) {
expect(
screen
.getByText(`历史正文 ${index - 1}`)
.compareDocumentPosition(screen.getByText(`历史正文 ${index}`)) &
Node.DOCUMENT_POSITION_FOLLOWING,
).not.toBe(0);
}
}
expect(
invoke.mock.calls.filter(
([command]) => command === 'read_direct_project_history_slice',
),
).toHaveLength(4);
});
it('首屏按消息加载20条,更早消息使用原生游标,原始工具记录不占页', async () => {
const invoke = install((args) =>
args.beforeItemId