From 57351fd9d67893c619cf436187c18bd3f95016bd Mon Sep 17 00:00:00 2001 From: EJClaw Date: Thu, 15 Oct 2026 10:25:06 +0900 Subject: [PATCH] =?UTF-8?q?=ED=9C=B4=EB=8C=80=ED=8F=B0=EC=97=90=EC=84=9C?= =?UTF-8?q?=20=EC=B1=84=ED=8C=85=EC=9D=84=20=EB=B3=B4=EB=82=B8=20=EB=92=A4?= =?UTF-8?q?=EC=97=90=EB=8F=84=20=ED=82=A4=EB=B3=B4=EB=93=9C=20=EC=9C=A0?= =?UTF-8?q?=EC=A7=80:=20"=EB=B3=B4=EB=82=B4=EA=B8=B0"=20=EB=B2=84=ED=8A=BC?= =?UTF-8?q?=EC=9D=84=20=EB=88=84=EB=A5=B4=EB=A9=B4=20=ED=8F=AC=EC=BB=A4?= =?UTF-8?q?=EC=8A=A4=EA=B0=80=20=EB=B2=84=ED=8A=BC=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=84=98=EC=96=B4=EA=B0=80=20=EC=9E=85=EB=A0=A5=20=EC=B9=B8?= =?UTF-8?q?=EC=9D=B4=20=EB=B9=A0=EC=A7=80=EA=B3=A0=20=ED=82=A4=EB=B3=B4?= =?UTF-8?q?=EB=93=9C=EA=B0=80=20=EB=82=B4=EB=A0=A4=EA=B0=80=EB=8D=98=20?= =?UTF-8?q?=EA=B2=83=EC=9D=84,=20=EB=B2=84=ED=8A=BC=EC=9D=98=20pointerdown?= =?UTF-8?q?/mousedown=20=EA=B8=B0=EB=B3=B8=20=EB=8F=99=EC=9E=91=EC=9D=84?= =?UTF-8?q?=20=EB=A7=89=EC=95=84(lib/chat-input=20keepFocus)=20=ED=8F=AC?= =?UTF-8?q?=EC=BB=A4=EC=8A=A4=EB=A5=BC=20=EC=9E=85=EB=A0=A5=20=EC=B9=B8?= =?UTF-8?q?=EC=97=90=20=EB=91=90=EA=B3=A0,=20=EB=B3=B4=EB=82=B8=20?= =?UTF-8?q?=EB=92=A4=EC=97=90=EB=8F=84=20=EC=9E=85=EB=A0=A5=20=EC=B9=B8?= =?UTF-8?q?=EC=97=90=20=ED=8F=AC=EC=BB=A4=EC=8A=A4=EB=A5=BC=20=EB=8B=A4?= =?UTF-8?q?=EC=8B=9C=20=EC=A4=8C.=20=EB=B0=A9=20=EC=B1=84=ED=8C=85(ChatPan?= =?UTF-8?q?el)=C2=B7=EA=B7=B8=EB=A6=BC=20=EB=A7=9E=ED=9E=88=EA=B8=B0=C2=B7?= =?UTF-8?q?=EB=A7=88=ED=94=BC=EC=95=84=C2=B7=EB=9D=BC=EC=9D=B4=EC=96=B4=20?= =?UTF-8?q?=EA=B2=8C=EC=9E=84=20=EC=B1=84=ED=8C=85=20=EB=AA=A8=EB=91=90.?= =?UTF-8?q?=20Esc=EB=A1=9C=20=EB=B9=A0=EC=A0=B8=EB=82=98=EA=B0=80=EA=B8=B0?= =?UTF-8?q?=EC=99=80=20=ED=8F=AC=EC=BB=A4=EC=8A=A4=EA=B0=80=20=EB=B9=A0?= =?UTF-8?q?=EC=A7=88=20=EB=95=8C=20"=EC=9E=85=EB=A0=A5=20=EC=A4=91"=20?= =?UTF-8?q?=EB=81=84=EA=B8=B0=EB=8A=94=20=EA=B7=B8=EB=8C=80=EB=A1=9C.=20ch?= =?UTF-8?q?at.e2e.ts(=ED=9C=B4=EB=8C=80=ED=8F=B0=20=EC=8B=9C=ED=8A=B8?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EB=B3=B4=EB=82=B4=EA=B8=B0=20=ED=83=AD)?= =?UTF-8?q?=EC=99=80=20games.e2e.ts(catchmind=C2=B7mafia=C2=B7liar=20?= =?UTF-8?q?=EB=B3=B4=EB=82=B4=EA=B8=B0=20=EB=B2=84=ED=8A=BC)=EC=97=90=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8=20=EC=B6=94=EA=B0=80,=20docs/07=EC=97=90=20?= =?UTF-8?q?=ED=95=9C=20=EC=A4=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/ChatPanel.tsx | 7 +++++-- apps/web/src/games/catchmind/index.tsx | 4 +++- apps/web/src/games/liar/index.tsx | 9 +++++++-- apps/web/src/games/mafia/index.tsx | 9 +++++++-- apps/web/src/lib/chat-input.ts | 8 +++++++- docs/07-ui-ux.md | 1 + e2e/chat.e2e.ts | 8 +++++++- e2e/games.e2e.ts | 24 +++++++++++++++++++++--- 8 files changed, 58 insertions(+), 12 deletions(-) diff --git a/apps/web/src/components/ChatPanel.tsx b/apps/web/src/components/ChatPanel.tsx index 7c43b9c..b8c901f 100644 --- a/apps/web/src/components/ChatPanel.tsx +++ b/apps/web/src/components/ChatPanel.tsx @@ -3,7 +3,7 @@ import { useEffect, useRef, useState } from 'react'; import { CHAT_MAX, EMOTE_LABEL, EMOTES, type PublicUser, type RoomView } from '@bg/shared/lite'; import { create } from 'zustand'; import { socket, useRoom } from '../net/socket'; -import { useTypingSignal } from '../lib/chat-input'; +import { keepFocus, useTypingSignal } from '../lib/chat-input'; import { useStickToBottom } from '../lib/useStickToBottom'; import { BotActivity } from './BotActivity'; import { ChatMessage, sameRun } from './ChatMessage'; @@ -70,6 +70,7 @@ export function ChatPanel({ room, me, title = true }: { room: RoomView; me: Publ setText(''); typing.stop(); pin(); + inputRef.current?.focus(); }} > - + ) : (

이 방은 채팅을 쓰지 않아요. 반응 버튼은 쓸 수 있어요.

diff --git a/apps/web/src/games/catchmind/index.tsx b/apps/web/src/games/catchmind/index.tsx index c1566e7..396dc70 100644 --- a/apps/web/src/games/catchmind/index.tsx +++ b/apps/web/src/games/catchmind/index.tsx @@ -5,6 +5,7 @@ import type { PublicUser, ServerMessage } from '@bg/shared/lite'; import { nameHue } from '../../components/ChatMessage'; import { Avatar } from '../../components/ui'; import { useServerNow } from '../../components/TurnTimer'; +import { keepFocus } from '../../lib/chat-input'; import { haptic, noise, sfx, sounds, tone } from '../../lib/feedback'; import { useWide } from '../../lib/media'; import { socket } from '../../net/socket'; @@ -1005,6 +1006,7 @@ function GuessPanel({ v, me, players, act, pending }: { v: CatchmindView; me: st if (!t || !enabled) return; act(v.canGuess ? { type: 'guess', text: t.slice(0, max) } : { type: 'chat', text: t.slice(0, max) }); setText(''); + inputRef.current?.focus(); }} > e.key === 'Escape' && e.currentTarget.blur()} /> - diff --git a/apps/web/src/games/liar/index.tsx b/apps/web/src/games/liar/index.tsx index f7f8244..f228e8a 100644 --- a/apps/web/src/games/liar/index.tsx +++ b/apps/web/src/games/liar/index.tsx @@ -15,7 +15,7 @@ import { haptic, sfx, sounds, tone, useChatSound } from '../../lib/feedback'; import { cssEsc, useBanner, type BannerTone } from '../card-fx'; import { ChatMessage, nameHue, sameRun } from '../../components/ChatMessage'; import { useStickToBottom } from '../../lib/useStickToBottom'; -import { useTypingSignal } from '../../lib/chat-input'; +import { keepFocus, useTypingSignal } from '../../lib/chat-input'; import type { BoardProps, GameUI, OptionsProps } from '../types'; import { helpNow } from './help'; import { quickStart } from './quick'; @@ -435,6 +435,7 @@ function ChatBox({ v, players, me, act }: { v: LiarView; players: Record(null); const why = !me || !v.my ? '관전 중에는 채팅을 쓸 수 없어요.' : talk ? (v.my.chatWhy ?? '') : v.phase.kind === 'describe' ? '토론 채팅은 설명이 다 끝나면 열려요.' : (v.my.chatWhy ?? ''); return (
@@ -464,9 +465,11 @@ function ChatBox({ v, players, me, act }: { v: LiarView; players: Record { @@ -479,7 +482,9 @@ function ChatBox({ v, players, me, act }: { v: LiarView; players: Record - + ) : ( why &&

{why}

diff --git a/apps/web/src/games/mafia/index.tsx b/apps/web/src/games/mafia/index.tsx index 52bf46e..f0f22cd 100644 --- a/apps/web/src/games/mafia/index.tsx +++ b/apps/web/src/games/mafia/index.tsx @@ -15,7 +15,7 @@ import { haptic, noise, sfx, sounds, tone, useChatSound } from '../../lib/feedba import { useBanner, type BannerTone } from '../card-fx'; import { ChatMessage, sameRun } from '../../components/ChatMessage'; import { useStickToBottom } from '../../lib/useStickToBottom'; -import { useTypingSignal } from '../../lib/chat-input'; +import { keepFocus, useTypingSignal } from '../../lib/chat-input'; import type { BoardProps, GameUI, OptionsProps } from '../types'; import { helpNow } from './help'; import { quickStart } from './quick'; @@ -485,6 +485,7 @@ function ChatBox({ v, players, me, act }: { v: MafiaView; players: Record(null); const why = ch ? ch.why : me ? '이 채팅은 읽기만 할 수 있어요.' : '관전 중에는 채팅을 쓸 수 없어요.'; const onTabKey = (e: KeyboardEvent) => { if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return; @@ -542,9 +543,11 @@ function ChatBox({ v, players, me, act }: { v: MafiaView; players: Record { @@ -557,7 +560,9 @@ function ChatBox({ v, players, me, act }: { v: MafiaView; players: Record - + ) : (

{why}

diff --git a/apps/web/src/lib/chat-input.ts b/apps/web/src/lib/chat-input.ts index f4a6153..4af09f7 100644 --- a/apps/web/src/lib/chat-input.ts +++ b/apps/web/src/lib/chat-input.ts @@ -4,8 +4,10 @@ * Chat lines are sent the moment Enter is pressed — no queue and no pace limit. * - `useTypingSignal`: tells the others "입력 중" while there is text in the box (renewed every 2 s, cleared when the * box is emptied or the line is sent, and when the box goes away). + * - `keepFocus`: props for the send button so pressing it leaves the focus in the chat box — on phones the keyboard + * stays up after sending, like with the keyboard's own send key (catchmind uses it too). */ -import { useCallback, useEffect, useRef } from 'react'; +import { useCallback, useEffect, useRef, type SyntheticEvent } from 'react'; import { socket } from '../net/socket'; const RENEW_MS = 2000; @@ -36,3 +38,7 @@ export function useTypingSignal(ch: 'room' | 'game', enabled = true) { useEffect(() => stop, [stop]); return { onText, stop }; } + +/** Spread on a chat form's send button: pressing it doesn't move the focus off the input (the phone keyboard stays up). */ +const noFocus = (e: SyntheticEvent) => e.preventDefault(); +export const keepFocus = { onPointerDown: noFocus, onMouseDown: noFocus }; diff --git a/docs/07-ui-ux.md b/docs/07-ui-ux.md index e80e7c8..d5c1815 100644 --- a/docs/07-ui-ux.md +++ b/docs/07-ui-ux.md @@ -117,6 +117,7 @@ - 방 안(대기실·게임·결과)에서는 사이트 상단 메뉴를 숨기고 방 막대(← 홈 · 게임 이름 · 🔗 방 코드 · 📖 규칙 · ⚙️ 설정 · 🚪 나가기) 한 줄만 둔다. 판이 그만큼 커진다. 높이 계산은 CSS 변수 `--site-h`(방 안에서는 0)를 쓴다. - 채팅의 빠른 반응(이모지·짧은 말)은 한 줄. 넘치면 옆으로 밀어 본다. - 채팅 한 줄은 이름(작은 글씨, 사람마다 다른 색)과 말풍선(내용)을 위아래로 나눠 보여 준다. 내 말은 오른쪽, 같은 사람이 이어서 말하면 이름은 한 번만. 목록은 늘 맨 아래(새 말)에 붙어 있고, 위로 올려 읽는 중에는 움직이지 않다가 내가 보내거나 아래로 내려오면 다시 붙는다(2026-10-13). 사람별 채팅 가리기는 없앴다(사용자 요청, 2026-10-13. 필요하면 방장이 내보내기). +- 채팅을 보낸 뒤에도 입력 칸 포커스를 그대로 둔다. 휴대폰에서 "보내기" 버튼을 눌러도 키보드가 내려가지 않는다(버튼을 누를 때 포커스를 가져가지 않음, `keepFocus`). 방 채팅·그림 맞히기·마피아·라이어 게임 채팅 모두 같다(사용자 요청, 2026-10-15). - 결과 창: 진한 버튼은 [🔁 한 판 더] 하나(누르면 그 방 대기실로 돌아간다, docs/06 §결과). [판 보기]·[▶ 다시 보기]는 한 줄에 나란히, [방 나가기]는 글자 버튼, 공정성 확인은 접어 둔다. ### 3.6 관리자 (PC) diff --git a/e2e/chat.e2e.ts b/e2e/chat.e2e.ts index fde628a..1535cd4 100644 --- a/e2e/chat.e2e.ts +++ b/e2e/chat.e2e.ts @@ -204,7 +204,7 @@ try { await sheet.getByRole('button', { name: '닫기' }).click(); }); - await step('휴대폰 채팅 시트: 새 메시지가 와도 입력 칸 포커스(키보드)가 그대로', async () => { + await step('휴대폰 채팅 시트: 새 메시지가 와도, 보내기를 눌러도 입력 칸 포커스(키보드)가 그대로', async () => { await b.getByRole('button', { name: /^채팅/ }).click(); const sheet = b.getByRole('dialog', { name: '채팅' }); const input = sheet.locator('input[aria-label="메시지"]'); @@ -220,6 +220,12 @@ try { await input.press('Enter'); await sheet.locator('.chat-line', { hasText: '치는 중 계속' }).waitFor(); if (!(await input.evaluate((el) => el === document.activeElement))) throw new Error('the chat box lost focus after sending'); + // Tapping 보내기 (not the keyboard's send key) must not take the focus either, or the phone keyboard drops. + await input.pressSequentially('버튼으로 보냄'); + await sheet.getByRole('button', { name: '보내기' }).tap(); + await sheet.locator('.chat-line', { hasText: '버튼으로 보냄' }).waitFor(); + await b.waitForTimeout(150); + if (!(await input.evaluate((el) => el === document.activeElement))) throw new Error('the chat box lost focus after tapping 보내기'); await sheet.getByRole('button', { name: '닫기' }).click(); }); diff --git a/e2e/games.e2e.ts b/e2e/games.e2e.ts index 9e07b91..b7ceb39 100644 --- a/e2e/games.e2e.ts +++ b/e2e/games.e2e.ts @@ -4,7 +4,7 @@ * the keyboard (role="grid" boards support arrows + Enter) and reach the opponent. * Run: bun e2e/games.e2e.ts [gameId...] (needs apps/web/dist built) */ -import { chromium, type Page } from 'playwright-core'; +import { chromium, type Locator, type Page } from 'playwright-core'; import { mkdirSync, mkdtempSync } from 'node:fs'; import { join } from 'node:path'; import { loadConfig } from '../apps/server/src/config'; @@ -929,8 +929,8 @@ async function catchmindTurn(pages: Page[], turn: number, shots: boolean): Promi await input.fill(text); await input.press('Enter'); }; - // Wrong guess: visible to the drawer too. - await send('모르겠어요'); + // Wrong guess (with the 맞히기 button; the box keeps the focus): visible to the drawer too. + await sendByButton(guesser, input, guesser.locator('.cm-form button'), '모르겠어요'); await drawer.locator('.cm-chat-list').getByText('모르겠어요').first().waitFor(); // Close guess (last syllable's final consonant changed): "아까워요" for the guesser only. const close = await guesser.evaluate((w) => { @@ -980,6 +980,17 @@ async function mafiaPick(p: Page, nick: string) { await p.locator('button.mf-tile[aria-pressed="true"]', { has: p.locator('.nm', { hasText: new RegExp(`^${nick}( \\(나\\))?$`) }) }).waitFor({ timeout: 15_000 }); } +/** Game chat box: sends a line with its button (a tap on phones) and checks the box keeps the focus (phone keyboard stays up). */ +async function sendByButton(p: Page, box: Locator, button: Locator, text: string) { + await box.click(); + await box.fill(text); + if (await p.evaluate(() => 'ontouchstart' in window)) await button.tap(); + else await button.click(); + await p.waitForFunction((el) => (el as HTMLInputElement).value === '', await box.elementHandle(), { timeout: 5000 }); + await p.waitForTimeout(150); + if (!(await box.evaluate((el) => el === document.activeElement))) throw new Error(`the chat box lost focus after pressing the send button ("${text}")`); +} + /** 마피아: writes in the selected channel tab and waits until the line shows up. */ async function mafiaSay(p: Page, channel: '전체' | '마피아' | '죽은 사람', text: string) { await p.getByRole('tab', { name: new RegExp(`^${channel} 채팅`) }).click(); @@ -2744,6 +2755,11 @@ const PLANS: Record = { await pages[citizen]!.getByLabel('토론 채팅 메시지').fill(`${LIAR_NICKS[L]}님이 수상해요`); await pages[citizen]!.getByLabel('토론 채팅 메시지').press('Enter'); for (const p of pages) await p.locator('.lg-msgs .lg-msg', { hasText: '님이 수상해요' }).waitFor({ timeout: 15_000 }); + { + const ph = pages[citizen === 1 ? 2 : 1]!; // a phone + await sendByButton(ph, ph.getByLabel('토론 채팅 메시지'), ph.locator('.lg-form').getByRole('button', { name: '보내기' }), '버튼으로 보낸 말'); + for (const p of pages) await p.locator('.lg-msgs .lg-msg', { hasText: '버튼으로 보낸 말' }).waitFor({ timeout: 15_000 }); + } await liarShots(pages, '3-discussion', true); await liarClean('discussion'); for (const p of pages) await p.getByRole('button', { name: /^토론 끝내기/ }).click(); @@ -2804,6 +2820,8 @@ const PLANS: Record = { await mafiaBanner(host, '인사 시간'); await mafiaSay(phone, '전체', '안녕하세요 반가워요'); + await sendByButton(phone, phone.getByLabel('전체 채팅 메시지'), phone.locator('.mf-form').getByRole('button', { name: '보내기' }), '버튼으로 보낸 인사'); + for (const p of pages) await p.locator('.mf-msgs .mf-msg', { hasText: '버튼으로 보낸 인사' }).waitFor({ timeout: 15_000 }); for (const p of pages) await p.locator('.mf-msgs .mf-msg', { hasText: '안녕하세요 반가워요' }).waitFor({ timeout: 15_000 }); // No chat pace limit: 15 lines typed back to back all show up right away, in order, on every screen. {