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
1 change: 1 addition & 0 deletions apps/stage-tamagotchi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@proj-airi/server-runtime": "workspace:^",
"@proj-airi/server-sdk": "workspace:*",
"@proj-airi/stage-layouts": "workspace:^",
"@proj-airi/stage-pages": "workspace:^",
"@proj-airi/stage-ui": "workspace:^",
"@proj-airi/stage-ui-live2d": "workspace:^",
"@proj-airi/stage-ui-three": "workspace:^",
Expand Down
4 changes: 4 additions & 0 deletions apps/stage-tamagotchi/src/renderer/layouts/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ const routeHeaderMetadataMap = computed(() => {
subtitle: t('settings.title'),
title: t('settings.pages.data.title'),
},
'/settings/connection': {
subtitle: t('settings.title'),
title: t('settings.pages.connection.title'),
},
'/settings/scene': {
subtitle: t('settings.title'),
title: t('settings.pages.scene.title'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script setup lang="ts">
import ConnectionSettings from '@proj-airi/stage-pages/pages/settings/connection/ConnectionSettings.vue'
</script>

<template>
<ConnectionSettings>
<template #platform-specific />
</ConnectionSettings>
</template>

<route lang="yaml">
meta:
layout: settings
stageTransition:
name: slide
</route>
6 changes: 6 additions & 0 deletions apps/stage-tamagotchi/src/renderer/pages/settings/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ const settings = computed(() => [
icon: 'i-solar:box-minimalistic-bold-duotone',
to: '/settings/providers',
},
{
title: t('settings.pages.connection.title'),
description: t('settings.pages.connection.description'),
icon: 'i-solar:router-bold-duotone',
to: '/settings/connection',
},
{
title: t('settings.pages.system.title'),
description: t('settings.pages.system.description'),
Expand Down
7 changes: 7 additions & 0 deletions packages/i18n/src/locales/en/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,13 @@ pages:
playground:
title: Transcription Playground
title: Providers
connection:
description: Configure WebSocket server connection
title: Connection
websocket-url:
description: Full address of the WebSocket server (e.g., ws://localhost:6121/ws)
label: WebSocket Server Address
placeholder: ws://localhost:6121/ws
scene:
description: Configure the environment where the character lives
title: Scene
Expand Down
6 changes: 6 additions & 0 deletions packages/i18n/src/locales/es/settings.yaml
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not to translate for other languages, this should be done by another CI.

Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,12 @@ pages:
playground:
title: Playground de Transcripción
title: Proveedores
connection:
description: Configurar la conexión del servidor WebSocket
title: Conexión
websocket-url:
description: "Dirección completa del servidor WebSocket (ej.: ws://localhost:6121/ws)' label: Dirección del servidor WebSocket"
placeholder: ws://localhost:6121/ws
scene:
description: Configurar el entorno donde vive el personaje
title: Escena
Expand Down
7 changes: 7 additions & 0 deletions packages/i18n/src/locales/ja/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,13 @@ pages:
playground:
title: 文字起こし実験場
title: プロバイダー
connection:
description: WebSocket サーバー接続を設定
title: 接続
websocket-url:
description: WebSocket サーバーの完全なアドレス(例:ws://localhost:6121/ws)
label: WebSocket サーバーアドレス
placeholder: ws://localhost:6121/ws
scene:
description: キャラクターが過ごす環境を設定する
title: シーン
Expand Down
7 changes: 7 additions & 0 deletions packages/i18n/src/locales/ko/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,13 @@ pages:
playground:
title: Transcription Playground
title: Providers
connection:
description: WebSocket 서버 연결 구성
title: 연결
websocket-url:
description: 'WebSocket 서버의 전체 주소 (예: ws://localhost:6121/ws)'
label: WebSocket 서버 주소
placeholder: ws://localhost:6121/ws
scene:
description: Configure the environment where the character lives
title: Scene
Expand Down
7 changes: 7 additions & 0 deletions packages/i18n/src/locales/ru/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,13 @@ pages:
playground:
title: Песочница транскрипции
title: Провайдеры
connection:
description: Настроить подключение к WebSocket серверу
title: Подключение
websocket-url:
description: 'Полный адрес WebSocket сервера (например: ws://localhost:6121/ws)'
label: Адрес WebSocket сервера
placeholder: ws://localhost:6121/ws
scene:
description: Настройте окружение, в котором живёт персонаж
title: Сцена
Expand Down
7 changes: 7 additions & 0 deletions packages/i18n/src/locales/vi/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,13 @@ pages:
playground:
title: Transcription Playground
title: Nhà cung cấp
connection:
description: Cấu hình kết nối máy chủ WebSocket
title: Kết nối
websocket-url:
description: 'Địa chỉ đầy đủ của máy chủ WebSocket (ví dụ: ws://localhost:6121/ws)'
label: Địa chỉ máy chủ WebSocket
placeholder: ws://localhost:6121/ws
scene:
description: Cấu hình môi trường nhân vật sinh sống
title: Bối cảnh
Expand Down
7 changes: 7 additions & 0 deletions packages/i18n/src/locales/zh-Hans/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,13 @@ pages:
scene:
description: 配置角色所在环境
title: 场景
connection:
description: 配置 WebSocket 服务器连接
title: 连接
websocket-url:
description: WebSocket 服务器的完整地址(例如:ws://localhost:6121/ws)
label: WebSocket 服务器地址
placeholder: ws://localhost:6121/ws
system:
color-scheme:
description: 更改舞台的配色方案
Expand Down
7 changes: 7 additions & 0 deletions packages/i18n/src/locales/zh-Hant/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,13 @@ pages:
playground:
title: 實驗平台
title: 服務來源
connection:
description: 設定 WebSocket 伺服器連線
title: 連線
websocket-url:
description: WebSocket 伺服器的完整位址(例如:ws://localhost:6121/ws)
label: WebSocket 伺服器位址
placeholder: ws://localhost:6121/ws
scene:
description: 設定角色所在環境
title: 場景
Expand Down
4 changes: 4 additions & 0 deletions packages/stage-layouts/src/layouts/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ const routeHeaderMetadataMap = computed(() => {
subtitle: t('settings.title'),
title: t('settings.pages.data.title'),
},
'/settings/connection': {
subtitle: t('settings.title'),
title: t('settings.pages.connection.title'),
},
'/settings/scene': {
subtitle: t('settings.title'),
title: t('settings.pages.scene.title'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script setup lang="ts">
import { createResettableLocalStorage } from '@proj-airi/stage-ui/utils/resettable'
import { FieldInput } from '@proj-airi/ui'
import { useI18n } from 'vue-i18n'

const { t } = useI18n()

const defaultWebSocketUrl = import.meta.env.VITE_AIRI_WS_URL || 'ws://localhost:6121/ws'
const [websocketUrl] = createResettableLocalStorage('settings/connection/websocket-url', defaultWebSocketUrl)
</script>

<template>
<div :class="['rounded-lg', 'bg-neutral-50', 'p-4', 'dark:bg-neutral-800', 'flex', '~', 'col', 'gap-4']">
<!-- // TODO: Make this array, support to connect to multiple WebSocket server -->
<FieldInput
v-model="websocketUrl"
:label="t('settings.pages.connection.websocket-url.label')"
:description="t('settings.pages.connection.websocket-url.description')"
:placeholder="t('settings.pages.connection.websocket-url.placeholder')"
/>
Comment thread
nekomeowww marked this conversation as resolved.
<slot name="platform-specific" />
</div>
</template>
14 changes: 14 additions & 0 deletions packages/stage-pages/src/pages/settings/connection/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script setup lang="ts">
import ConnectionSettings from './ConnectionSettings.vue'
</script>

<template>
<ConnectionSettings />
</template>

<route lang="yaml">
meta:
layout: settings
stageTransition:
name: slide
</route>
6 changes: 6 additions & 0 deletions packages/stage-pages/src/pages/settings/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ const settings = computed(() => [
icon: 'i-solar:database-bold-duotone',
to: '/settings/data',
},
{
title: t('settings.pages.connection.title'),
description: t('settings.pages.connection.description'),
icon: 'i-solar:router-bold-duotone',
to: '/settings/connection',
},
{
title: t('settings.pages.system.title'),
description: t('settings.pages.system.description'),
Expand Down
24 changes: 20 additions & 4 deletions packages/stage-ui/src/stores/mods/api/channel-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import type { ContextUpdate, WebSocketBaseEvent, WebSocketEvent, WebSocketEventO

import { Client, WebSocketEventSource } from '@proj-airi/server-sdk'
import { isStageTamagotchi, isStageWeb } from '@proj-airi/stage-shared'
import { useLocalStorage } from '@vueuse/core'
import { nanoid } from 'nanoid'
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { ref, watch } from 'vue'

import { useWebSocketInspectorStore } from '../../devtools/websocket-inspector'

Expand All @@ -16,6 +17,9 @@ export const useModsServerChannelStore = defineStore('mods:channels:proj-airi:se
const listenersInitialized = ref(false)
const listenerDisposers = ref<Array<() => void>>([])

const defaultWebSocketUrl = import.meta.env.VITE_AIRI_WS_URL || 'ws://localhost:6121/ws'
const websocketUrl = useLocalStorage('settings/connection/websocket-url', defaultWebSocketUrl)

const basePossibleEvents: Array<keyof WebSocketEvents> = [
'context:update',
'error',
Expand Down Expand Up @@ -47,7 +51,7 @@ export const useModsServerChannelStore = defineStore('mods:channels:proj-airi:se
initializing.value = new Promise<void>((resolve) => {
client.value = new Client({
name: isStageWeb() ? WebSocketEventSource.StageWeb : isStageTamagotchi() ? WebSocketEventSource.StageTamagotchi : WebSocketEventSource.StageWeb,
url: import.meta.env.VITE_AIRI_WS_URL || 'ws://localhost:6121/ws',
url: websocketUrl.value || defaultWebSocketUrl,
token: options?.token,
possibleEvents,
onAnyMessage: (event) => {
Expand Down Expand Up @@ -173,12 +177,24 @@ export const useModsServerChannelStore = defineStore('mods:channels:proj-airi:se
flush()
clearListeners()

client.value?.close()
if (client.value) {
client.value.close()
client.value = undefined
}
connected.value = false
client.value = undefined
initializing.value = null
}

watch(websocketUrl, (newUrl, oldUrl) => {
if (newUrl === oldUrl)
return

if (client.value || initializing.value) {
dispose()
void initialize()
}
})

return {
connected,
ensureConnected,
Expand Down
Loading
Loading