Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5ff503b

Browse files
fix: force task to be created with latest version (#19923)
Fixes#19744
1 parentacc0890 commit5ff503b

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

‎site/src/pages/TasksPage/TaskPrompt.tsx‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,12 @@ const CreateTaskForm: FC<CreateTaskFormProps> = ({ templates, onSuccess }) => {
186186

187187
constcreateTaskMutation=useMutation({
188188
mutationFn:async({ prompt}:CreateTaskMutationFnProps)=>
189-
API.experimental.createTask(user.id,{
189+
createTaskWithLatestTemplateVersion(
190190
prompt,
191-
template_version_id:selectedTemplate.active_version_id,
192-
template_version_preset_id:selectedPresetId,
193-
}),
191+
user.id,
192+
selectedTemplate.id,
193+
selectedPresetId,
194+
),
194195
onSuccess:async(task)=>{
195196
awaitqueryClient.invalidateQueries({queryKey:["tasks"]});
196197
onSuccess(task);
@@ -427,3 +428,21 @@ function sortByDefault(a: Preset, b: Preset) {
427428
// Otherwise, sort alphabetically by name
428429
returna.Name.localeCompare(b.Name);
429430
}
431+
432+
// TODO: Enforce task creation to always use the latest active template version.
433+
// During task creation, the active version might change between template load
434+
// and user action. Since handling this in the FE cannot guarantee correctness,
435+
// we should move the logic to the BE after the experimental phase.
436+
asyncfunctioncreateTaskWithLatestTemplateVersion(
437+
prompt:string,
438+
userId:string,
439+
templateId:string,
440+
presetId:string|undefined,
441+
):Promise<Task>{
442+
consttemplate=awaitAPI.getTemplate(templateId);
443+
returnAPI.experimental.createTask(userId,{
444+
prompt,
445+
template_version_id:template.active_version_id,
446+
template_version_preset_id:presetId,
447+
});
448+
}

‎site/src/pages/TasksPage/TasksPage.stories.tsx‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,12 @@ export const CreateTaskSuccessfully: Story = {
245245
}),
246246
},
247247
beforeEach:()=>{
248+
constactiveVersionId=`${MockTemplate.active_version_id}-latest`;
248249
spyOn(API,"getTemplates").mockResolvedValue([MockTemplate]);
250+
spyOn(API,"getTemplate").mockResolvedValue({
251+
...MockTemplate,
252+
active_version_id:activeVersionId,
253+
});
249254
spyOn(API.experimental,"getTasks")
250255
.mockResolvedValueOnce(MockTasks)
251256
.mockResolvedValue([MockNewTaskData, ...MockTasks]);
@@ -262,6 +267,17 @@ export const CreateTaskSuccessfully: Story = {
262267
awaituserEvent.click(submitButton);
263268
});
264269

270+
awaitstep("Uses latest template version",()=>{
271+
expect(API.experimental.createTask).toHaveBeenCalledWith(
272+
MockUserOwner.id,
273+
{
274+
prompt:MockNewTaskData.prompt,
275+
template_version_id:`${MockTemplate.active_version_id}-latest`,
276+
template_version_preset_id:undefined,
277+
},
278+
);
279+
});
280+
265281
awaitstep("Displays success message",async()=>{
266282
constbody=within(canvasElement.ownerDocument.body);
267283
constsuccessMessage=awaitbody.findByText(/taskcreated/i);
@@ -281,6 +297,7 @@ export const CreateTaskError: Story = {
281297
decorators:[withGlobalSnackbar],
282298
beforeEach:()=>{
283299
spyOn(API,"getTemplates").mockResolvedValue([MockTemplate]);
300+
spyOn(API,"getTemplate").mockResolvedValue(MockTemplate);
284301
spyOn(API.experimental,"getTasks").mockResolvedValue(MockTasks);
285302
spyOn(API.experimental,"createTask").mockRejectedValue(
286303
mockApiError({

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp