mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
refactor: remove deprecated AITaskPromptParameterName constant (#21023)
This removes the deprecated AITaskPromptParameterName constant and all backward compatibility code that was added for v2.28. - Remove AITaskPromptParameterName constant from codersdk/aitasks.go - Remove backward compatibility code in coderd/aitasks.go that populated the "AI Prompt" parameter for templates that defined it - Remove the backward compatibility test (OK AIPromptBackCompat) - Update dbfake to no longer set the AI Prompt parameter - Remove AITaskPromptParameterName from frontend TypeScript types - Remove preset prompt read-only feature from TaskPrompt component - Update docs to reflect that pre-2.28 definition is no longer supported Task prompts are now exclusively stored in the tasks.prompt database column, as introduced in the migration that added the tasks table.
This commit is contained in:
Generated
-16
@@ -108,22 +108,6 @@ export interface AIConfig {
|
||||
readonly bridge?: AIBridgeConfig;
|
||||
}
|
||||
|
||||
// From codersdk/aitasks.go
|
||||
/**
|
||||
* AITaskPromptParameterName is the name of the parameter used to pass prompts
|
||||
* to AI tasks.
|
||||
*
|
||||
* Deprecated: This constant is deprecated and maintained only for backwards
|
||||
* compatibility with older templates. Task prompts are now stored directly
|
||||
* in the tasks.prompt database column. New code should access prompts via
|
||||
* the Task.InitialPrompt field returned from task endpoints.
|
||||
*
|
||||
* This constant will be removed in a future major version. Templates should
|
||||
* not rely on this parameter name, as the backend will continue to create it
|
||||
* automatically for compatibility but reads from tasks.prompt.
|
||||
*/
|
||||
export const AITaskPromptParameterName = "AI Prompt";
|
||||
|
||||
// From codersdk/allowlist.go
|
||||
/**
|
||||
* APIAllowListTarget represents a single allow-list entry using the canonical
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
MockAIPromptPresets,
|
||||
MockPresets,
|
||||
MockTask,
|
||||
MockTaskPresets,
|
||||
MockTasks,
|
||||
MockTemplate,
|
||||
MockTemplateVersion,
|
||||
@@ -72,11 +72,9 @@ export const WithPresets: Story = {
|
||||
},
|
||||
};
|
||||
|
||||
export const ReadOnlyPresetPrompt: Story = {
|
||||
export const WithAIPresets: Story = {
|
||||
beforeEach: () => {
|
||||
spyOn(API, "getTemplateVersionPresets").mockResolvedValue(
|
||||
MockAIPromptPresets,
|
||||
);
|
||||
spyOn(API, "getTemplateVersionPresets").mockResolvedValue(MockTaskPresets);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import type {
|
||||
Template,
|
||||
TemplateVersionExternalAuth,
|
||||
} from "api/typesGenerated";
|
||||
import { AITaskPromptParameterName } from "api/typesGenerated";
|
||||
import { ErrorAlert } from "components/Alert/ErrorAlert";
|
||||
import { Button } from "components/Button/Button";
|
||||
import { ExternalImage } from "components/ExternalImage/ExternalImage";
|
||||
@@ -162,19 +161,6 @@ const CreateTaskForm: FC<CreateTaskFormProps> = ({ templates, onSuccess }) => {
|
||||
const defaultPreset = presets?.find((p) => p.Default);
|
||||
setSelectedPresetId(defaultPreset?.ID ?? presets?.[0]?.ID);
|
||||
}, [presets]);
|
||||
const selectedPreset = presets?.find((p) => p.ID === selectedPresetId);
|
||||
|
||||
// Read-only prompt if defined in preset
|
||||
const presetPrompt = selectedPreset?.Parameters?.find(
|
||||
(param) => param.Name === AITaskPromptParameterName,
|
||||
)?.Value;
|
||||
const isPromptReadOnly = !!presetPrompt;
|
||||
useEffect(() => {
|
||||
if (presetPrompt) {
|
||||
setPrompt(presetPrompt);
|
||||
}
|
||||
}, [presetPrompt]);
|
||||
|
||||
// External Auth
|
||||
const {
|
||||
externalAuth,
|
||||
@@ -250,21 +236,13 @@ const CreateTaskForm: FC<CreateTaskFormProps> = ({ templates, onSuccess }) => {
|
||||
className="border border-border border-solid rounded-3xl p-3 bg-surface-secondary"
|
||||
disabled={createTaskMutation.isPending}
|
||||
>
|
||||
<label
|
||||
htmlFor="prompt"
|
||||
className={
|
||||
isPromptReadOnly
|
||||
? "text-xs font-medium text-content-primary block px-3 pt-2"
|
||||
: "sr-only"
|
||||
}
|
||||
>
|
||||
{isPromptReadOnly ? "Prompt defined by preset" : "Prompt"}
|
||||
<label htmlFor="prompt" className="sr-only">
|
||||
Prompt
|
||||
</label>
|
||||
<PromptTextarea
|
||||
required
|
||||
value={prompt}
|
||||
onChange={(e) => setPrompt(e.target.value)}
|
||||
readOnly={isPromptReadOnly}
|
||||
isSubmitting={createTaskMutation.isPending}
|
||||
onKeyDown={handleKeyDown}
|
||||
/>
|
||||
|
||||
@@ -4977,14 +4977,13 @@ export const MockPresets: TypesGen.Preset[] = [
|
||||
},
|
||||
];
|
||||
|
||||
export const MockAIPromptPresets: TypesGen.Preset[] = [
|
||||
export const MockTaskPresets: TypesGen.Preset[] = [
|
||||
{
|
||||
ID: "ai-preset-1",
|
||||
Name: "Code Review",
|
||||
Description: "",
|
||||
Icon: "",
|
||||
Parameters: [
|
||||
{ Name: "AI Prompt", Value: "Review the code for best practices" },
|
||||
{ Name: "cpu", Value: "4" },
|
||||
{ Name: "memory", Value: "8GB" },
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user