diff --git a/docs/docs.go b/docs/docs.go index aeeeafc0..4a9fdc04 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -17443,6 +17443,13 @@ const docTemplate = `{ "cube_sandbox_ttl_seconds": { "type": "integer" }, + "dns_servers": { + "description": "DNSServers are Cube template nameserver IPs. Empty uses Cubelet's default.", + "type": "array", + "items": { + "type": "string" + } + }, "http_timeout_sec": { "description": "HTTPTimeoutSec bounds each HTTP call to the sandbox control plane.\n0 means use the built-in default (30s), never the deployment's value.", "type": "integer" diff --git a/docs/sandbox-cluster.md b/docs/sandbox-cluster.md index 74a5164d..e35b362f 100644 --- a/docs/sandbox-cluster.md +++ b/docs/sandbox-cluster.md @@ -62,8 +62,8 @@ Cube 变体只发布 linux/amd64——envd 的来源镜像 `cubesandbox-base` ### 制作模板并对接 WeKnora 1. 按 [CubeSandbox Quick Start](https://github.com/TencentCloud/CubeSandbox/blob/master/docs/zh/guide/quickstart.md) 完成控制面、计算节点、CubeProxy 与域名解析。生产环境还需按官方文档完成鉴权、TLS、网络策略与多节点部署。 -2. 在 WeKnora 的空间设置中填写 CubeAPI、CubeProxy、sandbox domain 和可选 API Key。若这些端点位于 RFC1918/loopback 网络,显式打开“允许访问私网集群地址”。 -3. 点击“连接并继续”。WeKnora 先验证控制面地址与凭据,通过后才进入模板步骤并调用集群模板列表;如果集群里没有可用的 WeKnora 标准模板,会从 `wechatopenai/weknora-sandbox:latest-cube` 发起一次构建。已有模板按名称 `weknora` 或镜像识别,因此即使集群没有给模板登记别名也不会重复创建;已有模板构建失败时,走的是原地重建而不是新建一个。 +2. 在 WeKnora 的空间设置中填写 CubeAPI、CubeProxy、sandbox domain 和可选 API Key。需要自定义 guest DNS 时填写「DNS 服务器」(须为 IP);留空则使用集群默认。若这些端点位于 RFC1918/loopback 网络,显式打开“允许访问私网集群地址”。 +3. 点击“连接并继续”。WeKnora 先验证控制面地址与凭据,通过后才进入模板步骤并列出集群模板。**不会自动创建**。没有 WeKnora 标准模板时在占位卡片上点「创建」,会从 `wechatopenai/weknora-sandbox:latest-cube` 发起构建。改 DNS 或需要换镜像时在 weknora 卡片上点「重建」:先删掉现有标准模板再用当前配置新建。已有模板按名称 `weknora` 或镜像识别;失败模板同样用「重建」(CubeMaster 拒绝 redo、错误码 130400 时尤其需要)。 4. 模板构建状态会自动刷新。状态变为 `READY` 后才可选择并进入运行配置;界面显示模板名称、状态和版本,配置内部才保存该集群自己的 `template_id`。 模板镜像必须提供 uid 1000 的 `user` 账号:WeKnora 以该账号执行脚本与文件操作。写权限只保证在 `/workspace/output` 与 `/workspace/input` 下。 @@ -90,9 +90,10 @@ go test -tags=integration ./internal/sandbox -run Integration -count=1 -v | 连接验证失败 | CubeAPI 地址是否是控制面端口(不是 Dashboard 端口);私网地址是否已打开“允许访问私网集群地址” | | 连接通过但执行报数据面错误 | CubeProxy 地址与 sandbox domain 是否与集群 `CUBE_API_SANDBOX_DOMAIN` 一致;Proxy 是否对 WeKnora 可达 | | 模板长期停在构建中 | 镜像体积与网络;用 `cubemastercli tpl watch --job-id ` 看真实进度 | -| 模板构建失败 | 卡片上会显示集群返回的失败原因;点「刷新模板」会就地重建同一个模板,不会新建一个 | +| 模板构建失败 | 卡片上会显示集群返回的失败原因。未安装 Skill 时可点「重建」删掉失败模板并用当前配置新建;仅刷新列表不会再自动重建。已安装 Skill 的配置会拒绝重建,请新建沙箱 | +| 失败原因含 `TOOMANYREQUESTS` / Docker Hub 限流 | Cube 节点匿名拉 `wechatopenai/weknora-sandbox` 触发了 Hub 限额。等限额恢复后再刷新,或在节点上 `docker login` 后重试 | | 失败原因是 `Get "http://:49983/health": connect: connection refused` | 模板镜像里没有 envd。确认建模板用的是 `-cube` 变体镜像;若已是该变体,再查 Cube 沙箱网段(默认 `192.168.0.0/18`)是否与物理内网冲突 | -| 沙箱能创建但脚本报权限错误 | 模板缺少 `user` 账号,或脚本写到了 `/workspace` 根目录 | +| 沙箱能执行但「出网可用」失败 | 先看模板「公网访问」是否开启;WeKnora 标准模板构建会带 `allowInternetAccess`。guest DNS 来自标准模板构建时写入的 `dns`(设置页「DNS 服务器」/`dns_servers`)。留空时 Cubelet 会落到 `119.29.29.29`;私网或云上 UDP 53 到不了公网 DNS 时,填 Cube 宿主机 `/etc/resolv.conf` 里能用的地址,并避开 CubeVS 默认拒绝的 `10/8`、`172.16/12`、`192.168/16`。未安装 Skill 时,已有标准模板改 DNS 后在 weknora 卡片上点「重建」;已装 Skill 的配置请新建沙箱。其次 Cube 把沙箱 80/443 TPROXY 到 `192.168.0.1:8080/8443`,宿主机占用 `0.0.0.0:8080` 时 cube-egress 起不来。探测目标 `1.1.1.1` 在腾讯云也经常不通,国内目标可达即可 | | 会话重连后状态丢失 | 多副本部署是否配置了 Redis 绑定存储;沙箱是否已被空闲 TTL 回收 | ### 已知限制 @@ -105,14 +106,14 @@ go test -tags=integration ./internal/sandbox -run Integration -count=1 -v ## E2B 及其它 E2B 兼容实现 -E2B 官方托管服务、自建 E2B Infrastructure,以及任意实现 E2B 协议的控制面(例如 Kubernetes 上以容器隔离的 Agent-Sandbox)都通过同一个 E2B 配置接入;自建集群通常还要填写 `proxy_url` 数据面网关,详见 [沙箱协议接入说明](./sandbox-protocol.md)。填写 API Key 后先执行“连接并继续”,流程与 Cube 相同:验证连接后列出账号可见模板,缺少 `weknora` 时通过 E2B Template API 从标准镜像启动后台构建。自建部署还需填写 API URL 和 sandbox domain;E2B 上游通过 Terraform 提供 AWS、GCP 等部署方式,具体以 [E2B self-hosting guide](https://github.com/e2b-dev/infra/blob/main/self-host.md) 和 [E2B Template 文档](https://e2b.dev/docs/template/quickstart) 为准。 +E2B 官方托管服务、自建 E2B Infrastructure,以及任意实现 E2B 协议的控制面(例如 Kubernetes 上以容器隔离的 Agent-Sandbox)都通过同一个 E2B 配置接入;自建集群通常还要填写 `proxy_url` 数据面网关,详见 [沙箱协议接入说明](./sandbox-protocol.md)。填写 API Key 后先执行“连接并继续”,流程与 Cube 相同:验证连接后列出账号可见模板;缺少 `weknora` 时点「创建 WeKnora 标准模板」,通过 E2B Template API 从标准镜像启动后台构建。自建部署还需填写 API URL 和 sandbox domain;E2B 上游通过 Terraform 提供 AWS、GCP 等部署方式,具体以 [E2B self-hosting guide](https://github.com/e2b-dev/infra/blob/main/self-host.md) 和 [E2B Template 文档](https://e2b.dev/docs/template/quickstart) 为准。 ## 在设置页面完成接入 1. 打开“设置 → 沙箱后端”,点击“添加沙箱后端”。 2. 填写该集群自己的 API、Proxy、sandbox domain 和凭据;这些值只保存在当前空间配置中,不读取 Sandbox 环境变量。 3. 点击“连接并继续”,验证控制面地址和凭据;连接通过后才加载模板列表。 -4. 等待自动创建的标准模板就绪,或选择集群已有的兼容模板;构建中的模板不可选择,状态会自动刷新。 +4. 没有标准模板时点占位卡片上的「创建」,或选择集群已有的兼容模板;改 DNS / 镜像后在 weknora 卡片上点「重建」。**该配置已安装 Skill 时不能更换或重建模板**——技能环境绑在快照上,新底模不会进去;请新建一份沙箱再装 Skill。构建中的模板不可选择,状态会自动刷新。 5. 配置运行参数;上线前可执行一次“完整验证”。完整验证会真实创建、执行并销毁一个沙箱。 6. 保存后,在智能体 Skills 配置中选择该后端。对配置的修改只影响之后新建的沙箱;已有会话仍固定使用创建时的配置。 diff --git a/docs/swagger.json b/docs/swagger.json index 36f5256a..82ec7d4a 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -17436,6 +17436,13 @@ "cube_sandbox_ttl_seconds": { "type": "integer" }, + "dns_servers": { + "description": "DNSServers are Cube template nameserver IPs. Empty uses Cubelet's default.", + "type": "array", + "items": { + "type": "string" + } + }, "http_timeout_sec": { "description": "HTTPTimeoutSec bounds each HTTP call to the sandbox control plane.\n0 means use the built-in default (30s), never the deployment's value.", "type": "integer" diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 1847eaa7..d33c6f08 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -697,6 +697,11 @@ definitions: type: string cube_sandbox_ttl_seconds: type: integer + dns_servers: + description: DNSServers are Cube template nameserver IPs. Empty uses Cubelet's default. + items: + type: string + type: array http_timeout_sec: description: |- HTTPTimeoutSec bounds each HTTP call to the sandbox control plane. diff --git a/frontend/src/api/system/index.ts b/frontend/src/api/system/index.ts index 92fb5a41..7c3588cb 100644 --- a/frontend/src/api/system/index.ts +++ b/frontend/src/api/system/index.ts @@ -737,6 +737,7 @@ export interface SandboxCubeConfig { template_id?: string http_timeout_sec?: number cube_sandbox_ttl_seconds?: number + dns_servers?: string[] } export interface SandboxE2BConfig { @@ -812,6 +813,9 @@ export interface SandboxTemplate { standard: boolean /** The provider's own explanation for a failed build, when it reports one. */ error?: string + instance_type?: string + network_type?: string + allow_internet_access?: boolean } export interface SandboxTemplateCatalog { @@ -921,12 +925,15 @@ export function getSandboxConfigInventory(id: string): Promise<{ data: SandboxIn /** * Fetch templates using the connection currently entered in the drawer. * `ensure_standard` starts a provider-side build when no WeKnora template is - * present; the returned building item can be polled through the same endpoint. + * present. `replace_standard` deletes the existing WeKnora template first so + * a new spec (DNS, image) can take effect. The returned building item can be + * polled through the same endpoint. */ export function querySandboxTemplates(payload: { config: SandboxConfig config_id?: string ensure_standard?: boolean + replace_standard?: boolean }): Promise<{ data: SandboxTemplateCatalog }> { return post('/api/v1/sandbox-configs/templates/query', payload) as unknown as Promise<{ data: SandboxTemplateCatalog @@ -960,7 +967,10 @@ export function checkSandboxConfig(payload: { * `sandbox_inventory_unverifiable` says the backend is unreachable, so nothing * could be counted — the one case a force delete may override. */ -export type SandboxConflictCode = 'sandboxes_still_live' | 'sandbox_inventory_unverifiable' +export type SandboxConflictCode = + | 'sandboxes_still_live' + | 'sandbox_inventory_unverifiable' + | 'skill_snapshot_blocks_template' export interface SandboxConflict { code: SandboxConflictCode @@ -984,7 +994,8 @@ export function parseSandboxConflict(err: unknown): SandboxConflict | null { if (!detail || typeof detail !== 'object') return null if ( detail.code !== 'sandboxes_still_live' && - detail.code !== 'sandbox_inventory_unverifiable' + detail.code !== 'sandbox_inventory_unverifiable' && + detail.code !== 'skill_snapshot_blocks_template' ) { return null } diff --git a/frontend/src/components/SandboxConfigEditorDrawer.vue b/frontend/src/components/SandboxConfigEditorDrawer.vue index 3999cdd6..34fbb454 100644 --- a/frontend/src/components/SandboxConfigEditorDrawer.vue +++ b/frontend/src/components/SandboxConfigEditorDrawer.vue @@ -60,7 +60,7 @@ Identity-change refusals must sit at the top: the form is long and the admin otherwise saves, sees nothing, and assumes the click did nothing. --> -
+
+ @@ -222,79 +241,101 @@

{{ $t('settings.sandbox.sectionTemplate') }}

- + {{ $t('settings.sandbox.refreshTemplates') }}
-
- -
-

{{ $t('settings.sandbox.connectionPassedTitle') }}

-

{{ $t('settings.sandbox.connectionPassed') }}

-
-
-

{{ $t('settings.sandbox.templateStepHint') }}

+
{{ $t('settings.sandbox.loadingTemplates') }}
-
- -
-
- {{ $t('settings.sandbox.noTemplates') }} -
-
- - {{ $t('settings.sandbox.templateReadyHint', { name: selectedTemplate.name }) }} -
-
- - {{ $t('settings.sandbox.templateProvisioningHint') }} +

+
+
+
+ {{ $t('settings.sandbox.noTemplates') }} +
-

- {{ $t('settings.sandbox.templateLoadHint') }} -

{{ $t('settings.sandbox.howToBuildTemplate') }} @@ -395,7 +436,12 @@ config whose save was refused. --> @@ -470,6 +516,7 @@ const props = defineProps<{ const emit = defineEmits<{ (e: 'update:visible', value: boolean): void (e: 'saved'): void + (e: 'skillsChanged', record?: SandboxConfigRecord): void }>() const { t } = useI18n() @@ -524,6 +571,10 @@ const currentTemplateId = computed(() => ( backend.value === 'cube' ? cube.template_id : backend.value === 'e2b' ? e2b.template_id : '' )?.trim() || '') const selectedTemplate = computed(() => templates.value.find((item) => item.id === currentTemplateId.value)) +const clusterStandardTemplate = computed(() => templates.value.find((item) => item.standard && item.id)) +const canCreateStandard = computed(() => ( + isRemoteBackend.value && templatesLoaded.value && !clusterStandardTemplate.value && !hasSkillSnapshot.value +)) const wizardSteps = computed>(() => { const steps: Array<{ key: SandboxStepKey; title: string }> = [ { key: 'connection', title: t('settings.sandbox.stepConnection') }, @@ -573,9 +624,13 @@ const primaryDisabled = computed(() => ( // than create another one. const savedRecord = ref(null) const effectiveRecord = computed(() => savedRecord.value || props.record) +const hasSkillSnapshot = computed(() => ( + Boolean(effectiveRecord.value?.config?.skill_image?.snapshot_id?.trim()) +)) function onSkillsConfigUpdated(record: SandboxConfigRecord) { savedRecord.value = record + emit('skillsChanged', record) } // Jumping is what separates editing from creating. A config that does not exist @@ -600,7 +655,7 @@ function goToStep(index: number) { // step still has to ask the cluster what it offers; a step already loaded // just resumes its poll, as walking back through it always has. if (templatesLoaded.value) scheduleTemplatePolling() - else void loadTemplates(true) + else void loadTemplates() } const hasPendingTemplates = computed(() => templates.value.some(isTemplatePending)) @@ -711,6 +766,7 @@ function reset() { Object.assign(cube, cfg.cube || {}) Object.assign(e2b, cfg.e2b || {}) Object.assign(docker, cfg.docker || {}) + if (!Array.isArray(cube.dns_servers)) cube.dns_servers = [] if (backend.value === 'docker' && !docker.image) { docker.image = 'wechatopenai/weknora-sandbox:latest' } @@ -783,8 +839,71 @@ function clearTemplateSelection() { delete fieldErrors.value.template_id } -function templateMeta(item: SandboxTemplate): string { - return [item.status, item.version, item.id].filter(Boolean).join(' · ') +function onTemplateCardClick(item: SandboxTemplate) { + if (hasSkillSnapshot.value && item.id !== currentTemplateId.value) return + if (!isTemplateSelectable(item)) return + selectTemplate(item.id) +} + +function canRebuildTemplate(item: SandboxTemplate): boolean { + return Boolean(item.standard && item.id) && !isTemplatePending(item) && !hasSkillSnapshot.value +} + +function templateDisplayName(item: SandboxTemplate): string { + const name = item.name?.trim() || '' + const id = item.id?.trim() || '' + if (!name || name === id) return t('settings.sandbox.templateUnnamed') + return name +} + +function formatTemplateTime(value?: string): string { + const raw = value?.trim() + if (!raw) return '' + const ms = Date.parse(raw) + if (Number.isNaN(ms)) return raw + return new Date(ms).toLocaleString() +} + +function templateFieldRows(item: SandboxTemplate): Array<{ key: string; label: string; value: string; mono?: boolean }> { + const rows: Array<{ key: string; label: string; value: string; mono?: boolean }> = [] + const image = item.image?.trim() + if (image) { + rows.push({ key: 'image', label: t('settings.sandbox.templateFieldImage'), value: image, mono: true }) + } + const version = item.version?.trim() + if (version) { + rows.push({ key: 'version', label: t('settings.sandbox.templateFieldVersion'), value: version }) + } + const id = item.id?.trim() + if (id) { + rows.push({ key: 'id', label: t('settings.sandbox.templateFieldId'), value: id, mono: true }) + } + const created = formatTemplateTime(item.created_at) + if (created) { + rows.push({ key: 'created', label: t('settings.sandbox.templateFieldCreated'), value: created }) + } + const instanceType = item.instance_type?.trim() + if (instanceType) { + rows.push({ key: 'instance', label: t('settings.sandbox.templateFieldInstance'), value: instanceType }) + } + const networkType = item.network_type?.trim() + if (networkType) { + rows.push({ key: 'network', label: t('settings.sandbox.templateFieldNetwork'), value: networkType }) + } + if (item.allow_internet_access === true) { + rows.push({ + key: 'internet', + label: t('settings.sandbox.templateFieldInternet'), + value: t('settings.sandbox.templateInternetOn'), + }) + } else if (item.allow_internet_access === false) { + rows.push({ + key: 'internet', + label: t('settings.sandbox.templateFieldInternet'), + value: t('settings.sandbox.templateInternetOff'), + }) + } + return rows } function isTemplateSelectable(item: SandboxTemplate): boolean { @@ -795,7 +914,7 @@ function isTemplateSelectable(item: SandboxTemplate): boolean { function isTemplatePending(item: SandboxTemplate): boolean { const status = item.status?.trim().toLowerCase() - return ['building', 'waiting', 'pending', 'queued', 'processing'].includes(status || '') + return ['building', 'waiting', 'pending', 'queued', 'processing', 'running'].includes(status || '') } // The backend reports this when a template's builds finished without the tag @@ -847,7 +966,7 @@ function scheduleTemplatePolling() { }, 3000) } -async function loadTemplates(ensureStandard: boolean, silent = false): Promise { +async function loadTemplates(ensureStandard = false, silent = false, replaceStandard = false): Promise { if (!hasImageCatalog.value) return true if (!connectionReady()) return false if (!silent) templatesLoading.value = true @@ -857,17 +976,26 @@ async function loadTemplates(ensureStandard: boolean, silent = false): Promise item.id === currentTemplateId.value) - if (currentTemplateId.value && (!current || !isTemplateSelectable(current))) clearTemplateSelection() + if ( + currentTemplateId.value + && (!current || !isTemplateSelectable(current)) + && !hasSkillSnapshot.value + ) { + clearTemplateSelection() + } const readyStandard = templates.value.find((item) => item.id === standardID && isTemplateSelectable(item)) || templates.value.find((item) => item.standard && isTemplateSelectable(item)) if (!currentTemplateId.value && readyStandard) selectTemplate(readyStandard.id) if (res.data?.provisioned && !silent) { - MessagePlugin.info(t('settings.sandbox.standardTemplateProvisioning')) + MessagePlugin.info(replaceStandard + ? t('settings.sandbox.standardTemplateReplaced') + : t('settings.sandbox.standardTemplateProvisioning')) } scheduleTemplatePolling() return true @@ -879,6 +1007,16 @@ async function loadTemplates(ensureStandard: boolean, silent = false): Promise(block: T, stored: boolean): T { @@ -929,7 +1067,7 @@ async function handlePrimaryAction() { if (isRemoteBackend.value) { invalidateCheck() wizardStep.value += 1 - await loadTemplates(true) + await loadTemplates() return } // Docker's template is the image typed on this step. Kick a background @@ -1174,6 +1312,14 @@ onUnmounted(stopTemplatePolling) } .sandbox-editor-form { + min-width: 0; + max-width: 100%; + overflow-x: hidden; + + :deep(.setting-drawer__section) { + min-width: 0; + } + :deep(.t-form__item) { margin-bottom: 0; } @@ -1283,54 +1429,13 @@ onUnmounted(stopTemplatePolling) align-items: center; justify-content: space-between; gap: 12px; + min-width: 0; .setting-drawer__section-title { margin-bottom: 0; } } -.connection-summary { - display: flex; - align-items: flex-start; - gap: 10px; - padding: 10px 12px; - border: 1px solid var(--td-component-stroke); - border-radius: 8px; - background: var(--td-bg-color-secondarycontainer); -} - -.connection-summary__icon { - display: inline-flex; - align-items: center; - justify-content: center; - width: 22px; - height: 22px; - flex-shrink: 0; - border-radius: 50%; - background: color-mix(in srgb, var(--td-brand-color) 12%, transparent); - color: var(--td-brand-color); - font-size: 13px; -} - -.connection-summary__title, -.connection-summary__text { - margin: 0; -} - -.connection-summary__title { - color: var(--td-text-color-primary); - font-size: 13px; - font-weight: 600; - line-height: 1.45; -} - -.connection-summary__text { - margin-top: 2px; - color: var(--td-text-color-secondary); - font-size: 12px; - line-height: 1.5; -} - .weknora-template-card { display: flex; align-items: center; @@ -1386,133 +1491,172 @@ onUnmounted(stopTemplatePolling) display: flex; flex-direction: column; gap: 8px; + width: 100%; + min-width: 0; + max-width: 100%; + overflow-x: hidden; } -.template-card { +.template-row { display: flex; - align-items: center; - gap: 12px; + align-items: flex-start; + gap: 10px; + box-sizing: border-box; width: 100%; - min-height: 72px; - padding: 12px 14px; + max-width: 100%; + min-width: 0; + padding: 10px 12px; + overflow: hidden; border: 1px solid var(--td-component-stroke); - border-radius: 10px; + border-radius: 8px; background: var(--td-bg-color-container); color: var(--td-text-color-primary); - cursor: pointer; text-align: left; - transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease; + cursor: pointer; + transition: border-color 0.15s ease, box-shadow 0.15s ease; - &:hover:not(:disabled) { + &:hover:not(.is-disabled):not(.template-row--offer) { border-color: var(--td-brand-color-3, var(--td-brand-color)); - box-shadow: 0 3px 10px rgba(15, 23, 42, 0.05); } &.is-active { border-color: var(--td-brand-color); - background: color-mix(in srgb, var(--td-brand-color) 4%, var(--td-bg-color-container)); } - &:disabled { - cursor: not-allowed; + &:focus-visible { + outline: 2px solid var(--td-brand-color); + outline-offset: 2px; } - &.is-pending { - background: color-mix(in srgb, var(--td-warning-color) 3%, var(--td-bg-color-container)); + &.is-disabled { + cursor: default; } } -.template-card__badge { - display: inline-flex; - align-items: center; - justify-content: center; - width: 36px; - height: 36px; +.template-row--offer { + cursor: default; + border-style: dashed; +} + +.template-row__marker { flex-shrink: 0; - border-radius: 9px; - background: rgba(0, 82, 217, 0.1); - color: #0052d9; - font-size: 16px; + width: 14px; + height: 14px; + margin-top: 3px; + box-sizing: border-box; + border: 1.5px solid var(--td-border-level-2-color, var(--td-component-stroke)); + border-radius: 50%; + background: var(--td-bg-color-container); - .is-pending & { - background: color-mix(in srgb, var(--td-warning-color) 12%, transparent); - color: var(--td-warning-color); + .is-active & { + border-color: var(--td-brand-color); + box-shadow: inset 0 0 0 3.5px var(--td-brand-color); + } + + .is-disabled & { + opacity: 0.45; } } -.template-card__body { +.template-row__main { display: flex; flex: 1; flex-direction: column; - gap: 5px; - min-width: 0; -} - -.template-card__title-row { - display: flex; - align-items: center; gap: 6px; min-width: 0; + max-width: 100%; } -.template-card__title { +.template-row__head { + display: flex; + align-items: center; + gap: 8px; + min-width: 0; + max-width: 100%; + + :deep(.t-tag) { + flex-shrink: 0; + } +} + +.template-row__title { + flex: 0 1 auto; + min-width: 0; overflow: hidden; font-size: 13px; font-weight: 600; + line-height: 22px; text-overflow: ellipsis; white-space: nowrap; } -.template-card__meta, -.template-card__hint { - overflow-wrap: anywhere; - color: var(--td-text-color-placeholder); - font-size: 11px; - line-height: 1.45; +.template-row__spacer { + flex: 1 1 8px; + min-width: 8px; } -.template-card__hint { - color: var(--td-warning-color); +.template-row__rebuild { + flex-shrink: 0; - &--error { - color: var(--td-error-color); + :deep(.t-button) { + color: var(--td-text-color-secondary); + padding-left: 4px; + padding-right: 4px; + + &:hover { + color: var(--td-text-color-primary); + } } } -.template-card__state { - display: flex; - align-items: center; - gap: 8px; - flex-shrink: 0; - align-self: flex-start; - padding-top: 1px; +.template-row__fields { + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); + gap: 4px 16px; + margin: 0; + min-width: 0; } -.template-card__selected { - color: var(--td-brand-color); - font-size: 17px; +.template-row__field { + display: grid; + grid-template-columns: auto minmax(0, 1fr); + align-items: baseline; + gap: 8px; + min-width: 0; + + dt { + color: var(--td-text-color-placeholder); + font-size: 11px; + line-height: 18px; + white-space: nowrap; + } + + dd { + margin: 0; + min-width: 0; + overflow: hidden; + color: var(--td-text-color-secondary); + font-size: 12px; + line-height: 18px; + text-overflow: ellipsis; + white-space: nowrap; + + &.is-mono { + font-family: var(--td-font-family-mono, ui-monospace, SFMono-Regular, Menlo, monospace); + font-size: 11px; + } + } } -.template-state-note { - display: flex; - align-items: center; - gap: 8px; - padding: 9px 11px; - border: 1px solid var(--td-component-stroke); - border-radius: 7px; - background: var(--td-bg-color-secondarycontainer); - color: var(--td-text-color-secondary); +.template-row__hint { + margin: 0; + overflow-wrap: anywhere; + color: var(--td-text-color-placeholder); font-size: 12px; line-height: 1.5; - > .t-icon { - flex-shrink: 0; - color: var(--td-warning-color); - font-size: 15px; - } - - &--ready > .t-icon { - color: var(--td-brand-color); + &--error { + color: var(--td-error-color); } } @@ -1711,6 +1855,10 @@ onUnmounted(stopTemplatePolling) .sandbox-step__title { font-size: 12px; } + + .template-row__fields { + grid-template-columns: minmax(0, 1fr); + } } diff --git a/frontend/src/components/SandboxSkillsPanel.vue b/frontend/src/components/SandboxSkillsPanel.vue index eda44a44..bde9c006 100644 --- a/frontend/src/components/SandboxSkillsPanel.vue +++ b/frontend/src/components/SandboxSkillsPanel.vue @@ -185,64 +185,92 @@ - + + + + - - + () const { t, locale } = useI18n() @@ -617,19 +646,33 @@ async function refreshImage() { const res = await getSandboxConfigById(props.record.id) skillImage.value = res?.data?.config?.skill_image || null skillRollout.value = normalizeSkillRollout(res?.data?.config?.skill_rollout) + if (res?.data) emit('updated', res.data) } catch { - skillImage.value = props.record.config?.skill_image || null + skillImage.value = skillImage.value || props.record.config?.skill_image || null + emit('skillsChanged') } } +function skillsSignature(list: ConfigSkill[]): string { + return list.map((skill) => `${skill.id}:${skill.status}:${skill.enabled ? 1 : 0}`).join('|') +} + async function loadSkills(silent = false) { if (!props.record) return if (!silent) loading.value = true + const previous = skillsSignature(skills.value) + const wasBusy = skills.value.some(isBusy) try { const res = await listConfigSkills(props.record.id) skills.value = res?.data || [] followBusySkills() ensurePoll() + if (skillsSignature(skills.value) !== previous) { + emit('skillsChanged') + } + if (wasBusy && !skills.value.some(isBusy)) { + void refreshImage() + } } catch (e: any) { if (!silent) { MessagePlugin.error(e?.message || t('settings.sandbox.skillLoadFailed')) @@ -812,6 +855,7 @@ async function removeSkill(skill: ConfigSkill) { await deleteConfigSkill(props.record.id, skill.id) MessagePlugin.success(t('settings.sandbox.skillDeleteAccepted')) await loadSkills() + await refreshImage() followProgress(skill.id) } catch (e: any) { MessagePlugin.error(e?.message || t('common.deleteFailed')) @@ -1205,11 +1249,49 @@ onUnmounted(() => { color: var(--td-brand-color); } + &.is-live { + color: var(--td-brand-color); + background: color-mix(in srgb, var(--td-brand-color) 10%, transparent); + } + + &.is-live-chip { + width: auto; + min-width: 26px; + padding: 0 8px; + gap: 5px; + } + &--danger:hover:not(:disabled) { background: var(--td-error-color-1, var(--td-bg-color-secondarycontainer)); color: var(--td-error-color); } } + +.skill-item__live-dot { + width: 6px; + height: 6px; + border-radius: 50%; + background: var(--td-brand-color); + animation: skill-transcript-dot 2.4s ease-in-out infinite; +} + +.skill-item__live-label { + font-size: 12px; + font-weight: 500; + line-height: 1; + white-space: nowrap; +} + +@keyframes skill-transcript-dot { + 0%, + 100% { + opacity: 1; + } + + 50% { + opacity: 0.45; + } +}