Scope live chat to the current match and save match history

This commit is contained in:
2026-10-07 00:40:20 -04:00
parent 8fcabe27fc
commit 2b8e102b86
14 changed files with 266 additions and 30 deletions
@@ -1,7 +1,7 @@
import { json } from '@sveltejs/kit';
import { getServer } from '$lib/server/fleet/servers.js';
import { gameLogKey, resolveLogPath, tailLog } from '$lib/server/fleet/logs.js';
import { serverChatTimeline } from '$lib/server/fleet/chat.js';
import { gameLogKey, resolveLogPath } from '$lib/server/fleet/logs.js';
import { collectServerChat } from '$lib/server/fleet/chat.js';
export async function GET({ params }: { params: { name: string } }) {
const headers = { 'Cache-Control': 'no-store' };
@@ -13,8 +13,7 @@ export async function GET({ params }: { params: { name: string } }) {
if (!path) return json({ ok: false, reason: 'Path traversal rejected' }, { status: 400, headers });
try {
const tail = await tailLog(path, 2000);
return json({ ok: true, entries: tail ? serverChatTimeline(server, tail) : [], missing: tail === null }, { headers });
return json({ ok: true, ...await collectServerChat(server) }, { headers });
} catch (error) {
console.error('Could not read server chat', error);
return json({ ok: false, reason: 'Could not read server chat' }, { status: 500, headers });
+3
View File
@@ -13,6 +13,7 @@
import Card from '$ui/components/primitives/Card.svelte';
import EmptyState from '$ui/components/primitives/EmptyState.svelte';
import Stat from '$ui/components/primitives/Stat.svelte';
import ChatPanel from '$ui/components/ChatPanel.svelte';
let { data }: { data: { match: MatchDetail } } = $props();
const match = $derived(data.match);
@@ -86,6 +87,8 @@
{/if}
</section>
<Card padding="lg"><ChatPanel history={match.chat} /></Card>
<details class="note">
<summary>About these results</summary>
<p>Kills, headshots, revives, downs, and score retain each player's highest reported value. Highest reported score is a points balance, not total points earned or necessarily the final score.</p>
+1 -1
View File
@@ -259,7 +259,7 @@
</section>
<section id="chat" aria-label="Chat">
<Card>
{#key name}<ChatPanel server={name} />{/key}
{#key `${name}:${scoreboard?.timing?.matchId ?? ''}:${effectiveGameStartedAt ?? ''}`}<ChatPanel server={name} />{/key}
</Card>
</section>
{:else if activeSection === 'configuration'}