Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ Lightweight human-readable summary of meaningful repository changes. This does n

## [Unreleased]

## [v0.1.25] - 2026-11-15

- AI 여정 요청 시 Idempotency-Key UUID v4 규격 적용:
- 여정 생성 요청(`POST /api/v1/explorations`), 턴 추가(`POST /api/v1/explorations/{id}/turns`), 관리자 API 등에서 전송하는 `Idempotency-Key` 헤더를 RFC 4122 v4 UUID(8-4-4-4-12) 형식으로 표준화.
- 백엔드 `400 VALIDATION_ERROR` ('Idempotency-Key must be a UUID') 오류로 인해 여정 AI 생성이 중단되던 문제 해결.
- `clientTurnId` 역시 UUID 형식으로 일원화.
- Added Korean living-culture paths from the Hanok map home into stay, food, hands-on experience, and traditional-market exploration.
- Limited the Hanok Culture Walk panel to places identified as Hanok and removed duplicate English copy from the panel.
- Refined the map cultural-discovery panel into a compact editorial section with vertically ordered places and accessible interaction states.
- 지도마루 정보 모드의 전국 한옥 홈에 문화 발견 패널을 추가했다. 지역과 한옥 생활문화를 소개한 뒤 실제 장소 선택으로 이어지고, 한옥마루의 심화 콘텐츠로 이동할 수 있다.
- 한국어 문화 맥락과 영어 보조 해설을 함께 제공해 해외 방문자도 장소를 문화적 맥락에서 탐색할 수 있게 했다.

## [v0.1.24] - 2026-11-09

- 모바일 좌우 여백을 16px로 통일:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "onmaru-frontend",
"version": "0.1.24",
"version": "0.1.25",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
6 changes: 2 additions & 4 deletions src/features/admin/api/adminApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
*/

import { apiRequest, USE_MOCK } from '@/lib/api/client';
import { generateUUID } from '@/lib/uuid';

function newIdempotencyKey(): string {
if (typeof crypto !== 'undefined' && crypto.randomUUID) return crypto.randomUUID();
return `${Date.now()}-${Math.random().toString(36).slice(2)}`;
}
const newIdempotencyKey = generateUUID;
import {
mockDashboardStats,
mockRecentReviews,
Expand Down
42 changes: 41 additions & 1 deletion src/features/journey-curator/api/journeyApi.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,47 @@
import { describe, expect, it } from 'vitest';
import { describe, expect, it, vi } from 'vitest';
import { createJourneyRepository } from './journeyApi';

describe('journey repository', () => {
it('uses the RunAccepted snapshot URLs without rebuilding their paths', async () => {
const calls: Array<{ path: string; options: unknown }> = [];
const repository = createJourneyRepository((async (path: string, options: unknown) => {
calls.push({ path, options });
return { schemaVersion: '1.3' };
}) as never);

await repository.getAcceptedSnapshots({
schemaVersion: '1.3',
explorationId: 'exp-1',
runId: 'run-1',
stateVersion: 0,
runUrl: '/api/v1/explorations/exp-1/runs/run-1',
eventsUrl: '/api/v1/explorations/exp-1/runs/run-1/events',
snapshotUrl: '/api/v1/explorations/exp-1',
});

expect(calls).toEqual([
{ path: '/api/v1/explorations/exp-1/runs/run-1', options: { method: 'GET', cache: 'no-store', rootPath: true } },
{ path: '/api/v1/explorations/exp-1', options: { method: 'GET', cache: 'no-store', rootPath: true } },
]);
});

it('subscribes to the EventSource URL returned by RunAccepted without rebuilding it', () => {
const createEventSource = vi.fn(() => ({
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
close: vi.fn(),
})) as unknown as import('./journeyApi').JourneyEventSourceFactory;
const repository = createJourneyRepository();

repository.subscribeToRunEvents(
'https://journey.example.test/signed-events?run=accepted',
vi.fn(),
{ createEventSource },
);

expect(createEventSource).toHaveBeenCalledWith('https://journey.example.test/signed-events?run=accepted');
});

it('starts and recovers journey runs through the backend contract paths', async () => {
const calls: Array<{ path: string; options: unknown }> = [];
const repository = createJourneyRepository((async (path: string, options: unknown) => {
Expand Down
31 changes: 21 additions & 10 deletions src/features/journey-curator/api/journeyApi.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { apiRequest, getApiV1BaseUrl, type ApiRequestOptions, USE_MOCK } from '@/lib/api/client';
import { apiRequest, type ApiRequestOptions, USE_MOCK } from '@/lib/api/client';
import type { BentoJourneyPlan } from '../types/journey.types';
import { JOURNEY_PLANS } from '../data/curatedJourneys';
import type { JourneyRunSnapshot, JourneySseFrame } from './journeyContract';
import type { JourneyRunSnapshot, JourneySchemaVersion, JourneySseFrame } from './journeyContract';
import { parseJourneySseFrame } from '../reducers/journeySseParser';

type RequestFn = <T>(path: string, options?: ApiRequestOptions) => Promise<T>;

export type RunAccepted = {
schemaVersion: '1.2';
schemaVersion: JourneySchemaVersion;
explorationId: string;
runId: string;
stateVersion: number;
Expand Down Expand Up @@ -70,6 +70,7 @@ export type JourneyRepository = {
}): Promise<RunAccepted>;
getExploration(explorationId: string): Promise<ExplorationSnapshot>;
getRun(explorationId: string, runId: string): Promise<JourneyRunSnapshot>;
getAcceptedSnapshots(accepted: RunAccepted): Promise<{ run: JourneyRunSnapshot; snapshot: ExplorationSnapshot }>;
cancelRun(explorationId: string, runId: string): Promise<JourneyRunSnapshot>;

applyAction(input: ApplyActionInput): Promise<ExplorationSnapshot>;
Expand All @@ -78,8 +79,7 @@ export type JourneyRepository = {


subscribeToRunEvents(
explorationId: string,
runId: string,
eventsUrl: string,
onEvent: (frame: JourneySseFrame) => void,
options?: { onError?: (error: unknown) => void; createEventSource?: JourneyEventSourceFactory },
): () => void;
Expand Down Expand Up @@ -124,6 +124,13 @@ export function createJourneyRepository(request: RequestFn = apiRequest): Journe
cache: 'no-store',
});
},
async getAcceptedSnapshots(accepted) {
const [run, snapshot] = await Promise.all([
request<JourneyRunSnapshot>(accepted.runUrl, { method: 'GET', cache: 'no-store', rootPath: true }),
request<ExplorationSnapshot>(accepted.snapshotUrl, { method: 'GET', cache: 'no-store', rootPath: true }),
]);
return { run, snapshot };
},
cancelRun(explorationId, runId) {
return request<JourneyRunSnapshot>(`/explorations/${explorationId}/runs/${runId}/cancel`, {
method: 'POST',
Expand All @@ -143,17 +150,17 @@ export function createJourneyRepository(request: RequestFn = apiRequest): Journe
idempotencyKey: input.idempotencyKey,
});
},
subscribeToRunEvents(explorationId, runId, onEvent, options) {
const url = `${getApiV1BaseUrl()}/explorations/${explorationId}/runs/${runId}/events`;
subscribeToRunEvents(eventsUrl, onEvent, options) {
const createEventSource = options?.createEventSource ?? ((u) => new EventSource(u, { withCredentials: true }));
const source = createEventSource(url);
const source = createEventSource(eventsUrl);

const eventNames = ['run.stage', 'run.terminal', 'heartbeat', 'reset', 'auth_closed'] as const;
const listeners = eventNames.map((eventName) => {
const listener = (event: Event) => {
const messageEvent = event as MessageEvent<string>;
try {
onEvent(parseJourneySseFrame({ id: messageEvent.lastEventId, event: eventName, data: messageEvent.data }));
const frame = parseJourneySseFrame({ id: messageEvent.lastEventId, event: eventName, data: messageEvent.data });
if (frame) onEvent(frame);
} catch (err) {
options?.onError?.(err);
}
Expand Down Expand Up @@ -181,6 +188,7 @@ const fixtureRun: JourneyRunSnapshot = {
engine: 'BASELINE',
degradedReason: 'AI_SERVICE_UNAVAILABLE',
stage: null,
sequence: 1,
outcome: 'INITIAL_BOARD',
clarification: null,
retryAfterMs: 0,
Expand Down Expand Up @@ -224,13 +232,16 @@ export const fixtureJourneyRepository: JourneyRepository = {
async getRun() {
return fixtureRun;
},
async getAcceptedSnapshots() {
return { run: fixtureRun, snapshot: await this.getExploration('fixture-exploration') };
},
async cancelRun() {
return { ...fixtureRun, status: 'CANCELLED', outcome: null };
},
async applyAction() {
return this.getExploration('fixture-exploration');
},
subscribeToRunEvents(_expId, _runId, onEvent) {
subscribeToRunEvents(_eventsUrl, onEvent) {
const timer = setTimeout(() => {
onEvent({
id: '1',
Expand Down
11 changes: 9 additions & 2 deletions src/features/journey-curator/api/journeyContract.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
export type JourneySchemaVersion = '1.2';
export type JourneySchemaVersion = '1.2' | '1.3';

export type JourneyRunStatus = 'QUEUED' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED';
export type JourneyRunStage = 'INTERPRETING' | 'RETRIEVING' | 'VALIDATING' | 'PERSISTING';
export type JourneyRunStage =
| 'INTERPRETING'
| 'RETRIEVING'
| 'SELECTING_EVIDENCE'
| 'GENERATING'
| 'VALIDATING'
| 'PERSISTING';
export type JourneyRunEngine = 'LLM' | 'BASELINE';
export type JourneyDegradedReason =
| 'AI_QUOTA_EXCEEDED'
Expand All @@ -25,6 +31,7 @@ export type JourneyRunSnapshot = {
engine: JourneyRunEngine;
degradedReason: JourneyDegradedReason | null;
stage: JourneyRunStage | null;
sequence: number;
outcome: JourneyRunOutcome | null;
clarification: JourneyClarification | null;
retryAfterMs: number;
Expand Down
4 changes: 2 additions & 2 deletions src/features/journey-curator/api/journeyCuratorApi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { BentoJourneyPlan, MoodId } from '../types/journey.types';
import { matchJourneyPlan } from '../data/curatedJourneys';
import { defaultJourneyRepository, type JourneyRepository, type RunAccepted } from './journeyApi';
import { generateUUID } from '@/lib/uuid';

export interface CurateJourneyParams {
query: string;
Expand All @@ -21,8 +22,7 @@ type RunJourneyOptions = {
};

function createIdempotencyKey(): string {
if (typeof crypto !== 'undefined' && 'randomUUID' in crypto) return crypto.randomUUID();
return `journey-${Date.now()}-${Math.random().toString(16).slice(2)}`;
return generateUUID();
}

async function readAcceptedSnapshot(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('runJourneyCurator', () => {
engine: 'BASELINE',
degradedReason: null,
stage: null,
sequence: 1,
outcome: 'INITIAL_BOARD',
clarification: null,
retryAfterMs: 0,
Expand All @@ -41,6 +42,7 @@ describe('runJourneyCurator', () => {
execution: null,
}),
cancelRun: vi.fn(),
getAcceptedSnapshots: vi.fn(),
applyAction: vi.fn(),
subscribeToRunEvents: vi.fn(),
};
Expand Down
4 changes: 2 additions & 2 deletions src/features/journey-curator/api/journeySse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('journey repository actions/SSE (FE #93)', () => {
const createEventSource: JourneyEventSourceFactory = () => fake as unknown as EventSource;

const received: JourneySseFrame[] = [];
const unsubscribe = repository.subscribeToRunEvents('exp-1', 'run-1', (frame) => received.push(frame), {
const unsubscribe = repository.subscribeToRunEvents('https://journey.example.test/events/run-1', (frame) => received.push(frame), {
createEventSource,
});

Expand All @@ -86,7 +86,7 @@ describe('journey repository actions/SSE (FE #93)', () => {
const createEventSource: JourneyEventSourceFactory = () => fake as unknown as EventSource;
const onError = vi.fn();

repository.subscribeToRunEvents('exp-1', 'run-1', () => {}, { createEventSource, onError });
repository.subscribeToRunEvents('https://journey.example.test/events/run-1', () => {}, { createEventSource, onError });

fake.emit('run.stage', { lastEventId: '1', data: 'not json' });

Expand Down
30 changes: 30 additions & 0 deletions src/features/journey-curator/application/conversationRepository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { RunAccepted } from '../api/journeyApi';
import type { JourneyRunSnapshot, JourneySseFrame } from '../api/journeyContract';
import type {
ConversationSnapshot,
ExplorationPage,
ExplorationTurnPage,
} from '../domain/conversation';

export interface ConversationRepository {
listExplorations(input?: { limit?: number; cursor?: string }): Promise<ExplorationPage>;
getExploration(explorationId: string): Promise<ConversationSnapshot>;
listTurns(input: { explorationId: string; limit?: number; cursor?: string }): Promise<ExplorationTurnPage>;
createExploration(input: { query: string; regionCode?: string | null; idempotencyKey: string }): Promise<RunAccepted>;
createTurn(input: {
explorationId: string;
query: string;
baseVersion: number;
clientTurnId: string;
clarificationAnswer?: { clarificationId: string; choiceId: string | null; text: string | null } | null;
idempotencyKey: string;
}): Promise<RunAccepted>;
getAcceptedSnapshots(accepted: RunAccepted): Promise<{ run: JourneyRunSnapshot; snapshot: ConversationSnapshot }>;
subscribeToRunEvents(
eventsUrl: string,
onEvent: (frame: JourneySseFrame) => void,
onError: (error: unknown) => void,
): () => void;
cancelRun(input: { explorationId: string; runId: string; idempotencyKey: string }): Promise<JourneyRunSnapshot>;
deleteExploration(input: { explorationId: string; idempotencyKey: string }): Promise<void>;
}
Loading
Loading