Files
halobestie-clone/mitra_app/lib/core/constants.dart
ramadhan sjamsani 14b5cc966b Phase 4 Stage 6: chat-room countdown UX + voice-call mode pill
Customer chat screen:
- Voice-call header pill (mode == 'call' renders accent-colored pill;
  chat mode renders no pill).
- HaloSnackbar fires once per session at 180s remaining ('sisa 3 menit
  lagi ya 🤍'), driven by the backend session_warning WS event.
- Last-2-min danger styling: timer pill flips to HaloTokens.danger +
  bold JetBrainsMono when remaining <= 120s.
- Floating ChatExpiredBanner widget injected above the input bar when
  remaining hits 0 in closing-grace state. perpanjang -> existing
  pricing bottom sheet.
- pricing_bottom_sheet.dart rewritten to the 5-option layout with
  chat|call mode toggle (mirrors duration-pick from Stage 3).

Mitra chat screen: voice-call header pill only (no countdown UX per PRD).

Backend:
- session.service.js getSessionById JOINs payment_sessions so mode +
  expires_at ship in /api/shared/chat/:id/info.
- session-timer.service.js onThreeMinuteWarning now emits expires_at +
  remaining_seconds for client resync.
- Dev-only POST /internal/_test/force-session-expires-at clears the
  3-min flag, reschedules the timer, and broadcasts WS resync. Lets
  the Maestro flow drive 175s -> 90s -> 0s without waiting live.

New chatRemainingSeconds StreamProvider derived from expiresAt, fed by
session_warning / session_timer / session_expired resync messages
(plan referenced a secondsLeftProvider that didn't actually exist).

Maestro 06_chat_countdown.yaml + force_session_expires_at.js helper.

Out of scope: meet.google.com URL launching - url_launcher isn't a
client_app dependency and message bubbles render plain Text. Defer.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-10 17:25:11 +08:00

148 lines
3.9 KiB
Dart

/// User types
class UserType {
static const customer = 'customer';
static const mitra = 'mitra';
UserType._();
}
/// Chat session statuses
class SessionStatus {
static const searching = 'searching';
static const pendingAcceptance = 'pending_acceptance';
static const pendingPayment = 'pending_payment';
static const active = 'active';
static const extending = 'extending';
static const closing = 'closing';
static const completed = 'completed';
static const cancelled = 'cancelled';
static const expired = 'expired';
SessionStatus._();
}
/// Chat message statuses
class MessageStatus {
static const sent = 'sent';
static const delivered = 'delivered';
static const read = 'read';
MessageStatus._();
}
/// Chat message types
class MessageType {
static const text = 'text';
MessageType._();
}
/// Session extension statuses
class ExtensionStatus {
static const pending = 'pending';
static const accepted = 'accepted';
static const rejected = 'rejected';
static const timeout = 'timeout';
ExtensionStatus._();
}
/// Chat request notification responses (Phase 3.5).
/// `null` on the wire means "still pending" — no enum value.
enum RequestResponse {
accepted('accepted'),
declined('declined'),
missed('missed'),
ignored('ignored');
final String value;
const RequestResponse(this.value);
static RequestResponse? fromString(String? v) {
if (v == null) return null;
for (final e in values) {
if (e.value == v) return e;
}
return null;
}
}
/// Session mode — chat or voice call. Mirrors backend `payment_sessions.mode`
/// (added in Phase 4 stage 1). Mitra only reads this to render the header
/// "Voice Call" pill — there is no functional difference from a regular chat.
enum SessionMode {
chat('chat'),
call('call');
final String value;
const SessionMode(this.value);
static SessionMode fromString(String? v) =>
values.firstWhere((e) => e.value == v, orElse: () => SessionMode.chat);
}
/// Session topic sensitivity
enum TopicSensitivity {
regular('regular'),
sensitive('sensitive');
final String value;
const TopicSensitivity(this.value);
static TopicSensitivity fromString(String? v) =>
values.firstWhere((e) => e.value == v, orElse: () => TopicSensitivity.regular);
}
/// Pairing request type — distinguishes general blast from targeted
/// "Curhat lagi" returning-chat requests.
enum PairingRequestType {
general('general'),
returning('returning');
final String value;
const PairingRequestType(this.value);
static PairingRequestType fromString(String? v) =>
values.firstWhere((e) => e.value == v, orElse: () => PairingRequestType.general);
}
/// WebSocket message types
class WsMessage {
// Auth
static const auth = 'auth';
static const authOk = 'auth_ok';
static const error = 'error';
// Chat
static const message = 'message';
static const messageAck = 'message_ack';
static const messageStatus = 'message_status';
static const typing = 'typing';
// Pairing
static const chatRequest = 'chat_request';
static const chatRequestClosed = 'chat_request_closed';
static const paired = 'paired';
// Session lifecycle
static const sessionTimer = 'session_timer';
static const sessionExpired = 'session_expired';
static const sessionClosing = 'session_closing';
static const sessionCompleted = 'session_completed';
static const sessionPaused = 'session_paused';
static const sessionResumed = 'session_resumed';
// Phase 4 — `session_warning` is customer-only; the mitra never receives it.
// Kept here for symmetry with backend constants only.
// Extension
static const extensionRequest = 'extension_request';
static const extensionResponse = 'extension_response';
// Topic sensitivity
static const sessionTopicUpdated = 'session_topic_updated';
// Delivery
static const delivered = 'delivered';
static const read = 'read';
// Early end
static const earlyEnd = 'early_end';
WsMessage._();
}