Skip to content

Commit f33bb8a

Browse files
authored
[fix] [prompt] prompt clone var error (#20)
* fix(prompt): url after delete * fix(prompt): copy vars
1 parent 42744bf commit f33bb8a

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

frontend/packages/cozeloop/prompt-pages/src/components/prompt-header/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ export function PromptHeader() {
538538
onCacnel={deleteModal.close}
539539
onOk={() => {
540540
deleteModal.close();
541-
navigate('pe/prompts');
541+
navigate(`${baseURL}/pe/prompts`);
542542
}}
543543
/>
544544
</div>

frontend/packages/cozeloop/prompt-pages/src/hooks/use-prompt.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,17 @@ export const usePrompt = ({
134134
};
135135
});
136136
setHistoricMessage(historicMessage);
137-
const mockVariables =
138-
mockRes.debug_context?.debug_core?.mock_variables || [];
139-
setMockVariables(mockVariables);
137+
setMockVariables(array =>
138+
array.map(it => {
139+
const mock = (
140+
mockRes.debug_context?.debug_core?.mock_variables || []
141+
).find(v => v.key === it.key);
142+
return {
143+
...it,
144+
value: mock?.value,
145+
};
146+
}),
147+
);
140148
const mockTools =
141149
mockRes.debug_context?.debug_core?.mock_tools || [];
142150
setMockTools(mockTools);

frontend/packages/cozeloop/prompt-pages/src/utils/prompt.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) 2025 coze-dev Authors
22
// SPDX-License-Identifier: Apache-2.0
3+
/* eslint-disable arrow-body-style */
34
/* eslint-disable security/detect-object-injection */
45
/* eslint-disable @typescript-eslint/no-explicit-any */
56
import { uniqueId } from 'lodash-es';
@@ -114,10 +115,6 @@ export const getMockVariables = (
114115
variables: VariableDef[],
115116
mockVariables: VariableVal[],
116117
) => {
117-
const map = new Map();
118-
variables.forEach((item, index) => {
119-
map.set(item.key, index);
120-
});
121118
return variables.map(item => {
122119
const mockVariable = mockVariables.find(it => it.key === item.key);
123120
return {

0 commit comments

Comments
 (0)