chore(chat): clean up legacy state machine and fix bubble alignment

- Remove redundant `loadingMoreHistory` and `ready` states from chat machine, consolidating history loading flow
- Add `align-self: flex-start` to chat row container for proper alignment
- Clean up commented-out margin rules in text bubble styles
- Update deploy script GIT_REMOTE from "server" to "test"
This commit is contained in:
2026-06-12 11:59:34 +08:00
parent a9938b8dae
commit 57992bffac
4 changed files with 2 additions and 83 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
# Git remote 名(在仓库根目录配置): # Git remote 名(在仓库根目录配置):
# git remote add server root@8.166.137.51:/root/frontend/cozsweet # git remote add server root@8.166.137.51:/root/frontend/cozsweet
GIT_REMOTE="server" GIT_REMOTE="test"
# 推送指定分支到服务器 # 推送指定分支到服务器
# 期望服务器端 post-receive hook 已就位;本脚本只做 git push,不负责构建/启动 # 期望服务器端 post-receive hook 已就位;本脚本只做 git push,不负责构建/启动
@@ -39,6 +39,7 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: flex-start; align-items: flex-start;
align-self: flex-start;
gap: var(--spacing-1, 4px); gap: var(--spacing-1, 4px);
} }
@@ -17,8 +17,6 @@
background: #fff; background: #fff;
color: var(--color-text-foreground, #000); color: var(--color-text-foreground, #000);
border-top-left-radius: 0; border-top-left-radius: 0;
/* 气泡在头像侧的外侧留白 */
/* margin-left: var(--spacing-4, 16px); */
} }
.bubbleUser { .bubbleUser {
@@ -29,6 +27,4 @@
); );
color: #fff; color: #fff;
border-top-right-radius: 0; border-top-right-radius: 0;
/* 气泡在头像侧的外侧留白 */
/* margin-right: var(--spacing-4, 16px); */
} }
-78
View File
@@ -220,18 +220,6 @@ export const chatMachine = setup({
on: { on: {
ChatGuestLogin: "#chat.guestSession", ChatGuestLogin: "#chat.guestSession",
ChatNonGuestLogin: "#chat.userSession", ChatNonGuestLogin: "#chat.userSession",
ChatLoadMoreHistory: {
actions: [
"logLoadMoreHistoryReceived",
({ context }) =>
console.log("[chat-machine] idle.ChatLoadMoreHistory received (but no UI dispatcher)", {
currentOffset: context.historyOffset,
hasMore: context.hasMore,
isLoadingMore: context.isLoadingMore,
}),
],
target: "loadingMoreHistory",
},
}, },
}, },
@@ -522,72 +510,6 @@ export const chatMachine = setup({
}, },
}, },
}, },
loadingMoreHistory: {
entry: ({ context }) =>
console.log("[chat-machine] → loadingMoreHistory (legacy)", { offset: context.historyOffset }),
invoke: {
src: "loadMoreHistory",
input: ({ context }) => ({ offset: context.historyOffset }),
onDone: {
target: "ready",
actions: [
assign(({ context, event }) => ({
messages: [...event.output.messages, ...context.messages],
isLoadingMore: false,
hasMore: event.output.hasMore,
historyOffset: event.output.newOffset,
})),
({ event }) =>
console.log("[chat-machine] loadingMoreHistory.onDone", {
newMessagesCount: event.output.messages.length,
newOffset: event.output.newOffset,
hasMore: event.output.hasMore,
}),
],
},
onError: {
target: "ready",
actions: [
assign({ isLoadingMore: false }),
({ event }) =>
console.error("[chat-machine] loadingMoreHistory.onError", {
error: event.error instanceof Error ? event.error.message : String(event.error),
}),
],
},
},
},
ready: {
on: {
ChatSendMessage: {
actions: ["logSendMessageReceived", "appendUserMessage"],
guard: ({ event }) => event.content.trim().length > 0,
},
ChatSendImage: {
actions: ["logSendImageReceived", "appendUserImage"],
},
ChatLoadMoreHistory: {
actions: [
"logLoadMoreHistoryReceived",
({ context }) =>
console.log("[chat-machine] ready.ChatLoadMoreHistory received (legacy ready)", {
currentOffset: context.historyOffset,
hasMore: context.hasMore,
}),
],
target: "loadingMoreHistory",
},
ChatLogout: "#chat.idle",
ChatGuestLogin: "#chat.guestSession",
ChatNonGuestLogin: "#chat.userSession",
ChatAISentenceReceived: { actions: "appendOrUpdateAISentence" },
ChatWebSocketError: { actions: "appendSocketErrorMessage" },
ChatWebSocketConnected: { actions: "setWsConnected" },
ChatQuotaExceeded: { actions: "incrementQuotaExceeded" },
},
},
}, },
}); });