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:
@@ -220,18 +220,6 @@ export const chatMachine = setup({
|
||||
on: {
|
||||
ChatGuestLogin: "#chat.guestSession",
|
||||
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" },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user