诊断:Skill 目录读取失败不再静默
- skillReferenceProvider 的 loadSkillCatalog 失败分支补 console.warn('[skill-reference] …'),带上是哪一次重试、错在哪,排障时不再只能看到「敲 $ 没反应」
- referenceSourceProviders 用例断言这条日志(并用 vi.restoreAllMocks 收尾),把「失败可重试」与「失败留痕」两件事一起钉住
This commit is contained in:
+7
-1
@@ -75,7 +75,13 @@ export function useSkillReferenceProvider(): ReferenceProvider {
|
||||
requestedRef.current = true;
|
||||
void loadSkillCatalog()
|
||||
.then((items) => setSkills(items))
|
||||
.catch(() => {
|
||||
.catch((error) => {
|
||||
// 失败不静默:一次瞬时失败下一次 `match` 会重试,但持续失败至少要在控制台留痕,
|
||||
// 否则用户看到的是「敲 `$` 什么都没有」,排障时没有任何线索。
|
||||
console.warn(
|
||||
'[skill-reference] Skill 目录读取失败,下次触发重试',
|
||||
error,
|
||||
);
|
||||
requestedRef.current = false;
|
||||
setSkills([]);
|
||||
});
|
||||
|
||||
@@ -64,6 +64,7 @@ const attachmentPart: DirectCodexUserContentPart = {
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
vi.restoreAllMocks();
|
||||
window.__TAURI__ = undefined;
|
||||
});
|
||||
|
||||
@@ -373,7 +374,8 @@ describe('Skill provider', () => {
|
||||
expect(result.current.match?.('client-plugin')).toEqual([]);
|
||||
});
|
||||
|
||||
it('一次瞬时失败不锁死候选:下一次 `match` 还会重读目录', async () => {
|
||||
it('一次瞬时失败不锁死候选:下一次 `match` 还会重读目录,并在控制台留痕', async () => {
|
||||
const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
||||
const invoke = vi
|
||||
.fn(async (command: string) => {
|
||||
if (command === 'list_agc_skill_catalog') {
|
||||
@@ -400,6 +402,11 @@ describe('Skill provider', () => {
|
||||
expect(result.current.match?.('')).toHaveLength(1);
|
||||
});
|
||||
expect(invoke).toHaveBeenCalledTimes(4);
|
||||
// 读取失败不能静默:控制台要留下可排障的一条。
|
||||
expect(warn).toHaveBeenCalledWith(
|
||||
'[skill-reference] Skill 目录读取失败,下次触发重试',
|
||||
expect.any(Error),
|
||||
);
|
||||
});
|
||||
|
||||
it('`toReference` / `refresh` / `mentionToken` 只认 Skill', async () => {
|
||||
|
||||
Reference in New Issue
Block a user