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

fix: force task to be created with latest version#19923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
BrunoQuaresma merged 3 commits intomainfrombq/force-latest-template-version
Sep 24, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
feat: force task to be created with latest version
  • Loading branch information
@BrunoQuaresma
BrunoQuaresma committedSep 23, 2025
commitacd3bdfd878a35ffd7225607454004dd6100d0e7
27 changes: 23 additions & 4 deletionssite/src/pages/TasksPage/TaskPrompt.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -189,11 +189,12 @@ const CreateTaskForm: FC<CreateTaskFormProps> = ({ templates, onSuccess }) => {

const createTaskMutation = useMutation({
mutationFn: async ({ prompt }: CreateTaskMutationFnProps) =>
API.experimental.createTask(user.id, {
createTaskWithLatestTemplateVersion(
prompt,
template_version_id: selectedTemplate.active_version_id,
template_version_preset_id: selectedPresetId,
}),
user.id,
selectedTemplate.id,
selectedPresetId,
),
onSuccess: async (task) => {
await queryClient.invalidateQueries({
queryKey: ["tasks"],
Expand DownExpand Up@@ -432,3 +433,21 @@ function sortByDefault(a: Preset, b: Preset) {
// Otherwise, sort alphabetically by name
return a.Name.localeCompare(b.Name);
}

// TODO: Enforce task creation to always use the latest active template version.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

nit: this is rather FIXME than TODO :P

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

IsFIXME a valid thing? 👀

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah, we have a lot of fixmes in our codebase :)

PS. nit-pick!

// During task creation, the active version might change between template load
// and user action. Since handling this in the FE cannot guarantee correctness,
// we should move the logic to the BE after the experimental phase.
async function createTaskWithLatestTemplateVersion(
prompt: string,
userId: string,
templateId: string,
presetId: string | undefined,
): Promise<Task> {
const template = await API.getTemplate(templateId);
return API.experimental.createTask(userId, {
prompt,
template_version_id: template.active_version_id,
template_version_preset_id: presetId,
});
}
16 changes: 16 additions & 0 deletionssite/src/pages/TasksPage/TasksPage.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -244,7 +244,12 @@ export const CreateTaskSuccessfully: Story = {
}),
},
beforeEach: () => {
const activeVersionId = `${MockTemplate.active_version_id}-latest`;
spyOn(API, "getTemplates").mockResolvedValue([MockTemplate]);
spyOn(API, "getTemplate").mockResolvedValue({
...MockTemplate,
active_version_id: activeVersionId,
});
spyOn(API.experimental, "getTasks")
.mockResolvedValueOnce(MockTasks)
.mockResolvedValue([MockNewTaskData, ...MockTasks]);
Expand All@@ -261,6 +266,17 @@ export const CreateTaskSuccessfully: Story = {
await userEvent.click(submitButton);
});

await step("Uses latest template version", () => {
expect(API.experimental.createTask).toHaveBeenCalledWith(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Correct me if I'm wrong, but since this is a story not a unit test, you shouldn't assert API calls on that level?

Can we convert it to jest test instead?

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We’re using Storybook as our main testing tool. At some point, Jest will only be used for testing functions or other non-component-related code. Kayla did an awesome L&L yesterday about the FE state—I’m just trying to grab the link to share here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ok, TIL!

MockUserOwner.id,
{
prompt: MockNewTaskData.prompt,
template_version_id: `${MockTemplate.active_version_id}-latest`,
template_version_preset_id: undefined,
},
);
});

await step("Redirects to the task page", async () => {
await canvas.findByText(/task page/i);
});
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp