라이어 게임: "입력 중…" 표시를 오른쪽 상태 줄에서 토론 채팅 칸 안(입력칸 바로 위)으로

- GameUI.typingInChat: 게임 채팅 칸이 입력 중 표시를 맡고, 상태 줄은 컴퓨터 "생각 중"만 보인다
- BotActivity: only='thinking', hide(설명 차례인 컴퓨터는 채팅이 아니라 설명을 치는 중이라 빼기)
- e2e: 토론 중 입력하면 다른 사람 화면의 토론 채팅 칸 안에만 "입력 중"이 보이는지 확인

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-18 01:25:13 +09:00
parent fcc79f05bc
commit 03e0e8ed84
5 changed files with 23 additions and 5 deletions

View File

@@ -3,14 +3,15 @@ import { useRoom } from '../net/socket';
/**
* What the computers are doing right now (docs/06 §12.1): "🤖 컴퓨터 1 생각 중…", "💬 컴퓨터 2 입력 중…", and people
* typing ("💬 고양이 입력 중…", `ch`: the room chat or the game's own public chat).
* typing ("💬 고양이 입력 중…", `ch`: the room chat or the game's own public chat). `hide`: ids left out (라이어 게임:
* the computer typing its description is not typing in the chat).
* Not announced to screen readers: the chat line or the move that follows is.
*/
export function BotActivity({ room, only, ch }: { room: RoomView; only?: 'typing'; ch?: 'room' | 'game' }) {
export function BotActivity({ room, only, ch, hide }: { room: RoomView; only?: 'typing' | 'thinking'; ch?: 'room' | 'game'; hide?: string[] }) {
const typing = useRoom((s) => s.typing);
const me = useRoom((s) => s.me?.id);
const entries = Object.entries(room.botActivity ?? {}).filter(([, a]) => !only || a === only);
const people = ch ? Object.entries(typing).filter(([id, t]) => t.ch === ch && id !== me) : [];
const entries = Object.entries(room.botActivity ?? {}).filter(([id, a]) => (!only || a === only) && !hide?.includes(id));
const people = ch && only !== 'thinking' ? Object.entries(typing).filter(([id, t]) => t.ch === ch && id !== me && !hide?.includes(id)) : [];
if (!entries.length && !people.length) return null;
const name = (id: string, fallback: string) =>
room.seats.find((s) => s?.user.id === id)?.user.nickname ?? room.spectators.find((u) => u.id === id)?.nickname ?? fallback;

View File

@@ -16,6 +16,8 @@ import { cssEsc, useBanner, type BannerTone } from '../card-fx';
import { ChatMessage, nameHue, sameRun } from '../../components/ChatMessage';
import { useStickToBottom } from '../../lib/useStickToBottom';
import { keepFocus, useTypingSignal } from '../../lib/chat-input';
import { useRoom } from '../../net/socket';
import { BotActivity } from '../../components/BotActivity';
import type { BoardProps, GameUI, OptionsProps } from '../types';
import { helpNow } from './help';
import { quickStart } from './quick';
@@ -116,6 +118,7 @@ button.lg-tile { cursor: pointer; }
.lg-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--border); flex-wrap: nowrap; }
.lg-form .input { flex: 1; min-height: 44px; min-width: 0; }
.lg-actions .lg-form { padding: 0; border: 0; }
.lg-chat .bot-activity { padding: 4px 10px 0; }
.lg-why { padding: 8px 10px; border-top: 1px solid var(--border); font-size: .88rem; color: var(--text-sub); font-weight: 600; margin: 0; }
.lg-big { display: flex; flex-wrap: wrap; gap: 8px; }
.lg-big .btn { flex: 1 1 auto; min-height: 52px; }
@@ -434,6 +437,8 @@ function ChatBox({ v, players, me, act }: { v: LiarView; players: Record<string,
].sort((a, b) => a.at - b.at || (a.k === b.k ? 0 : a.k === 'sys' ? -1 : 1));
const canWrite = !!v.my?.canChat;
const typing = useTypingSignal('game', canWrite);
// Who is typing sits right above the input, inside the chat (not on the status row: `typingInChat`).
const room = useRoom((s) => s.room);
const inputRef = useRef<HTMLInputElement>(null);
const why = !me || !v.my ? '관전 중에는 채팅을 쓸 수 없어요.' : (v.my.chatWhy ?? '');
return (
@@ -453,6 +458,7 @@ function ChatBox({ v, players, me, act }: { v: LiarView; players: Record<string,
),
)}
</div>
{room && <BotActivity room={room} only="typing" ch="game" hide={v.phase.kind === 'describe' && v.phase.speaker ? [v.phase.speaker] : undefined} />}
{canWrite ? (
<form
className="lg-form"
@@ -1051,6 +1057,7 @@ const ui: GameUI<LiarView, LiarOptions> = {
quickStart,
helpNow,
ownChat: true,
typingInChat: true,
};
export default ui;

View File

@@ -39,6 +39,8 @@ export interface GameUI<V = any, O = any> {
Rules: ComponentType<{ options?: O }>;
/** The board has its own chat channels; the room chat panel is hidden while the game runs (마피아). */
ownChat?: boolean;
/** The board's chat box shows who is typing in it ("입력 중…"); the status row then shows only the computers thinking (라이어 게임). */
typingInChat?: boolean;
/** 30초 규칙 요약: 3 cards shown the first time this device plays the game (docs/07 §5). */
quickStart?: QuickCard[];
/** [?] "지금 할 수 있는 것": the current situation in plain words for this viewer (docs/07 §5). */

View File

@@ -710,7 +710,7 @@ function GameView({ room, ui, me, players, pending, slow }: { room: RoomView; ui
{status}
<GameHelp room={room} ui={ui} title={gameName(room.gameId)} me={me.id} players={players} />
</div>
<BotActivity room={room} ch={ui.ownChat ? 'game' : undefined} />
{ui.typingInChat ? <BotActivity room={room} only="thinking" /> : <BotActivity room={room} ch={ui.ownChat ? 'game' : undefined} />}
{room.status === 'paused' && room.hostId === me.id && (
<button className="btn btn-danger btn-block" onClick={() => socket.send({ t: 'void' })}>
⏹ 게임 끝내기(무효)

View File

@@ -3061,6 +3061,14 @@ const PLANS: Record<string, Plan> = {
for (const p of pages) await liarBanner(p, '자유 토론');
const citizen = (L + 1) % 3;
await pages[citizen]!.getByLabel('토론 채팅 메시지').fill(`${LIAR_NICKS[L]}님이 수상해요`);
{
// "입력 중…" shows inside the 토론 chat box, not on the status row.
const other = pages[(citizen + 1) % 3]!;
await other.locator('.lg-chat .bot-activity [data-person]', { hasText: `${LIAR_NICKS[citizen]} 입력 중` }).waitFor({ timeout: 10_000 });
const outside = await other.locator('.bot-activity [data-person]').evaluateAll((els) => els.filter((e) => !e.closest('.lg-chat')).length);
if (outside) throw new Error('"입력 중" is shown outside the 토론 chat');
await other.locator('.lg-chat').screenshot({ path: join(SHOTS, 'liar-typing.png') });
}
await pages[citizen]!.getByLabel('토론 채팅 메시지').press('Enter');
for (const p of pages) await p.locator('.lg-msgs .lg-msg', { hasText: '님이 수상해요' }).waitFor({ timeout: 15_000 });
{