Skip to content

feat: add preset selector in TasksPage #19012

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jul 24, 2025
Merged

feat: add preset selector in TasksPage #19012

merged 17 commits into from
Jul 24, 2025

Conversation

johnstcn
Copy link
Member

@johnstcn johnstcn commented Jul 23, 2025

  • Adds a preset selector in TasksPage that is visible if the selected template version defines presets, with the default preset pre-selected and at the top of the list.
  • If no default preset exists, the user is prompted to select one.
  • If a preset defines an AI Prompt, it will override the textarea.

@johnstcn johnstcn self-assigned this Jul 23, 2025
@johnstcn johnstcn force-pushed the cj/tasks-preset-selector branch from 0a11e8e to ebeb601 Compare July 24, 2025 11:32
@johnstcn johnstcn marked this pull request as ready for review July 24, 2025 11:44
@johnstcn johnstcn requested a review from Copilot July 24, 2025 11:45
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a preset selector to the TasksPage that appears when the selected template version has defined presets. If a preset contains an AI Prompt parameter, it overrides the textarea input and makes it read-only.

  • Adds preset selection functionality with automatic default preset selection
  • Implements AI prompt override behavior when presets contain AI Prompt parameters
  • Refactors test data by moving mock objects to shared test helpers for better reusability

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
site/src/testHelpers/entities.ts Adds mock preset data and task data for testing preset functionality
site/src/pages/TasksPage/TasksPage.tsx Implements preset selector UI, preset fetching logic, and AI prompt override behavior
site/src/pages/TasksPage/TasksPage.stories.tsx Updates stories to use shared mock data and adds new stories for preset scenarios

>
<SelectTrigger
id="templateID"
className="w-80 text-xs [&_svg]:size-icon-xs border-0 bg-surface-secondary h-8 px-3"
Copy link
Preview

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

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

The template and preset selectors use identical styling (w-80 text-xs [&_svg]:size-icon-xs border-0 bg-surface-secondary h-8 px-3). Consider extracting this into a CSS class or constant to avoid duplication.

Suggested change
className="w-80 text-xs [&_svg]:size-icon-xs border-0 bg-surface-secondary h-8 px-3"
className="select-trigger-style"

Copilot uses AI. Check for mistakes.

Comment on lines -312 to -342
const MockTasks = [
{
workspace: {
...MockWorkspace,
latest_app_status: MockWorkspaceAppStatus,
},
prompt: "Create competitors page",
},
{
workspace: {
...MockWorkspace,
id: "workspace-2",
latest_app_status: {
...MockWorkspaceAppStatus,
message: "Avatar size fixed!",
},
},
prompt: "Fix user avatar size",
},
{
workspace: {
...MockWorkspace,
id: "workspace-3",
latest_app_status: {
...MockWorkspaceAppStatus,
message: "Accessibility issues fixed!",
},
},
prompt: "Fix accessibility issues",
},
];
Copy link
Member Author

Choose a reason for hiding this comment

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

review: moved to entities.ts

@johnstcn johnstcn requested a review from mtojek July 24, 2025 11:58
Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

I don't feel super comfortable with extra useEffects, but I assume that we need to reload it dynamically, right?

</SelectTrigger>
<SelectContent>
{presets
.sort((a, b) => {
Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe extract to a seperate function with a comment?

// Extract AI prompt from selected preset
const selectedPreset = presets?.find((p) => p.ID === selectedPresetId);
const presetAIPrompt = selectedPreset?.Parameters.find(
(param) => param.Name === AI_PROMPT_PARAMETER_NAME,
Copy link
Member

Choose a reason for hiding this comment

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

nit: is it special/magic parameter now?

Copy link
Member Author

Choose a reason for hiding this comment

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

always has been

@jaaydenh
Copy link
Contributor

Is selecting a preset required? On the create workspace page I added a "None" to make it explicit that choosing a preset is not necessary.

@johnstcn
Copy link
Member Author

Is selecting a preset required? On the create workspace page I added a "None" to make it explicit that choosing a preset is not necessary.

Right now it technically isn't, although presets are currently the only way to expose parameter values on Tasks page. I can add a "none" option for consistency.

placeholder={textareaPlaceholder}
className={`border-0 resize-none w-full h-full bg-transparent rounded-lg outline-none flex min-h-[60px]
text-sm shadow-sm text-content-primary placeholder:text-content-secondary md:text-sm`}
text-sm shadow-sm text-content-primary placeholder:text-content-secondary md:text-sm ${
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this could be done later but it can be confusing for users that the Prompt is disabled because of a preset. In the dynamic parameters create workspace page, I label parameters when they are preset as such so user know why they can't be edited.

Copy link
Member Author

Choose a reason for hiding this comment

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

I could add a quick tooltip here

Copy link
Member Author

@johnstcn johnstcn Jul 24, 2025

Choose a reason for hiding this comment

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

Addressed in 0fd55e2

@johnstcn johnstcn force-pushed the cj/tasks-preset-selector branch from f6ecc40 to b3916e2 Compare July 24, 2025 17:20
Copy link
Contributor

@jaaydenh jaaydenh left a comment

Choose a reason for hiding this comment

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

LGTM

@johnstcn johnstcn merged commit 9a05a8a into main Jul 24, 2025
31 of 32 checks passed
@johnstcn johnstcn deleted the cj/tasks-preset-selector branch July 24, 2025 19:19
@github-actions github-actions bot locked and limited conversation to collaborators Jul 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants