fix: resolve review findings (P1/P2/P3)

P1: Remove unused injects and functions
- Remove unused appOpenPromptPreview inject from ContextSystemWorkspace
- Remove unused appOpenPromptPreview inject from ContextUserWorkspace
- Remove unused handleOpenToolManager/handleOpenVariableManager from ContextUserWorkspace

P2: Fix saveToGlobal bypassing persistence
- Use variableManager.addVariable() instead of direct customVariables.value assignment
- This ensures proper validation and saveToStorage() is called

P3: Fix trailing whitespace in docs
- Remove trailing whitespace from replicate.md
- Remove trailing whitespace from style-learn.md
This commit is contained in:
linshen
2026-05-04 16:41:16 +08:00
parent 96f2f23aa9
commit 1187716942
5 changed files with 14 additions and 24 deletions

View File

@@ -59,8 +59,8 @@ After analysis, it generates:
Reference image: A cyberpunk-style city night scene
Generated prompt:
A futuristic city night scene, neon lights闪烁, towering buildings,
rain-soaked streets reflecting colorful lights, cyberpunk style,
A futuristic city night scene, neon lights闪烁, towering buildings,
rain-soaked streets reflecting colorful lights, cyberpunk style,
high contrast, purple and blue as main colors
Extracted variables:
@@ -76,8 +76,8 @@ Extracted variables:
Reference image: A portrait using golden ratio composition
Generated prompt:
A portrait of a young woman, using golden ratio composition,
soft natural light, shallow depth of field, warm tones,
A portrait of a young woman, using golden ratio composition,
soft natural light, shallow depth of field, warm tones,
photography style
Extracted variables:

View File

@@ -74,7 +74,7 @@ An orange cat sitting on a windowsill, sunlight shining on it
Reference image: A warm-toned, soft-lighting photography work
Generated stylized prompt:
An orange cat sitting on a windowsill, sunlight shining on it,
An orange cat sitting on a windowsill, sunlight shining on it,
warm tones, soft light transitions, cozy atmosphere, photography style
Extracted variables:
@@ -93,8 +93,8 @@ A snowy mountain with snow on the peak
Reference image: A landscape photo shot from low angle, emphasizing foreground
Generated stylized prompt:
A snowy mountain with snow on the peak, low angle shot,
emphasizing foreground, vast视野, magnificent atmosphere,
A snowy mountain with snow on the peak, low angle shot,
emphasizing foreground, vast视野, magnificent atmosphere,
landscape photography style
Extracted variables:
@@ -113,7 +113,7 @@ A samurai holding a long sword
Reference image: An ukiyo-e style illustration
Generated stylized prompt:
A samurai holding a long sword, ukiyo-e style, flat processing,
A samurai holding a long sword, ukiyo-e style, flat processing,
traditional Japanese colors, decorative lines, artistic illustration
Extracted variables:

View File

@@ -1761,9 +1761,12 @@ provide("openVariableManager", (variableName?: string) => {
// 提供 saveToGlobal 接口(供 Pro 工作区将临时变量保存到全局)
provide("saveToGlobal", (name: string, value: string) => {
variableManager?.customVariables?.value
? (variableManager.customVariables.value[name] = value)
: undefined;
try {
variableManager.addVariable(name, value);
} catch (error) {
console.error('[PromptOptimizerApp] Failed to save variable to global:', error);
throw error;
}
});
// 提供 openPromptPreview 接口(供 Pro 工作区打开提示词预览面板)

View File

@@ -686,7 +686,6 @@ const appOpenToolManager = inject<(() => void) | null>('openToolManager', null)
const appOpenVariableManager = inject<((variableName?: string) => void) | null>('openVariableManager', null)
const appHandleSaveFavorite = inject<((data: SaveFavoritePayload) => void) | null>('handleSaveFavorite', null)
const appSaveToGlobal = inject<((name: string, value: string) => void) | null>('saveToGlobal', null)
const appOpenPromptPreview = inject<(() => void) | null>('openPromptPreview', null)
// Pro Multi: message list is session-owned (per-submode isolation).
// Keep emitting update:optimizationContext only as a backward-compat hook for non-App hosts.

View File

@@ -727,7 +727,6 @@ const appOpenToolManager = inject<(() => void) | null>('openToolManager', null)
const appOpenVariableManager = inject<((variableName?: string) => void) | null>('openVariableManager', null)
const appHandleSaveFavorite = inject<((data: SaveFavoritePayload) => void) | null>('handleSaveFavorite', null)
const appSaveToGlobal = inject<((name: string, value: string) => void) | null>('saveToGlobal', null)
const appOpenPromptPreview = inject<(() => void) | null>('openPromptPreview', null)
const handleOpenModelManager = () => {
if (appOpenModelManager) {
@@ -747,17 +746,6 @@ const handleOpenTemplateManager = (typeOrPayload?: string | Record<string, unkno
emit('open-template-manager', type)
}
// Pro 工作区专有功能的处理函数(优先使用 injectemit 作为兜底)
const handleOpenToolManager = () => {
if (appOpenToolManager) { appOpenToolManager(); return; }
emit('open-tool-manager')
}
const handleOpenVariableManager = () => {
if (appOpenVariableManager) { appOpenVariableManager(); return; }
emit('open-variable-manager')
}
const handleSaveFavorite = (data: SaveFavoritePayload) => {
if (appHandleSaveFavorite) { appHandleSaveFavorite(data); return; }
emit('save-favorite', data)