diff --git a/electron/main/auto-salvo.ts b/electron/main/auto-salvo.ts index e6fe0d4..059c9c0 100644 --- a/electron/main/auto-salvo.ts +++ b/electron/main/auto-salvo.ts @@ -7,7 +7,7 @@ import type { ClockEstimate, ReservationRequest, } from '../../src/type/reservation' -import { executeReservation } from './reservation' +import { executeReservation, executeReservationConcurrent } from './reservation' import { serverClock } from './server-clock' import { computePlannedSendAtMs } from './server-clock-core' @@ -60,7 +60,7 @@ export class AutoSalvoService { getEstimate(): ClockEstimate setAutoTarget(targetServerTimeMs?: number): void } = serverClock, - private readonly execute: (request: ReservationRequest) => Promise>> = executeReservation, + private readonly execute: (request: ReservationRequest) => Promise>> = executeReservationConcurrent, private readonly emitState: (state: AutoSalvoState) => void = broadcast, ) {} @@ -228,6 +228,7 @@ export class AutoSalvoService { arrivalErrorMs: estimatedArrivalServerMs === undefined ? undefined : estimatedArrivalServerMs - next.attempt.effectiveTargetServerMs, rttMs: transport?.rttMs, httpStatus: transport?.httpStatus, + serverDateMs: transport?.observedServerDateMs, }) if (result.success) { this.state = { ...this.state, succeededIndex: next.attempt.index, result } diff --git a/electron/main/reservation.ts b/electron/main/reservation.ts index e19ac28..b178d08 100644 --- a/electron/main/reservation.ts +++ b/electron/main/reservation.ts @@ -341,6 +341,12 @@ export async function executeReservation(rawRequest: ReservationRequest): Promis } } +// 다중 시도(살보)용: 단일 실행 잠금을 거치지 않고 각 시도를 실제로 병렬 전송한다. +// 각 시도가 서로 다른 토큰을 소비하므로 잠금으로 서로를 막지 않는다. +export function executeReservationConcurrent(rawRequest: ReservationRequest): Promise { + return executeReservationOnce(rawRequest) +} + function handle( channel: string, handler: (...args: TArgs) => Promise, diff --git a/src/components/AutomationPanel.tsx b/src/components/AutomationPanel.tsx index 9d67080..c070bca 100644 --- a/src/components/AutomationPanel.tsx +++ b/src/components/AutomationPanel.tsx @@ -75,6 +75,13 @@ function parseKstInput(value: string) { ) } +// 서버가 응답 Date 헤더로 알려준 서버 시각을 분:초만 표시한다 (HTTP Date는 초 단위). +function formatServerMmSs(epochMs: number) { + return new Intl.DateTimeFormat('en-GB', { + timeZone: 'Asia/Seoul', hour12: false, minute: '2-digit', second: '2-digit', + }).format(epochMs) +} + function formatClock(epochMs: number) { return new Intl.DateTimeFormat('ko-KR', { timeZone: 'Asia/Seoul', @@ -517,7 +524,8 @@ export default function AutomationPanel({ {attemptCount > 0 && !salvoArmed && } - {attemptCount > 0 &&

시도 {attemptCount}개 · 오프셋 {salvoTokenState.map((item) => `${item.offsetMs >= 0 ? '+' : ''}${item.offsetMs}`).join(' / ')} ms · 목표 시각 대비 각 시도가 이 오프셋에서 발사됩니다.

} + {attemptCount > 0 &&

시도 {attemptCount}개 · 오프셋 {salvoTokenState.map((item) => `${item.offsetMs >= 0 ? '+' : ''}${item.offsetMs}`).join(' / ')} ms · 각 시도가 목표 시각 대비 이 오프셋에서 실제로 병렬 전송됩니다.

} + {attemptCount > 1 && !stopOnSuccess &&

‘첫 성공 시 이후 취소’를 끄면 여러 시도가 동시에 성공해 중복 예약될 수 있습니다.

} {salvoState.attempts.length > 0 && (
@@ -548,6 +556,7 @@ export default function AutomationPanel({ = 0 ? '+' : ''}${attempt.arrivalErrorMs.toFixed(1)}ms`} /> + ) : ( diff --git a/src/type/reservation.ts b/src/type/reservation.ts index 27300d6..0f65953 100644 --- a/src/type/reservation.ts +++ b/src/type/reservation.ts @@ -245,6 +245,7 @@ export interface AutoSalvoAttempt { arrivalErrorMs?: number rttMs?: number httpStatus?: number + serverDateMs?: number status: 'pending' | 'firing' | 'succeeded' | 'failed' | 'skipped' message?: string reservationNum?: string diff --git a/test/auto-salvo.test.ts b/test/auto-salvo.test.ts index 2a9180a..ca0b2e7 100644 --- a/test/auto-salvo.test.ts +++ b/test/auto-salvo.test.ts @@ -82,6 +82,21 @@ describe('multi-attempt (salvo) auto reservation scheduler', () => { expect(service.getState().attempts.map((attempt) => attempt.status)).toEqual(['failed', 'failed', 'failed']) }) + it('fires every attempt in parallel without waiting for earlier requests to resolve', async () => { + vi.useFakeTimers() + vi.setSystemTime(new Date('2026-08-12T06:00:00.000Z')) + // 첫 요청이 계속 진행 중이어도(응답 없음) 뒤 시도들이 자기 시각에 발사되어야 한다. + const execute = vi.fn<() => Promise>().mockImplementation(() => new Promise(() => {})) + const clock = { ensureSample: async () => estimate(), getEstimate: estimate, setAutoTarget: vi.fn() } + const service = new AutoSalvoService(clock, execute, vi.fn()) + + await service.arm(config(Date.now() + 2_000, 3, 300)) + await vi.advanceTimersByTimeAsync(3_000) + + expect(execute).toHaveBeenCalledTimes(3) + expect(service.getState().status).toBe('firing') + }) + it('cancels remaining attempts after the first success when stopOnSuccess is set', async () => { vi.useFakeTimers() vi.setSystemTime(new Date('2026-08-12T06:00:00.000Z')) diff --git a/test/screenshots/e2e.png b/test/screenshots/e2e.png index 7c352ca..c30769f 100644 Binary files a/test/screenshots/e2e.png and b/test/screenshots/e2e.png differ