From a26c597d4fd6216091fa1fe1b4cc42355ce64b03 Mon Sep 17 00:00:00 2001 From: 11linear11 <11linearlin11@gmail.com> Date: Fri, 16 Oct 2026 17:09:31 -0400 Subject: [PATCH] feat(voice): add session provider selection to the frontend Pin provider choices to creation attempts, confirm session closure before switching and handle unavailable providers without fallback. Restore Settings navigation for non-admin users while preserving operation-level authorization. --- src/app/layout/layout.component.ts | 9 +-- src/app/pages/home/home.page.css | 6 +- src/app/pages/home/home.page.html | 14 ++++ src/app/pages/home/home.page.ts | 12 ++++ .../voice-stream/voice-api.service.ts | 16 ++++- .../voice-stream/voice-stream.service.spec.ts | 50 +++++++++++++ .../voice-stream/voice-stream.service.ts | 71 +++++++++++++++++-- 7 files changed, 163 insertions(+), 15 deletions(-) diff --git a/src/app/layout/layout.component.ts b/src/app/layout/layout.component.ts index 09455f6..77922e0 100644 --- a/src/app/layout/layout.component.ts +++ b/src/app/layout/layout.component.ts @@ -6,7 +6,7 @@ import { AuthService } from '../services/auth/auth.service'; import { VoiceStreamService } from '../services/voice-stream/voice-stream.service'; import { ThemeService } from '../services/theme/theme.service'; -/** Navigation outside the assistant: document management is admin-only per the contract. */ +/** Settings remain discoverable; document-management operations require admin authority. */ const BASE_NAV_ITEMS: NavItem[] = [ { icon: 'M12 5v14M5 12h14', label: 'چت جدید', route: '/' }, { icon: 'M4 4v16h16M8 20V11M12.5 20V6M17 20V9', label: 'گزارشات', route: '/reports' }, @@ -53,11 +53,8 @@ export class LayoutComponent { /** The signed-in identity exactly as the server reported it. */ readonly userName = computed(() => this.authService.currentUserSubject.value?.username ?? ''); - /** Hiding a nav entry is only cosmetic: every request is still authorized server-side. */ - readonly navItems = computed(() => { - const isAdmin = this.authService.currentUserSubject.value?.role === 'admin'; - return isAdmin ? BASE_NAV_ITEMS : BASE_NAV_ITEMS.filter((item) => item.route !== '/settings'); - }); + /** The settings page handles role-specific controls; the server authorizes each operation. */ + readonly navItems = signal(BASE_NAV_ITEMS); onProfile(): void { this.sidebarOpen.set(false); diff --git a/src/app/pages/home/home.page.css b/src/app/pages/home/home.page.css index 8f81a29..8b91bf9 100644 --- a/src/app/pages/home/home.page.css +++ b/src/app/pages/home/home.page.css @@ -330,4 +330,8 @@ transition: none !important; animation: none !important; } -} \ No newline at end of file +} +.voice-provider-choice { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .5rem 1rem; font-size: .85rem; } +.voice-provider-choice select { font: inherit; color: inherit; background: var(--surface-color, transparent); border: 1px solid currentColor; border-radius: .5rem; padding: .3rem .6rem; } +.voice-provider-choice small { opacity: .75; } +.voice-provider-error { margin: .25rem 1rem; font-size: .8rem; } diff --git a/src/app/pages/home/home.page.html b/src/app/pages/home/home.page.html index 2af53d4..e29bda9 100644 --- a/src/app/pages/home/home.page.html +++ b/src/app/pages/home/home.page.html @@ -37,6 +37,20 @@
+ @if (providerOptions().length) { +
+ + + @if (callOpen()) { تغییر ارائه‌دهنده تماس فعلی را پایان می‌دهد. } +
+ } + @if (providerChoiceError()) {

{{ providerChoiceError() }}

} + @if (jumpVisible()) {