feat: update main chat and system chat UI

This commit is contained in:
2026-05-25 17:26:37 +09:00
parent fb5ec649cd
commit f59522ffc4
120 changed files with 43262 additions and 3325 deletions

View File

@@ -495,6 +495,11 @@ function resolveAppConfigFallbackBaseUrl() {
const APP_CONFIG_API_BASE_URL = resolveAppConfigApiBaseUrl();
const APP_CONFIG_FALLBACK_BASE_URL = resolveAppConfigFallbackBaseUrl();
type AppConfigRequestOptions = {
shareToken?: string | null;
skipAutomationNotifications?: boolean;
};
class AppConfigApiError extends Error {
status: number;
@@ -505,12 +510,18 @@ class AppConfigApiError extends Error {
}
}
async function requestAppConfigOnce<T>(baseUrl: string, path: string, init?: RequestInit): Promise<T> {
async function requestAppConfigOnce<T>(
baseUrl: string,
path: string,
init?: RequestInit,
options?: AppConfigRequestOptions,
): Promise<T> {
const headers = appendClientIdHeader(init?.headers);
const hasBody = init?.body !== undefined && init.body !== null;
const method = init?.method?.toUpperCase() ?? 'GET';
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), APP_CONFIG_REQUEST_TIMEOUT_MS);
const shareToken = options?.shareToken?.trim() ?? '';
if (hasBody && !headers.has('Content-Type')) {
headers.set('Content-Type', 'application/json');
@@ -527,6 +538,10 @@ async function requestAppConfigOnce<T>(baseUrl: string, path: string, init?: Req
headers.set('X-App-Domain', appDomain);
}
if (shareToken && !headers.has('X-Chat-Share-Token')) {
headers.set('X-Chat-Share-Token', shareToken);
}
let response: Response;
try {
@@ -566,9 +581,9 @@ async function requestAppConfigOnce<T>(baseUrl: string, path: string, init?: Req
return response.json() as Promise<T>;
}
async function requestAppConfig<T>(path: string, init?: RequestInit): Promise<T> {
async function requestAppConfig<T>(path: string, init?: RequestInit, options?: AppConfigRequestOptions): Promise<T> {
try {
return await requestAppConfigOnce<T>(APP_CONFIG_API_BASE_URL, path, init);
return await requestAppConfigOnce<T>(APP_CONFIG_API_BASE_URL, path, init, options);
} catch (error) {
const shouldRetryWithFallback =
APP_CONFIG_FALLBACK_BASE_URL &&
@@ -581,15 +596,15 @@ async function requestAppConfig<T>(path: string, init?: RequestInit): Promise<T>
throw error;
}
return requestAppConfigOnce<T>(APP_CONFIG_FALLBACK_BASE_URL, path, init);
return requestAppConfigOnce<T>(APP_CONFIG_FALLBACK_BASE_URL, path, init, options);
}
}
export async function fetchAppConfigFromServer() {
export async function fetchAppConfigFromServer(options?: AppConfigRequestOptions) {
try {
const response = await requestAppConfig<{ ok: boolean; config: Partial<AppConfig> }>(APP_CONFIG_API_PATH);
const response = await requestAppConfig<{ ok: boolean; config: Partial<AppConfig> }>(APP_CONFIG_API_PATH, undefined, options);
const config = normalizeConfig(response.config);
const preference = await fetchAutomationNotificationPreferenceFromServer();
const preference = options?.skipAutomationNotifications ? null : await fetchAutomationNotificationPreferenceFromServer();
return mergeAutomationNotificationSettings(config, preference);
} catch {
return null;
@@ -610,11 +625,11 @@ async function fetchAutomationNotificationPreferenceFromServer() {
}
}
export async function saveAppConfigToServer(config: AppConfig) {
export async function saveAppConfigToServer(config: AppConfig, options?: AppConfigRequestOptions) {
const response = await requestAppConfig<{ ok: boolean; config: Partial<AppConfig> }>(APP_CONFIG_API_PATH, {
method: 'PUT',
body: JSON.stringify({ config }),
});
}, options);
return normalizeConfig(response.config);
}
@@ -635,8 +650,8 @@ export async function saveAutomationNotificationPreferenceToServer(config: AppCo
return mergeAutomationNotificationSettings(config, response.automation);
}
export async function syncAppConfigFromServer() {
const config = await fetchAppConfigFromServer();
export async function syncAppConfigFromServer(options?: AppConfigRequestOptions) {
const config = await fetchAppConfigFromServer(options);
if (!config) {
return false;
@@ -685,8 +700,12 @@ export function setStoredAppConfig(config: AppConfig) {
const raw = JSON.stringify(normalized);
cachedConfig = normalized;
cachedRawConfig = raw;
const storage = isPreviewRuntime() ? window.sessionStorage : window.localStorage;
storage.setItem(APP_CONFIG_STORAGE_KEY, raw);
try {
const storage = isPreviewRuntime() ? window.sessionStorage : window.localStorage;
storage.setItem(APP_CONFIG_STORAGE_KEY, raw);
} catch {
// Ignore storage failures and keep the in-memory config for the current session.
}
emitConfigChange();
}