ui(sandbox): edit skill env vars in a popup
Only show the key when the skill declared env vars, and open the editor as a popup like the install transcript. Hide the hover tooltip while the popup is open and keep password managers from filling the fields.main
parent
d9b3ac3ab4
commit
4ce08b16ee
|
|
@ -179,27 +179,134 @@
|
|||
@change="(v: any) => toggleEnabled(skill, Boolean(v))"
|
||||
/>
|
||||
</t-tooltip>
|
||||
<t-tooltip
|
||||
:content="
|
||||
expandedEnvSkillId === skill.id
|
||||
? $t('settings.sandbox.skillEnv.toggleHide')
|
||||
: $t('settings.sandbox.skillEnv.toggle')
|
||||
"
|
||||
placement="top"
|
||||
<t-popup
|
||||
v-if="skillHasDeclaredEnvs(skill)"
|
||||
:visible="expandedEnvSkillId === skill.id"
|
||||
trigger="click"
|
||||
placement="bottom-right"
|
||||
attach="body"
|
||||
destroy-on-close
|
||||
overlay-class-name="skill-env-popup"
|
||||
:z-index="3200"
|
||||
:overlay-inner-style="{ padding: '0' }"
|
||||
@visible-change="(visible: boolean, context?: { e?: Event }) => onEnvVisible(skill, visible, context)"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="skill-item__icon-btn"
|
||||
:class="{ 'is-on': expandedEnvSkillId === skill.id }"
|
||||
:aria-label="$t('settings.sandbox.skillEnv.toggle')"
|
||||
@click="toggleEnvs(skill)"
|
||||
<t-tooltip
|
||||
:content="$t('settings.sandbox.skillEnv.toggle')"
|
||||
placement="top"
|
||||
destroy-on-close
|
||||
v-bind="expandedEnvSkillId === skill.id ? { visible: false } : {}"
|
||||
>
|
||||
<t-icon
|
||||
:name="expandedEnvSkillId === skill.id ? 'chevron-up' : 'key'"
|
||||
size="16px"
|
||||
/>
|
||||
</button>
|
||||
</t-tooltip>
|
||||
<button
|
||||
type="button"
|
||||
class="skill-item__icon-btn skill-item__icon-btn--key"
|
||||
:class="{ 'is-on': expandedEnvSkillId === skill.id }"
|
||||
:aria-label="$t('settings.sandbox.skillEnv.toggle')"
|
||||
@pointerdown="ensureEnvDrafts(skill.id)"
|
||||
>
|
||||
<t-icon name="key" size="18px" />
|
||||
</button>
|
||||
</t-tooltip>
|
||||
<template #content>
|
||||
<div class="skill-env-popup__panel">
|
||||
<header class="skill-env-popup__head">
|
||||
<div class="skill-env-popup__head-text">
|
||||
<div class="skill-env-popup__title">{{ skill.name || skill.id }}</div>
|
||||
<div class="skill-env-popup__meta">
|
||||
{{ $t('settings.sandbox.skillEnv.workspaceTitle') }}
|
||||
</div>
|
||||
</div>
|
||||
<t-button
|
||||
variant="text"
|
||||
shape="square"
|
||||
size="small"
|
||||
class="skill-env-popup__close"
|
||||
:title="$t('common.close')"
|
||||
@click.stop="onEnvVisible(skill, false)"
|
||||
>
|
||||
<template #icon><t-icon name="close" size="16px" /></template>
|
||||
</t-button>
|
||||
</header>
|
||||
<div class="skill-env-popup__body">
|
||||
<p class="skill-envs__hint">{{ $t('settings.sandbox.skillEnv.workspaceHint') }}</p>
|
||||
<div class="skill-envs__rows">
|
||||
<div v-for="(env, envIdx) in skill.envs" :key="env.name" class="skill-envs__row">
|
||||
<div class="skill-envs__meta">
|
||||
<code class="skill-envs__name">{{ env.name }}</code>
|
||||
<span v-if="env.required" class="skill-envs__tag skill-envs__tag--required">
|
||||
{{ $t('settings.sandbox.skillEnv.required') }}
|
||||
</span>
|
||||
<span
|
||||
class="skill-envs__tag"
|
||||
:class="env.is_set ? 'skill-envs__tag--set' : 'skill-envs__tag--unset'"
|
||||
>
|
||||
{{
|
||||
env.is_set
|
||||
? $t('settings.sandbox.skillEnv.isSet')
|
||||
: $t('settings.sandbox.skillEnv.notSet')
|
||||
}}
|
||||
</span>
|
||||
<span v-if="env.description" class="skill-envs__desc">{{ env.description }}</span>
|
||||
</div>
|
||||
<div class="skill-envs__editor">
|
||||
<t-input
|
||||
:value="envDrafts[skill.id]?.[env.name] ?? ''"
|
||||
type="password"
|
||||
autocomplete="new-password"
|
||||
:name="`wk-se-${envIdx}`"
|
||||
:readonly="!isEnvInputUnlocked(skill.id, env.name)"
|
||||
spellcheck="false"
|
||||
data-lpignore="true"
|
||||
data-1p-ignore="true"
|
||||
data-bwignore="true"
|
||||
:aria-label="env.name"
|
||||
:placeholder="
|
||||
env.is_set
|
||||
? $t('settings.sandbox.skillEnv.placeholderSet')
|
||||
: $t('settings.sandbox.skillEnv.placeholderUnset')
|
||||
"
|
||||
@focus="unlockEnvInput(skill.id, env.name)"
|
||||
@update:value="(v: string) => setEnvDraft(skill.id, env.name, v)"
|
||||
/>
|
||||
<t-popconfirm
|
||||
v-if="canClearAdminSkillEnv(env)"
|
||||
theme="warning"
|
||||
attach="body"
|
||||
:z-index="3300"
|
||||
:popup-props="{ attach: 'body', zIndex: 3300 }"
|
||||
:content="$t('settings.sandbox.skillEnv.clearConfirm', { name: env.name })"
|
||||
:confirm-btn="{ content: $t('settings.sandbox.skillEnv.clear'), theme: 'danger' }"
|
||||
:cancel-btn="{ content: $t('common.cancel') }"
|
||||
@confirm="clearEnv(skill, env.name)"
|
||||
>
|
||||
<t-button
|
||||
theme="danger"
|
||||
variant="text"
|
||||
size="small"
|
||||
:disabled="envSaveInFlight(skill)"
|
||||
:loading="envSaveInFlight(skill)"
|
||||
>
|
||||
{{ $t('settings.sandbox.skillEnv.clear') }}
|
||||
</t-button>
|
||||
</t-popconfirm>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="skill-env-popup__footer">
|
||||
<t-button
|
||||
theme="primary"
|
||||
size="small"
|
||||
:disabled="!hasEnvEdits(skill) || envSaveInFlight(skill)"
|
||||
:loading="envSaveInFlight(skill)"
|
||||
@click="saveEnvs(skill)"
|
||||
>
|
||||
{{ $t('settings.sandbox.skillEnv.save') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</t-popup>
|
||||
<span class="skill-item__actions-divider" />
|
||||
<t-tooltip :content="$t('settings.sandbox.skillFiles')" placement="top">
|
||||
<button
|
||||
|
|
@ -212,24 +319,25 @@
|
|||
<t-icon name="folder" size="16px" />
|
||||
</button>
|
||||
</t-tooltip>
|
||||
<t-tooltip
|
||||
v-if="hasTranscript(skill) || isBusy(skill)"
|
||||
:content="isBusy(skill)
|
||||
? $t('settings.sandbox.skillTranscriptLiveHint')
|
||||
: $t('settings.sandbox.skillTranscript')"
|
||||
placement="top"
|
||||
<t-popup
|
||||
v-if="hasTranscript(skill)"
|
||||
:visible="expandedSkillId === skill.id"
|
||||
trigger="click"
|
||||
placement="bottom-right"
|
||||
attach="body"
|
||||
destroy-on-close
|
||||
overlay-class-name="skill-transcript-popup"
|
||||
:z-index="3200"
|
||||
:overlay-inner-style="{ padding: '0' }"
|
||||
@visible-change="(visible: boolean) => onTranscriptVisible(skill, visible)"
|
||||
>
|
||||
<t-popup
|
||||
v-if="hasTranscript(skill)"
|
||||
:visible="expandedSkillId === skill.id"
|
||||
trigger="click"
|
||||
placement="bottom-right"
|
||||
attach="body"
|
||||
<t-tooltip
|
||||
:content="isBusy(skill)
|
||||
? $t('settings.sandbox.skillTranscriptLiveHint')
|
||||
: $t('settings.sandbox.skillTranscript')"
|
||||
placement="top"
|
||||
destroy-on-close
|
||||
overlay-class-name="skill-transcript-popup"
|
||||
:z-index="3200"
|
||||
:overlay-inner-style="{ padding: '0' }"
|
||||
@visible-change="(visible: boolean) => onTranscriptVisible(skill, visible)"
|
||||
v-bind="expandedSkillId === skill.id ? { visible: false } : {}"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
|
|
@ -247,7 +355,8 @@
|
|||
{{ $t('settings.sandbox.skillTranscriptLive') }}
|
||||
</span>
|
||||
</button>
|
||||
<template #content>
|
||||
</t-tooltip>
|
||||
<template #content>
|
||||
<div class="skill-transcript-popup__panel">
|
||||
<header class="skill-transcript-popup__head">
|
||||
<div class="skill-transcript-popup__head-text">
|
||||
|
|
@ -285,19 +394,23 @@
|
|||
</div>
|
||||
</template>
|
||||
</t-popup>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="skill-item__icon-btn is-live is-live-chip"
|
||||
:aria-label="$t('settings.sandbox.skillTranscript')"
|
||||
<t-tooltip
|
||||
v-else-if="isBusy(skill)"
|
||||
:content="$t('settings.sandbox.skillTranscriptLiveHint')"
|
||||
placement="top"
|
||||
>
|
||||
<span class="skill-item__live-dot" aria-hidden="true" />
|
||||
<t-icon name="chat-bubble-history" size="16px" />
|
||||
<span class="skill-item__live-label">
|
||||
{{ $t('settings.sandbox.skillTranscriptLive') }}
|
||||
</span>
|
||||
</button>
|
||||
</t-tooltip>
|
||||
<button
|
||||
type="button"
|
||||
class="skill-item__icon-btn is-live is-live-chip"
|
||||
:aria-label="$t('settings.sandbox.skillTranscript')"
|
||||
>
|
||||
<span class="skill-item__live-dot" aria-hidden="true" />
|
||||
<t-icon name="chat-bubble-history" size="16px" />
|
||||
<span class="skill-item__live-label">
|
||||
{{ $t('settings.sandbox.skillTranscriptLive') }}
|
||||
</span>
|
||||
</button>
|
||||
</t-tooltip>
|
||||
<t-tooltip
|
||||
v-if="skill.status === 'failed'"
|
||||
:content="$t('settings.sandbox.skillRetryHint')"
|
||||
|
|
@ -354,79 +467,6 @@
|
|||
<li v-for="(line, i) in failedErrorLines(skill)" :key="i">{{ line }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div v-if="expandedEnvSkillId === skill.id" class="skill-item__envs">
|
||||
<p v-if="!skill.envs || skill.envs.length === 0" class="skill-envs__none">
|
||||
{{ $t('settings.sandbox.skillEnv.none') }}
|
||||
</p>
|
||||
<template v-else>
|
||||
<h5 class="skill-envs__title">{{ $t('settings.sandbox.skillEnv.workspaceTitle') }}</h5>
|
||||
<p class="skill-envs__hint">{{ $t('settings.sandbox.skillEnv.workspaceHint') }}</p>
|
||||
<div class="skill-envs__rows">
|
||||
<div v-for="env in skill.envs" :key="env.name" class="skill-envs__row">
|
||||
<div class="skill-envs__meta">
|
||||
<code class="skill-envs__name">{{ env.name }}</code>
|
||||
<span v-if="env.required" class="skill-envs__tag skill-envs__tag--required">
|
||||
{{ $t('settings.sandbox.skillEnv.required') }}
|
||||
</span>
|
||||
<span
|
||||
class="skill-envs__tag"
|
||||
:class="env.is_set ? 'skill-envs__tag--set' : 'skill-envs__tag--unset'"
|
||||
>
|
||||
{{
|
||||
env.is_set
|
||||
? $t('settings.sandbox.skillEnv.isSet')
|
||||
: $t('settings.sandbox.skillEnv.notSet')
|
||||
}}
|
||||
</span>
|
||||
<span v-if="env.description" class="skill-envs__desc">{{ env.description }}</span>
|
||||
</div>
|
||||
<div class="skill-envs__editor">
|
||||
<t-input
|
||||
v-model="envDrafts[skill.id][env.name]"
|
||||
type="password"
|
||||
autocomplete="off"
|
||||
:aria-label="env.name"
|
||||
:placeholder="
|
||||
env.is_set
|
||||
? $t('settings.sandbox.skillEnv.placeholderSet')
|
||||
: $t('settings.sandbox.skillEnv.placeholderUnset')
|
||||
"
|
||||
/>
|
||||
<t-popconfirm
|
||||
v-if="canClearAdminSkillEnv(env)"
|
||||
theme="warning"
|
||||
:content="$t('settings.sandbox.skillEnv.clearConfirm', { name: env.name })"
|
||||
:confirm-btn="{ content: $t('settings.sandbox.skillEnv.clear'), theme: 'danger' }"
|
||||
:cancel-btn="{ content: $t('common.cancel') }"
|
||||
@confirm="clearEnv(skill, env.name)"
|
||||
>
|
||||
<t-button
|
||||
theme="danger"
|
||||
variant="text"
|
||||
size="small"
|
||||
:disabled="envSaveInFlight(skill)"
|
||||
:loading="envSaveInFlight(skill)"
|
||||
>
|
||||
{{ $t('settings.sandbox.skillEnv.clear') }}
|
||||
</t-button>
|
||||
</t-popconfirm>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="skill-envs__footer">
|
||||
<t-button
|
||||
theme="primary"
|
||||
size="small"
|
||||
:disabled="!hasEnvEdits(skill) || envSaveInFlight(skill)"
|
||||
:loading="envSaveInFlight(skill)"
|
||||
@click="saveEnvs(skill)"
|
||||
>
|
||||
{{ $t('settings.sandbox.skillEnv.save') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
|
@ -482,6 +522,7 @@ import {
|
|||
editedSkillEnvPayload,
|
||||
isSkillEnvSaveInFlight,
|
||||
isValidEnvValueLength,
|
||||
skillHasDeclaredEnvs,
|
||||
type SkillEnvSavesInFlight,
|
||||
} from '@/views/settings/envVarState'
|
||||
|
||||
|
|
@ -520,14 +561,15 @@ const transcriptEpoch = ref(0)
|
|||
const focusedSkillId = ref('')
|
||||
const skillItemEls = new Map<string, HTMLElement>()
|
||||
let focusTimer: number | null = null
|
||||
// Workspace-wide env values. Only one skill's editor is open at a time, for the
|
||||
// same reason as the timeline: the row is already dense.
|
||||
// Workspace-wide env values. Only one skill's editor popup is open at a time,
|
||||
// same as the install timeline.
|
||||
const expandedEnvSkillId = ref('')
|
||||
// Drafts keyed by skill then variable name. An absent key means "the admin did
|
||||
// not touch this field", which is what keeps the PATCH partial: an empty string
|
||||
// clears the stored value server-side, so submitting every input would wipe
|
||||
// values nobody looked at.
|
||||
const envDrafts = reactive<Record<string, Record<string, string>>>({})
|
||||
const envInputUnlocked = reactive<Record<string, boolean>>({})
|
||||
const envSavesInFlight = ref<SkillEnvSavesInFlight>({})
|
||||
const fileInputRef = ref<HTMLInputElement | null>(null)
|
||||
const progressById = ref<Record<string, ConfigSkillInstallEvent>>({})
|
||||
|
|
@ -639,6 +681,7 @@ function revealSkill(skillId: string) {
|
|||
function onTranscriptVisible(skill: ConfigSkill, visible: boolean) {
|
||||
if (visible) {
|
||||
filesDrawerVisible.value = false
|
||||
expandedEnvSkillId.value = ''
|
||||
if (expandedSkillId.value !== skill.id) {
|
||||
expandedSkillId.value = skill.id
|
||||
// A run that finished while the popup was closed was tailed from the
|
||||
|
|
@ -654,6 +697,7 @@ function onTranscriptVisible(skill: ConfigSkill, visible: boolean) {
|
|||
|
||||
function openSkillFiles(skill: ConfigSkill) {
|
||||
expandedSkillId.value = ''
|
||||
expandedEnvSkillId.value = ''
|
||||
if (filesDrawerVisible.value && filesSkillId.value === skill.id) {
|
||||
filesDrawerVisible.value = false
|
||||
return
|
||||
|
|
@ -663,15 +707,56 @@ function openSkillFiles(skill: ConfigSkill) {
|
|||
filesDrawerVisible.value = true
|
||||
}
|
||||
|
||||
function toggleEnvs(skill: ConfigSkill) {
|
||||
if (expandedEnvSkillId.value === skill.id) {
|
||||
expandedEnvSkillId.value = ''
|
||||
function ensureEnvDrafts(skillId: string) {
|
||||
if (!envDrafts[skillId]) envDrafts[skillId] = {}
|
||||
}
|
||||
|
||||
function setEnvDraft(skillId: string, name: string, value: string) {
|
||||
ensureEnvDrafts(skillId)
|
||||
envDrafts[skillId][name] = value ?? ''
|
||||
}
|
||||
|
||||
function envInputLockKey(skillId: string, name: string) {
|
||||
return `${skillId}\n${name}`
|
||||
}
|
||||
|
||||
function isEnvInputUnlocked(skillId: string, name: string) {
|
||||
return envInputUnlocked[envInputLockKey(skillId, name)] === true
|
||||
}
|
||||
|
||||
function unlockEnvInput(skillId: string, name: string) {
|
||||
envInputUnlocked[envInputLockKey(skillId, name)] = true
|
||||
}
|
||||
|
||||
function resetEnvInputLocks() {
|
||||
for (const key of Object.keys(envInputUnlocked)) delete envInputUnlocked[key]
|
||||
}
|
||||
|
||||
function onEnvVisible(skill: ConfigSkill, visible: boolean, context?: { e?: Event }) {
|
||||
if (visible) {
|
||||
if (!skillHasDeclaredEnvs(skill)) return
|
||||
filesDrawerVisible.value = false
|
||||
expandedSkillId.value = ''
|
||||
if (expandedEnvSkillId.value !== skill.id) {
|
||||
// Reopening starts from a clean slate rather than resurrecting a
|
||||
// half-typed secret from the last time the editor was open.
|
||||
envDrafts[skill.id] = {}
|
||||
resetEnvInputLocks()
|
||||
expandedEnvSkillId.value = skill.id
|
||||
} else {
|
||||
ensureEnvDrafts(skill.id)
|
||||
}
|
||||
return
|
||||
}
|
||||
// Reopening starts from a clean slate rather than resurrecting a half-typed
|
||||
// secret from the last time the editor was open.
|
||||
envDrafts[skill.id] = {}
|
||||
expandedEnvSkillId.value = skill.id
|
||||
// The clear confirm is another body-attached popup, so TDesign treats a
|
||||
// click on it as an outside click on this editor.
|
||||
const target = context?.e?.target
|
||||
if (target instanceof Element && target.closest('.t-popconfirm')) {
|
||||
return
|
||||
}
|
||||
if (expandedEnvSkillId.value === skill.id) {
|
||||
expandedEnvSkillId.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
function envPayload(skill: ConfigSkill): Record<string, string> {
|
||||
|
|
@ -1379,101 +1464,6 @@ onUnmounted(() => {
|
|||
box-shadow: 0 0 0 2px var(--td-brand-color-focus, rgba(0, 168, 112, 0.18));
|
||||
}
|
||||
|
||||
.skill-item__envs {
|
||||
grid-column: 1 / -1;
|
||||
border-top: 1px solid var(--td-component-stroke);
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.skill-envs__none {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
|
||||
.skill-envs__title {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
.skill-envs__hint {
|
||||
margin: 2px 0 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.skill-envs__rows {
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.skill-envs__row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.skill-envs__meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.skill-envs__name {
|
||||
font-family: var(--td-font-family-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-primary);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.skill-envs__tag {
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
padding: 0 8px;
|
||||
border-radius: 10px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.skill-envs__tag--required {
|
||||
background: var(--td-warning-color-light);
|
||||
color: var(--td-warning-color);
|
||||
}
|
||||
|
||||
.skill-envs__tag--set {
|
||||
background: var(--td-success-color-light);
|
||||
color: var(--td-success-color);
|
||||
}
|
||||
|
||||
.skill-envs__desc {
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.skill-envs__editor {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.skill-envs__editor :deep(.t-input__wrap) {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.skill-envs__footer {
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.skill-status-ring {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
|
|
@ -1610,6 +1600,11 @@ onUnmounted(() => {
|
|||
align-items: center;
|
||||
gap: 2px;
|
||||
flex-shrink: 0;
|
||||
|
||||
:deep(.t-popup),
|
||||
:deep(.t-popup__reference) {
|
||||
display: inline-flex;
|
||||
}
|
||||
}
|
||||
|
||||
.skill-item__actions-divider {
|
||||
|
|
@ -1631,8 +1626,13 @@ onUnmounted(() => {
|
|||
background: transparent;
|
||||
color: var(--td-text-color-placeholder);
|
||||
cursor: pointer;
|
||||
line-height: 0;
|
||||
transition: background 0.15s ease, color 0.15s ease;
|
||||
|
||||
:deep(.t-icon) {
|
||||
display: block;
|
||||
}
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-primary);
|
||||
|
|
@ -1664,6 +1664,13 @@ onUnmounted(() => {
|
|||
background: var(--td-error-color-1, var(--td-bg-color-secondarycontainer));
|
||||
color: var(--td-error-color);
|
||||
}
|
||||
|
||||
/* TDesign's key glyph sits in a smaller ink box than folder/refresh/delete. */
|
||||
&--key :deep(.t-icon) {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
.skill-item__live-dot {
|
||||
|
|
@ -1694,7 +1701,8 @@ onUnmounted(() => {
|
|||
</style>
|
||||
|
||||
<style lang="less">
|
||||
.skill-transcript-popup {
|
||||
.skill-transcript-popup,
|
||||
.skill-env-popup {
|
||||
z-index: 3200 !important;
|
||||
|
||||
.t-popup__content {
|
||||
|
|
@ -1749,6 +1757,27 @@ onUnmounted(() => {
|
|||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
|
||||
&__close {
|
||||
flex-shrink: 0;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
&__body {
|
||||
max-height: min(360px, 52vh);
|
||||
overflow: auto;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: var(--td-bg-color-component-disabled);
|
||||
border-radius: 3px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.skill-transcript-popup {
|
||||
&__status {
|
||||
color: var(--td-text-color-secondary);
|
||||
|
||||
|
|
@ -1766,24 +1795,103 @@ onUnmounted(() => {
|
|||
}
|
||||
}
|
||||
|
||||
&__close {
|
||||
flex-shrink: 0;
|
||||
color: var(--td-text-color-secondary);
|
||||
&__body {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
}
|
||||
}
|
||||
|
||||
.skill-env-popup {
|
||||
.t-popup__content {
|
||||
width: 440px;
|
||||
max-width: min(440px, calc(100vw - 32px));
|
||||
}
|
||||
|
||||
&__body {
|
||||
max-height: min(360px, 52vh);
|
||||
overflow: auto;
|
||||
padding: 12px 14px 14px;
|
||||
background: var(--td-bg-color-container);
|
||||
}
|
||||
|
||||
&__footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 10px 14px;
|
||||
border-top: 1px solid var(--td-component-stroke);
|
||||
}
|
||||
|
||||
.skill-envs__hint {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.skill-envs__rows {
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.skill-envs__row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.skill-envs__meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.skill-envs__name {
|
||||
font-family: var(--td-font-family-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-primary);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.skill-envs__tag {
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
padding: 0 8px;
|
||||
border-radius: 10px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
.skill-envs__tag--required {
|
||||
background: var(--td-warning-color-light);
|
||||
color: var(--td-warning-color);
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: var(--td-bg-color-component-disabled);
|
||||
border-radius: 3px;
|
||||
}
|
||||
.skill-envs__tag--set {
|
||||
background: var(--td-success-color-light);
|
||||
color: var(--td-success-color);
|
||||
}
|
||||
|
||||
.skill-envs__desc {
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.skill-envs__editor {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.skill-envs__editor .t-input__wrap {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* readonly is only there to block password-manager fill; keep the field looking editable. */
|
||||
.skill-envs__editor .t-input.t-is-readonly {
|
||||
cursor: text;
|
||||
background-color: var(--td-bg-color-specialcomponent);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import {
|
|||
isSkillEnvSaveInFlight,
|
||||
isValidEnvName,
|
||||
isValidEnvValueLength,
|
||||
skillHasDeclaredEnvs,
|
||||
sortedConfigGroups,
|
||||
statusOf,
|
||||
} from './envVarState'
|
||||
|
|
@ -174,6 +175,13 @@ test('canClearAdminSkillEnv is only true once a workspace value is stored', () =
|
|||
assert.equal(canClearAdminSkillEnv({}), false)
|
||||
})
|
||||
|
||||
test('skillHasDeclaredEnvs is true only when the installer declared variables', () => {
|
||||
assert.equal(skillHasDeclaredEnvs({}), false)
|
||||
assert.equal(skillHasDeclaredEnvs({ envs: null }), false)
|
||||
assert.equal(skillHasDeclaredEnvs({ envs: [] }), false)
|
||||
assert.equal(skillHasDeclaredEnvs({ envs: [{ name: 'WEKNORA_API_KEY' }] }), true)
|
||||
})
|
||||
|
||||
test('editedSkillEnvPayload includes only drafted names declared by the skill', () => {
|
||||
assert.deepEqual(
|
||||
editedSkillEnvPayload(['TOKEN', 'EMPTY'], {
|
||||
|
|
|
|||
|
|
@ -54,6 +54,11 @@ export function canClearAdminSkillEnv(env: { is_set?: boolean }): boolean {
|
|||
return env.is_set === true
|
||||
}
|
||||
|
||||
/** The key control only belongs on a skill that declared at least one variable. */
|
||||
export function skillHasDeclaredEnvs(skill: { envs?: readonly unknown[] | null }): boolean {
|
||||
return (skill.envs?.length ?? 0) > 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a submitted draft only if it still equals the sent value. New input
|
||||
* typed while the request was in flight always wins over response cleanup.
|
||||
|
|
|
|||
Loading…
Reference in New Issue