feat(chat): redesign chat UI with structured rendering and interactive action buttons
This commit is contained in:
@@ -179,6 +179,30 @@ async function handleWsMessage(ws, msg) {
|
||||
break;
|
||||
}
|
||||
|
||||
case 'click_action': {
|
||||
// 채팅 탭에서 Proceed/Cancel 등 버튼 클릭
|
||||
const session = sessionManager.getSession(msg.sessionId || state.activeSessionId);
|
||||
if (!session) {
|
||||
ws.send(JSON.stringify({ type: 'error', message: '활성 세션 없음' }));
|
||||
return;
|
||||
}
|
||||
|
||||
const { x, y } = msg;
|
||||
try {
|
||||
// mousePressed + mouseReleased = 클릭
|
||||
await session.client.dispatchInput({
|
||||
type: 'mouse', action: 'mousePressed', x, y, button: 'left', clickCount: 1,
|
||||
});
|
||||
await session.client.dispatchInput({
|
||||
type: 'mouse', action: 'mouseReleased', x, y, button: 'left', clickCount: 1,
|
||||
});
|
||||
ws.send(JSON.stringify({ type: 'action_clicked', success: true, label: msg.label }));
|
||||
} catch (err) {
|
||||
ws.send(JSON.stringify({ type: 'error', message: `버튼 클릭 실패: ${err.message}` }));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
ws.send(JSON.stringify({ type: 'error', message: `알 수 없는 메시지 타입: ${msg.type}` }));
|
||||
}
|
||||
@@ -188,12 +212,12 @@ async function handleWsMessage(ws, msg) {
|
||||
* 특정 세션의 CDP 채팅 폴링을 시작하고 결과를 ws 클라이언트에 전송
|
||||
*/
|
||||
function startSessionPolling(session, ws) {
|
||||
session.client.onChatUpdate = (html) => {
|
||||
session.client.onChatUpdate = (messages) => {
|
||||
if (ws.readyState === WebSocket.OPEN) {
|
||||
ws.send(JSON.stringify({
|
||||
type: 'chat_update',
|
||||
sessionId: session.id,
|
||||
html: html,
|
||||
messages: messages,
|
||||
timestamp: Date.now(),
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user