refactor(vibe): simplify durable session flow
This commit is contained in:
@@ -11,7 +11,7 @@ describe('durable vibe service', () => {
|
||||
|
||||
await vibeService.next('session', 3);
|
||||
|
||||
expect(post).toHaveBeenCalledWith('/v2/vibe/sessions/session/next', { expectedPlanVersion: 3 });
|
||||
expect(post).toHaveBeenCalledWith('/v2/vibe/sessions/session/advance', { expectedPlanVersion: 3 });
|
||||
});
|
||||
|
||||
it('uses an explicit idempotency key to advance a served but unplayable item', async () => {
|
||||
@@ -21,7 +21,7 @@ describe('durable vibe service', () => {
|
||||
eventId: 'event', planVersionId: 'plan', ordinal: 4, trackId: 'track',
|
||||
});
|
||||
|
||||
expect(post).toHaveBeenCalledWith('/v2/vibe/sessions/session/next', {
|
||||
expect(post).toHaveBeenCalledWith('/v2/vibe/sessions/session/advance', {
|
||||
expectedPlanVersion: 3,
|
||||
unplayable: { eventId: 'event', planVersionId: 'plan', ordinal: 4, trackId: 'track' },
|
||||
});
|
||||
|
||||
@@ -71,7 +71,7 @@ export const vibeService = {
|
||||
},
|
||||
|
||||
async next(sessionId: string, expectedPlanVersion: number): Promise<DurableVibeSessionResponse> {
|
||||
const res = await api.post<DurableVibeSessionResponse>(`/v2/vibe/sessions/${sessionId}/next`, {
|
||||
const res = await api.post<DurableVibeSessionResponse>(`/v2/vibe/sessions/${sessionId}/advance`, {
|
||||
expectedPlanVersion,
|
||||
});
|
||||
return res.data;
|
||||
@@ -82,7 +82,7 @@ export const vibeService = {
|
||||
expectedPlanVersion: number,
|
||||
unplayable: VibeUnplayableItemInput,
|
||||
): Promise<DurableVibeSessionResponse> {
|
||||
const res = await api.post<DurableVibeSessionResponse>(`/v2/vibe/sessions/${sessionId}/next`, {
|
||||
const res = await api.post<DurableVibeSessionResponse>(`/v2/vibe/sessions/${sessionId}/advance`, {
|
||||
expectedPlanVersion,
|
||||
unplayable,
|
||||
});
|
||||
|
||||
@@ -202,7 +202,7 @@ function isSessionTerminalError(error: unknown): boolean {
|
||||
export function vibeErrorMessage(error: unknown): string {
|
||||
if (!axios.isAxiosError(error)) return 'Could not refresh this Vibe. Please try again.';
|
||||
switch (error.response?.status) {
|
||||
case 401: return 'Vibe needs a trusted local user identity. Set MUZICK_VIBE_USER_ID and try again.';
|
||||
case 400: return 'Vibe needs a valid user identity.';
|
||||
case 404: return 'This Vibe session is no longer available.';
|
||||
case 409: return 'This Vibe session has already ended or was replaced.';
|
||||
default: return 'Could not refresh this Vibe. Please try again.';
|
||||
|
||||
@@ -75,8 +75,8 @@ export interface HealthResponse {
|
||||
redis: 'ok' | 'error' | 'unknown';
|
||||
}
|
||||
|
||||
// Active v2 recommendation session. The sessionId comes from
|
||||
// POST /api/v2/vibe/start and identifies the Redis-stored plan.
|
||||
// Active durable recommendation session. The sessionId comes from
|
||||
// POST /api/v2/vibe/sessions and identifies its persisted plan.
|
||||
export interface VibeSession {
|
||||
sessionId: string;
|
||||
seedTrackId: string | null;
|
||||
|
||||
Reference in New Issue
Block a user