v1.3.7: 기록 관리(경기 · 경기 전후 대화 묶음, 한 번에 지우기 · zip 내보내기/받아오기) · 검토로 찾은 오류 고침

- 기록 묶음 API · zip 형식(gvr-bundle v1) · 받아오기 검사(꼭 필요한 내용이 없으면 실패, 아무것도 넣지 않음)
- 사이트 기록 탭, 큰 zip 조각 중계
- 관리자 확인 %인코딩 우회, 큰 전송 중 연결 끊김, 진행 중 경기 지우기, 예전 녹음 고치기 덮어쓰기,
  타임라인 끼워 넣기, 숫자 반복 줄이기, TTS 반쪽 파일 등

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-16 05:34:39 +09:00
parent c397bacf8c
commit 5d494eb8e8
36 changed files with 246 additions and 72 deletions

View File

@@ -164,7 +164,17 @@ export const api = {
/** 기록 묶음 (v1.3.7~ 앱) */
bundles: () => request<{ bundles: BundleInfo[] }>('/api/bundles').then((r) => r.bundles),
deleteBundles: (ids: string[]) => request<{ bundles: number; utterances: number; files: number }>('/api/bundles/delete', { method: 'POST', body: JSON.stringify({ ids }) }),
bundleExportUrl: (ids: string[]) => `/api/bundles/export?ids=${ids.map(encodeURIComponent).join(',')}`,
/** zip 내려받기 (많이 골라도 되게 본문으로 보낸다). 파일 이름은 앱이 정한 것 */
exportBundles: async (ids: string[]): Promise<{ blob: Blob; fileName: string }> => {
const res = await fetch('/api/bundles/export', { method: 'POST', credentials: 'include', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ ids }) });
if (!res.ok) {
const b = await res.json().catch(() => ({}));
if (res.status === 503) emit('device_offline');
throw new Error(b.message ?? `zip 을 받지 못했습니다 (${res.status})`);
}
const cd = res.headers.get('content-disposition') ?? '';
return { blob: await res.blob(), fileName: /filename="([^"]+)"/.exec(cd)?.[1] ?? 'gvr-records.zip' };
},
/** zip 받아오기. 실패하면 서버가 준 이유("받아오기 실패: …")를 담은 Error */
importBundle: async (file: Blob): Promise<BundleImportResult> => {
let res: Response;

View File

@@ -11,7 +11,7 @@ export function reportClient(level: 'warn' | 'error', message: string, detail?:
method: 'POST',
credentials: 'include',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ level, message: message.slice(0, 500), detail: detail?.slice(0, 2000), page: location.pathname + location.search }),
body: JSON.stringify({ level, message: message.slice(0, 500), detail: detail?.slice(0, 2000), page: location.pathname /* 검색어 등 쿼리는 남기지 않는다 */ }),
keepalive: true,
}).catch(() => undefined);
}

View File

@@ -60,15 +60,26 @@ export function RecordsPage() {
const picked = (list ?? []).filter((b) => sel.has(b.id));
const toggle = (id: string) => setSel((s) => (s.has(id) ? new Set([...s].filter((x) => x !== id)) : new Set([...s, id])));
const download = (ids: string[]) => {
const download = async (ids: string[]) => {
sfx('click');
const a = document.createElement('a');
a.href = api.bundleExportUrl(ids);
a.download = '';
document.body.appendChild(a);
a.click();
a.remove();
setMsg({ ok: true, text: `zip 을 만드는 중입니다. 묶음이 크면 내려받기가 시작될 때까지 조금 걸립니다.` });
setBusy('export');
setMsg({ ok: true, text: 'zip 을 만들어 받는 중입니다. 묶음이 크면 조금 걸립니다…' });
try {
const { blob, fileName } = await api.exportBundles(ids);
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = fileName;
document.body.appendChild(a);
a.click();
a.remove();
setTimeout(() => URL.revokeObjectURL(url), 30000);
setMsg({ ok: true, text: `${fileName} (${fmtMB(blob.size)}) 내려받기를 시작했습니다` });
} catch (e) {
setMsg({ ok: false, text: (e as Error).message });
} finally {
setBusy(null);
}
};
const doDelete = async (bs: BundleInfo[]) => {
setBusy('delete');
@@ -79,7 +90,7 @@ export function RecordsPage() {
setConfirm(null);
load();
} catch (e) {
setMsg({ ok: false, text: e instanceof ApiError && e.status === 403 ? '지우기는 관리자만 할 수 있습니다' : '지우지 못했습니다' });
setMsg({ ok: false, text: e instanceof ApiError && e.status === 403 ? '지우기는 관리자만 할 수 있습니다' : e instanceof ApiError && e.status === 409 ? '진행 중인 경기는 지울 수 없습니다 (경기가 끝난 뒤 지워 주세요)' : '지우지 못했습니다' });
} finally {
setBusy(null);
}
@@ -155,11 +166,11 @@ export function RecordsPage() {
<span className="dim">
발화 {picked.reduce((n, b) => n + b.utterances, 0)}개 · 음성 {fmtMB(picked.reduce((n, b) => n + b.audioBytes, 0))}
</span>
<button className="chip on" onClick={() => download(picked.map((b) => b.id))}>
<button className="chip on" disabled={busy === 'export'} onClick={() => void download(picked.map((b) => b.id))}>
<IDownload width={14} height={14} /> 한 번에 zip
</button>
{admin && (
<button className="chip danger" onClick={() => setConfirm(picked)}>
<button className="chip danger" disabled={picked.some((b) => b.live)} title={picked.some((b) => b.live) ? '진행 중인 경기는 지울 수 없습니다' : undefined} onClick={() => setConfirm(picked)}>
🗑 한 번에 지우기
</button>
)}
@@ -184,7 +195,7 @@ export function RecordsPage() {
</label>
</h4>
{bs.map((b) => (
<BundleRow key={b.id} b={b} on={sel.has(b.id)} admin={admin} onToggle={() => toggle(b.id)} onView={() => view(b)} onZip={() => download([b.id])} onDelete={() => setConfirm([b])} />
<BundleRow key={b.id} b={b} on={sel.has(b.id)} admin={admin} busy={busy === 'export'} onToggle={() => toggle(b.id)} onView={() => view(b)} onZip={() => void download([b.id])} onDelete={() => setConfirm([b])} />
))}
</section>
))}
@@ -203,7 +214,7 @@ export function RecordsPage() {
</ul>
<p className="dim small">발화 · 음성 파일 · 경기 기록(킬 · 라운드 · 범인 분석)이 게임 PC 에서 지워지고 되돌릴 수 없습니다. 먼저 zip 으로 받아 두면 "받아오기"로 다시 넣을 수 있습니다.</p>
<div className="ctx-foot">
<button className="chip" onClick={() => download(confirm.map((b) => b.id))}>
<button className="chip" disabled={busy === 'export'} onClick={() => void download(confirm.map((b) => b.id))}>
<IDownload width={14} height={14} /> 먼저 zip 받기
</button>
<button className="chip danger" disabled={busy === 'delete'} onClick={() => void doDelete(confirm)}>
@@ -220,7 +231,7 @@ export function RecordsPage() {
);
}
function BundleRow({ b, on, admin, onToggle, onView, onZip, onDelete }: { b: BundleInfo; on: boolean; admin: boolean; onToggle: () => void; onView: () => void; onZip: () => void; onDelete: () => void }) {
function BundleRow({ b, on, admin, busy, onToggle, onView, onZip, onDelete }: { b: BundleInfo; on: boolean; admin: boolean; busy: boolean; onToggle: () => void; onView: () => void; onZip: () => void; onDelete: () => void }) {
const { userById } = useData();
const icon = b.kind === 'match' ? (b.game === 'lol' ? '🏆' : '🎯') : '💬';
return (
@@ -230,6 +241,7 @@ function BundleRow({ b, on, admin, onToggle, onView, onZip, onDelete }: { b: Bun
<div className="rec-main" onClick={onView} role="button" title="기록 보기">
<div className="rec-title">
<b>{b.label}</b>
{b.live && <span className="rec-live">● 진행 중</span>}
{b.sub && <span className="dim">· {b.sub}</span>}
</div>
<div className="rec-meta dim">
@@ -249,11 +261,11 @@ function BundleRow({ b, on, admin, onToggle, onView, onZip, onDelete }: { b: Bun
<button className="chip" onClick={onView}>
기록 보기
</button>
<button className="chip" onClick={onZip} title="이 묶음을 zip 으로 내려받기 (음성 ogg · 대화.txt 포함)">
<button className="chip" disabled={busy} onClick={onZip} title="이 묶음을 zip 으로 내려받기 (음성 ogg · 대화.txt 포함)">
<IDownload width={14} height={14} /> zip
</button>
{admin && (
<button className="chip danger" onClick={onDelete} title="이 묶음 지우기">
<button className="chip danger" disabled={b.live} onClick={onDelete} title={b.live ? '진행 중인 경기는 끝난 뒤 지울 수 있습니다' : '이 묶음 지우기'}>
🗑
</button>
)}

View File

@@ -317,7 +317,8 @@ export function TimelinePage() {
setItems((prev) => {
if (prev.some((p) => p.id === it.id)) return prev.map((p) => (p.id === it.id ? it : p));
const i = prev.findIndex((p) => (order === 'desc' ? p.ts < it.ts : p.ts > it.ts));
if (i < 0) return order === 'asc' && next ? prev : [...prev, it];
// 불러온 것보다 오래된(또는 시간순에서 뒤의) 항목: 더 불러올 페이지가 남아 있으면 그때 나온다
if (i < 0) return next ? prev : [...prev, it];
return [...prev.slice(0, i), it, ...prev.slice(i)];
});
}

View File

@@ -3875,3 +3875,12 @@ button.match:hover {
display: none;
}
}
.rec-live {
color: var(--accent);
font-size: 12px;
font-weight: 700;
}
.chip:disabled {
opacity: 0.45;
cursor: default;
}