fix(web): share loopback hostname policy

This commit is contained in:
ZiyaZhang
2026-08-02 13:24:49 -07:00
parent 5ee544081a
commit 7a71ab9a92
5 changed files with 34 additions and 17 deletions

View File

@@ -7,7 +7,7 @@
*/
import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'
import { deferRegistration } from '@deepseek-ai/dsh-client-ui-slots'
import type { ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client'
import { isLoopbackHostname, type ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client'
import { bindSnapshotSelector } from '@deepseek-ai/dsh-client-web-react'
// Type-only: pulls the shell's SlotMap merges (trigger/header/section/item).
import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
@@ -41,14 +41,6 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
/** Dictionary namespace owned by this plugin (shell chrome + General copy). */
const NS = 'settings'
function isLoopbackHostname(hostname: string): boolean {
if (hostname === 'localhost' || hostname === '[::1]') return true
const parts = hostname.split('.')
return parts.length === 4
&& parts[0] === '127'
&& parts.every(part => /^\d{1,3}$/.test(part) && Number(part) <= 255)
}
function welcomePersistence(): 'host' | 'memory' {
return typeof location === 'undefined' || isLoopbackHostname(location.hostname) ? 'host' : 'memory'
}