Ariver
2026-06-23 7eb0b4196ce15c8bfbb0514c54b51cf019c78d24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<script lang="ts">
  import { onMount } from 'svelte'
  import { Events, Call } from '@wailsio/runtime'
  import { t } from '../../lib/i18n'
  import { engineStatus } from '../../lib/stores/app'
  import AppIcon from '../shared/AppIcon.svelte'
 
  let statusText = $state(t('onboarding.syncModel'))
  let detailText = $state('')
  let progress = $state(0)
  let failed = $state(false)
  let downloadActive = $state(false)
 
  onMount(() => {
    Events.On('model:download-progress', (ev: any) => {
      const data = ev?.data
      if (data?.percent != null) {
        downloadActive = true
        failed = false
        statusText = t('onboarding.syncModel')
        progress = data.percent
        const downloadedMB = Math.floor((data.downloaded || 0) / 1024 / 1024)
        const totalMB = Math.floor((data.total || 0) / 1024 / 1024)
        detailText = `${data.percent.toFixed(1)}% (${downloadedMB}MB / ${totalMB}MB)`
      }
    })
 
    Events.On('engine:status', (ev: any) => {
      const data = ev?.data
      if (data?.status === 'ready') {
        downloadActive = false
        failed = false
        statusText = t('onboarding.complete')
        progress = 100
      } else if (data?.status === 'need_model') {
        const error = typeof data?.error === 'string' ? data.error.trim() : ''
        if (error && !downloadActive) {
          statusText = t('onboarding.failed')
          detailText = error
          failed = true
        }
      } else if (data?.status === 'error') {
        downloadActive = false
        statusText = t('onboarding.failed')
        detailText = data?.error || ''
        failed = true
      }
    })
 
    triggerDownload()
  })
 
  async function triggerDownload() {
    try {
      downloadActive = true
      failed = false
      statusText = t('onboarding.syncModel')
      detailText = ''
      await Call.ByName('voicesnap/services.EngineService.DownloadCurrentModel')
      downloadActive = false
      statusText = t('onboarding.optimizing')
      detailText = t('onboarding.extracting')
    } catch (err: any) {
      downloadActive = false
      statusText = t('onboarding.failed')
      detailText = err?.message || String(err)
      failed = true
    }
  }
</script>
 
<div class="onboarding">
  <div class="card">
    <div class="icon">
      <AppIcon size={56} elevated />
    </div>
    <h1 class="title">{t('onboarding.title')}</h1>
 
    <div class="status">
      <p class="status-text" class:failed>{statusText}</p>
      {#if detailText}
        <p class="detail-text">{detailText}</p>
      {/if}
    </div>
 
    <!-- Progress bar -->
    <div class="progress-track">
      <div class="progress-fill" style="width: {progress}%" class:failed></div>
    </div>
  </div>
</div>
 
<style>
  .onboarding {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--color-bg-secondary);
    padding: var(--spacing-xxl);
  }
 
  .card {
    background: var(--color-bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xxl) 48px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.06);
  }
 
  .icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--spacing-lg);
  }
 
  .title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    margin-bottom: var(--spacing-xl);
  }
 
  .status {
    margin-bottom: var(--spacing-lg);
  }
 
  .status-text {
    font-size: var(--font-size-base);
    font-weight: 500;
    color: var(--color-label);
  }
 
  .status-text.failed {
    color: var(--color-red);
  }
 
  .detail-text {
    margin-top: var(--spacing-xs);
    font-size: var(--font-size-sm);
    color: var(--color-secondary-label);
  }
 
  .progress-track {
    height: 6px;
    background: var(--color-bg-secondary);
    border-radius: 3px;
    overflow: hidden;
  }
 
  .progress-fill {
    height: 100%;
    background: var(--color-blue);
    border-radius: 3px;
    transition: width 200ms ease;
  }
 
  .progress-fill.failed {
    background: var(--color-red);
  }
</style>