From 4356f8c16dcd5cae85652e9afebf63dc280334fc Mon Sep 17 00:00:00 2001 From: lyingbug Date: Tue, 13 Oct 2026 19:47:14 +0800 Subject: [PATCH] fix(skill): do not fail installs on non-blocking observations (#4246) * fix(skill): do not fail installs on non-blocking observations A working skill was rejected when the installer recorded a docs mismatch as a blocker. Keep real setup failures in blockers and surface harmless observations as notes. * style(skill): wrap the install-report validation error * feat(frontend): compact skill cards and install progress Show each sandbox install on the card and collapse installer prompts, so the skills page stays readable when a skill is installed in more than one place. * fix(chat): include shared KBs in starter questions and stop composer jitter Agents using all knowledge bases now draw starters from KBs shared into the tenant, matching chat retrieval. The new-chat page skips refetches whose scope did not change and only shows the skeleton on first load. --- .../src/components/SandboxSkillsPanel.vue | 26 +- .../src/components/SkillInstallTimeline.vue | 169 ++++++-- frontend/src/i18n/locales/en-US.ts | 2 + frontend/src/i18n/locales/ja-JP.ts | 2 + frontend/src/i18n/locales/ko-KR.ts | 2 + frontend/src/i18n/locales/ru-RU.ts | 2 + frontend/src/i18n/locales/zh-CN.ts | 2 + frontend/src/i18n/locales/zh-TW.ts | 2 + frontend/src/views/creatChat/creatChat.vue | 43 ++- frontend/src/views/settings/SkillSettings.vue | 360 +++++++++++++----- internal/application/service/custom_agent.go | 45 ++- .../custom_agent_suggestion_scope_test.go | 24 ++ .../service/tenant_skill_runtime_verify.go | 47 ++- .../tenant_skill_runtime_verify_test.go | 19 +- .../service/tenant_skill_verify.go | 3 +- 15 files changed, 572 insertions(+), 176 deletions(-) diff --git a/frontend/src/components/SandboxSkillsPanel.vue b/frontend/src/components/SandboxSkillsPanel.vue index faa7fc27..07ceb66c 100644 --- a/frontend/src/components/SandboxSkillsPanel.vue +++ b/frontend/src/components/SandboxSkillsPanel.vue @@ -102,7 +102,7 @@ { min-width: 0; } + :deep(.skill-timeline--compact) { + padding: 0; + } + :deep(.skill-timeline__guidance) { // Include the drawer's 18px side padding and 16px bottom padding. - --skill-guidance-gutter: 30px; + --skill-guidance-gutter: 18px; --skill-guidance-bottom-gap: 16px; margin-bottom: -12px; padding-bottom: 12px; @@ -1708,9 +1712,13 @@ onUnmounted(() => { .skill-manage__row { display: flex; - align-items: flex-start; + align-items: center; justify-content: space-between; gap: 16px; + padding: 12px 14px; + border: 1px solid var(--td-component-stroke); + border-radius: var(--app-radius-md); + background: var(--td-bg-color-container); } .skill-manage__served { @@ -1724,10 +1732,8 @@ onUnmounted(() => { } .skill-manage__row--upgrade { - align-items: center; - padding: var(--app-space-2) var(--app-space-3); - border-radius: var(--app-radius-sm); - background: color-mix(in srgb, var(--td-warning-color) 8%, transparent); + border-color: color-mix(in srgb, var(--td-warning-color) 30%, transparent); + background: color-mix(in srgb, var(--td-warning-color) 6%, transparent); } .skill-manage__controls { @@ -1761,13 +1767,13 @@ onUnmounted(() => { flex-direction: column; align-items: stretch; gap: 10px; - padding-top: 12px; - border-top: 1px solid var(--td-component-stroke); + padding-top: 4px; h4 { margin: 0; - font-size: var(--app-text-md); + font-size: var(--app-text-base); font-weight: 600; + line-height: 22px; color: var(--td-text-color-primary); } diff --git a/frontend/src/components/SkillInstallTimeline.vue b/frontend/src/components/SkillInstallTimeline.vue index 9bdb7ff0..788fec37 100644 --- a/frontend/src/components/SkillInstallTimeline.vue +++ b/frontend/src/components/SkillInstallTimeline.vue @@ -10,7 +10,14 @@ @@ -181,6 +198,11 @@ const { handleMsgList, processStreamChunk } = useChatStreamHandler({ // install_prompt is the installer's opening line. It is not an assistant // event, so it becomes the user turn here rather than going through the chat // stream handler. +function promptPreview(content: unknown): string { + const line = String(content || '').trim().split('\n')[0] || '' + return line.length > 80 ? `${line.slice(0, 80)}…` : line +} + function applyPrompt(content: string) { if (!content) return if (messages.some((msg) => msg.role === 'user')) return @@ -357,7 +379,6 @@ onUnmounted(stop) margin-top: 12px; padding-top: 12px; background: var(--td-bg-color-container); - border-top: 1px solid var(--td-component-stroke); // Cover the timeline's padding too, so scrolling text cannot peek around // the sticky composer. Its z-index keeps this backdrop above the transcript. @@ -372,21 +393,46 @@ onUnmounted(stop) } .skill-timeline__guidance-message { margin: 8px 0; - padding: 8px; - background: var(--td-bg-color-container); + padding: 8px 10px; + background: var(--td-bg-color-secondarycontainer); border-radius: var(--app-radius-sm); - span { font-size: var(--app-text-sm); color: var(--td-text-color-secondary); } - p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; } + span { font-size: var(--app-text-xs); color: var(--td-text-color-placeholder); } + p { margin: 4px 0 0; font-size: var(--app-text-sm); white-space: pre-wrap; overflow-wrap: anywhere; } +} +.skill-timeline__guidance-box { + border: 1px solid var(--td-component-stroke); + border-radius: var(--app-radius-md); + background: var(--td-bg-color-container); + transition: border-color var(--app-motion-fast) ease, box-shadow var(--app-motion-fast) ease; + + &:focus-within { + border-color: var(--td-brand-color); + box-shadow: 0 0 0 2px var(--td-brand-color-focus); + } + + :deep(.t-textarea__inner) { + padding: 10px 12px 4px; + border: 0; + box-shadow: none; + background: transparent; + resize: none; + } + + :deep(.t-textarea__info_wrapper), + :deep(.t-textarea__limit) { + display: none; + } } .skill-timeline__guidance-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; - margin-top: 8px; - span { flex: 1; font-size: var(--app-text-sm); color: var(--td-text-color-secondary); } + padding: 4px 8px 8px 12px; + span { flex: 1; font-size: var(--app-text-xs); color: var(--td-text-color-placeholder); } } -.skill-timeline__guidance-error { color: var(--td-error-color); font-size: var(--app-text-sm); } +.skill-timeline__guidance-count { font-variant-numeric: tabular-nums; } +.skill-timeline__guidance-error { margin: 6px 0 0; color: var(--td-error-color); font-size: var(--app-text-sm); } .skill-timeline { display: flex; @@ -402,17 +448,63 @@ onUnmounted(stop) } .skill-timeline__prompt { - max-height: 140px; - margin: 0; - padding: 8px 10px; - overflow-y: auto; - color: var(--td-text-color-secondary); - font-size: var(--app-text-sm); - line-height: 1.6; - background: var(--td-bg-color-container); + border: 1px solid var(--td-component-stroke); border-radius: var(--app-radius-sm); - white-space: pre-wrap; - word-break: break-word; + background: var(--td-bg-color-container); + + summary { + display: flex; + align-items: center; + gap: 6px; + min-width: 0; + padding: 6px 10px; + cursor: pointer; + list-style: none; + font-size: var(--app-text-sm); + line-height: 20px; + color: var(--td-text-color-secondary); + user-select: none; + + &::-webkit-details-marker { display: none; } + + &:hover { color: var(--td-text-color-primary); } + } + + pre { + max-height: 240px; + margin: 0; + padding: 8px 12px 10px; + overflow-y: auto; + border-top: 1px solid var(--td-component-stroke); + color: var(--td-text-color-secondary); + font-size: var(--app-text-xs); + line-height: 1.6; + white-space: pre-wrap; + word-break: break-word; + } + + &[open] .skill-timeline__prompt-arrow { transform: rotate(90deg); } + &[open] .skill-timeline__prompt-preview { display: none; } +} + +.skill-timeline__prompt-arrow { + flex-shrink: 0; + color: var(--td-text-color-placeholder); + transition: transform var(--app-motion-fast) ease; +} + +.skill-timeline__prompt-label { + flex-shrink: 0; + font-weight: 500; +} + +.skill-timeline__prompt-preview { + flex: 1; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + color: var(--td-text-color-placeholder); } .skill-timeline__empty { @@ -428,11 +520,8 @@ onUnmounted(stop) border-radius: 0; } -.skill-timeline--compact .skill-timeline__prompt { - max-height: 72px; - padding: 6px 8px; - font-size: var(--app-text-xs); - line-height: 1.5; +.skill-timeline--compact .skill-timeline__prompt pre { + max-height: 160px; } .skill-timeline--compact .skill-timeline__empty { diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts index 80a17599..f292cec8 100755 --- a/frontend/src/i18n/locales/en-US.ts +++ b/frontend/src/i18n/locales/en-US.ts @@ -1828,6 +1828,7 @@ export default { skillTranscriptLive: 'Install log', skillTranscriptLiveHint: 'Installing — click to watch', skillTranscriptTitle: 'Install run', + skillTranscriptPrompt: 'Install instructions', skillTranscriptHide: 'Hide install run', skillGuidance: { placeholder: 'Add installation guidance, such as required CLIs, setup documentation, or environment constraints', @@ -1946,6 +1947,7 @@ export default { installedCount: 'Installed on {count} sandboxes', installPanelGroup: 'Installed', installPanelAvailable: 'Not installed', + installAction: 'Install', viewInstallProgress: 'View progress', manageOnSandbox: 'Manage this skill on “{name}”', manageDrawerDesc: 'Manage enablement, variables, and uninstall on sandbox “{name}”.', diff --git a/frontend/src/i18n/locales/ja-JP.ts b/frontend/src/i18n/locales/ja-JP.ts index f07d5dc1..abd35651 100644 --- a/frontend/src/i18n/locales/ja-JP.ts +++ b/frontend/src/i18n/locales/ja-JP.ts @@ -1828,6 +1828,7 @@ export default { skillTranscriptLive: 'インストールログ', skillTranscriptLiveHint: 'インストール中 — クリックで表示', skillTranscriptTitle: 'インストールの実行内容', + skillTranscriptPrompt: 'インストール指示', skillTranscriptHide: 'インストールの実行内容を非表示', skillGuidance: { placeholder: '必要な CLI、インストール手順、環境の制約などを入力', @@ -1946,6 +1947,7 @@ export default { installedCount: '{count}個のサンドボックスにインストール済み', installPanelGroup: 'インストール済み', installPanelAvailable: '未インストール', + installAction: 'インストール', viewInstallProgress: '進捗を表示', manageOnSandbox: 'サンドボックス「{name}」でこのスキルを管理', manageDrawerDesc: 'サンドボックス「{name}」での有効化、変数、アンインストールを管理します。', diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts index 7f290077..fbaa4696 100755 --- a/frontend/src/i18n/locales/ko-KR.ts +++ b/frontend/src/i18n/locales/ko-KR.ts @@ -6259,6 +6259,7 @@ export default { skillTranscriptLive: '설치 과정', skillTranscriptLiveHint: '설치 중입니다. 클릭해서 과정을 보세요', skillTranscriptTitle: '설치 과정', + skillTranscriptPrompt: '설치 지시', skillTranscriptHide: 'Hide install run', skillGuidance: { placeholder: '필요한 CLI, 설치 문서, 환경 제약 등 설치 안내를 추가하세요', @@ -6377,6 +6378,7 @@ export default { installedCount: '{count}개 샌드박스에 설치됨', installPanelGroup: '설치됨', installPanelAvailable: '미설치', + installAction: '설치', viewInstallProgress: '진행 상황', manageOnSandbox: '「{name}」 샌드박스에서 관리', manageDrawerDesc: '샌드박스 「{name}」에서 사용 여부, 변수, 제거를 관리합니다.', diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts index 4c3594c1..3222f77f 100755 --- a/frontend/src/i18n/locales/ru-RU.ts +++ b/frontend/src/i18n/locales/ru-RU.ts @@ -6259,6 +6259,7 @@ export default { skillTranscriptLive: 'Ход установки', skillTranscriptLiveHint: 'Идёт установка — нажмите, чтобы смотреть', skillTranscriptTitle: 'Ход установки', + skillTranscriptPrompt: 'Инструкции по установке', skillTranscriptHide: 'Hide install run', skillGuidance: { placeholder: 'Добавьте указания по установке: нужные CLI, документацию или ограничения среды', @@ -6377,6 +6378,7 @@ export default { installedCount: 'Установлен в {count} песочницах', installPanelGroup: 'Установлено', installPanelAvailable: 'Не установлено', + installAction: 'Установить', viewInstallProgress: 'Смотреть ход', manageOnSandbox: 'Управление в песочнице «{name}»', manageDrawerDesc: 'В песочнице «{name}» можно включать навык, править переменные и удалять установку.', diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts index 5dc856c6..69a1618a 100755 --- a/frontend/src/i18n/locales/zh-CN.ts +++ b/frontend/src/i18n/locales/zh-CN.ts @@ -6261,6 +6261,7 @@ export default { skillTranscriptLive: '安装过程', skillTranscriptLiveHint: '正在安装,点击查看过程', skillTranscriptTitle: '安装过程', + skillTranscriptPrompt: '安装指令', skillTranscriptHide: '收起安装过程', skillGuidance: { placeholder: '补充安装说明,例如需要安装的 CLI、安装文档或环境限制', @@ -6379,6 +6380,7 @@ export default { installedCount: '已安装到 {count} 个沙箱', installPanelGroup: '已安装', installPanelAvailable: '未安装', + installAction: '安装', viewInstallProgress: '查看进度', manageOnSandbox: '管理沙箱「{name}」上的安装', manageDrawerDesc: '在沙箱「{name}」上管理启用、变量和卸载。', diff --git a/frontend/src/i18n/locales/zh-TW.ts b/frontend/src/i18n/locales/zh-TW.ts index 8a36b5b8..c88c9131 100644 --- a/frontend/src/i18n/locales/zh-TW.ts +++ b/frontend/src/i18n/locales/zh-TW.ts @@ -6261,6 +6261,7 @@ export default { skillTranscriptLive: '安裝過程', skillTranscriptLiveHint: '正在安裝,點擊查看過程', skillTranscriptTitle: '安裝過程', + skillTranscriptPrompt: '安裝指令', skillTranscriptHide: '收起安裝過程', skillGuidance: { placeholder: '補充安裝說明,例如需要安裝的 CLI、安裝文件或環境限制', @@ -6379,6 +6380,7 @@ export default { installedCount: '已安裝到 {count} 個沙箱', installPanelGroup: '已安裝', installPanelAvailable: '未安裝', + installAction: '安裝', viewInstallProgress: '查看進度', manageOnSandbox: '管理沙箱「{name}」上的安裝', manageDrawerDesc: '在沙箱「{name}」上管理啟用、變數和解除安裝。', diff --git a/frontend/src/views/creatChat/creatChat.vue b/frontend/src/views/creatChat/creatChat.vue index 6f8ddfd8..aaa05477 100644 --- a/frontend/src/views/creatChat/creatChat.vue +++ b/frontend/src/views/creatChat/creatChat.vue @@ -7,7 +7,7 @@
-
+
@@ -25,7 +25,7 @@ {{ $t('chat.suggestedQuestions') }} @@ -118,12 +118,20 @@ const showChatContextualGuide = computed(() => { // ===== 推荐问题 ===== const suggestedQuestions = ref([]); const sqLoading = ref(true); +// The skeleton reserves space only until the first answer arrives. Later +// refetches keep the current content in place, so the composer below does not +// jump each time the agent or @mention selection changes. +const sqInitialLoad = ref(true); const sqCardsRevealed = ref(false); const sqRenderKey = ref(0); const sqContainerRef = ref(null); let suggestedQuestionsFetchId = 0; +let lastSuggestedQuestionsKey = ''; let debounceTimer: ReturnType | null = null; +const sameSuggestedQuestions = (a: SuggestedQuestion[], b: SuggestedQuestion[]) => + a.length === b.length && a.every((item, i) => item.question === b[i].question && item.source === b[i].source); + // --- 高度平滑过渡钩子 --- const onBeforeLeave = () => { const c = sqContainerRef.value; @@ -166,26 +174,39 @@ const onQuestionsEntered = () => { nextTick(() => { sqCardsRevealed.value = true; }); }; -const fetchSuggestedQuestions = async () => { +const fetchSuggestedQuestions = async (force = false) => { + const agentId = settingsStore.selectedAgentId; + const params = settingsStore.getSuggestedQuestionsParams(); + const requestKey = JSON.stringify([agentId, params]); + if (!force && requestKey === lastSuggestedQuestionsKey) return; + lastSuggestedQuestionsKey = requestKey; + const fetchId = ++suggestedQuestionsFetchId; sqLoading.value = true; try { - const agentId = settingsStore.selectedAgentId; - if (!agentId) return; - const res = await getSuggestedQuestions(agentId, settingsStore.getSuggestedQuestionsParams()); + if (!agentId) { + suggestedQuestions.value = []; + return; + } + const res = await getSuggestedQuestions(agentId, params); if (fetchId === suggestedQuestionsFetchId) { - sqCardsRevealed.value = false; - sqRenderKey.value++; - suggestedQuestions.value = res?.data?.questions || []; + const next = res?.data?.questions || []; + if (!sameSuggestedQuestions(suggestedQuestions.value, next)) { + sqCardsRevealed.value = false; + sqRenderKey.value++; + suggestedQuestions.value = next; + } } } catch (err) { console.warn('[SuggestedQuestions] Failed to fetch:', err); if (fetchId === suggestedQuestionsFetchId) { + lastSuggestedQuestionsKey = ''; suggestedQuestions.value = []; } } finally { if (fetchId === suggestedQuestionsFetchId) { sqLoading.value = false; + sqInitialLoad.value = false; } } }; @@ -196,15 +217,13 @@ const debouncedFetch = () => { debounceTimer = setTimeout(() => { fetchSuggestedQuestions(); }, 300); }; -// 监听 Agent / 知识库 / 文件 / 标签 / MCP / Skill @mention +// 监听 Agent / 知识库 / 文件 / 标签 @mention;MCP 与 Skill 不影响推荐范围 watch( () => ({ agentId: settingsStore.selectedAgentId, kbs: settingsStore.settings.selectedKnowledgeBases, files: settingsStore.settings.selectedFiles, tags: settingsStore.settings.selectedTags, - mcps: settingsStore.settings.selectedMCPServices, - skills: settingsStore.settings.selectedSkills, }), debouncedFetch, { deep: true }, diff --git a/frontend/src/views/settings/SkillSettings.vue b/frontend/src/views/settings/SkillSettings.vue index c8eabb4c..28506fa7 100644 --- a/frontend/src/views/settings/SkillSettings.vue +++ b/frontend/src/views/settings/SkillSettings.vue @@ -62,8 +62,8 @@
-