Skip to content

Commit af5c493

Browse files
committed
fix: show user message immediately before LLM processing
Display inbound chat message as soon as received, not bundled with reply. Replaces chatExchange (same-timestamp pair) with separate chatMessage calls.
1 parent 190f51c commit af5c493

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/manager.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,11 @@ export class Manager {
153153
* Fetches context, calls LLM, executes actions, returns reply.
154154
*/
155155
async handleWsMessage(content: string): Promise<{ reply: string; proposals?: Array<Record<string, string>> }> {
156+
ui.chatMessage("user", "manager", content);
156157
const context = await this.fetchContext();
157158
const { reply, actions, proposals } = await this.think(content, context);
158159
await this.executeActions(actions, context);
159-
ui.chatExchange("user", content, reply, actions.length, "ws");
160+
ui.chatMessage("manager", "user", reply);
160161
await this.advanceLastSeen();
161162
return { reply, proposals };
162163
}
@@ -192,6 +193,9 @@ export class Manager {
192193
for (const msg of newMessages) {
193194
const isFromUser = msg.from === "user" || msg.from.startsWith("user:");
194195

196+
// Show inbound message immediately before processing
197+
ui.chatMessage(msg.from, "manager", msg.content);
198+
195199
try {
196200
const senderContext = isFromUser
197201
? `[Message from user: ${msg.from}]`
@@ -208,10 +212,9 @@ export class Manager {
208212
this.onProposals?.(proposals);
209213
}
210214
}
211-
// Compact log: inbound + reply on two lines
212-
ui.chatExchange(msg.from, msg.content, reply, actions.length);
215+
ui.chatMessage("manager", msg.from, reply);
213216
} catch (err) {
214-
ui.chatExchange(msg.from, msg.content, `Error: ${err}`, 0);
217+
ui.chatMessage("manager", msg.from, `Error: ${err}`);
215218
await this.postReplyTo(msg.from, "Sorry, an error occurred while processing your message. Please try again.").catch(() => {});
216219
}
217220

0 commit comments

Comments
 (0)