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

Commitf6526b7

Browse files
authored
feat(site): make TaskPrompt PromptTextarea read-only when submitting (#20363)
- Makes the text area of TaskPrompt read-only when submitting- Adds a "scanning" animation to the textarea on submit.
1 parentcfbbcfc commitf6526b7

File tree

3 files changed

+67
-11
lines changed

3 files changed

+67
-11
lines changed

‎site/src/modules/tasks/TaskPrompt/TaskPrompt.stories.tsx‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,35 @@ export const SubmitDisabledWhenPromptEmpty: Story = {
103103
},
104104
};
105105

106+
exportconstSubmitting:Story={
107+
decorators:[withGlobalSnackbar],
108+
beforeEach:()=>{
109+
spyOn(API.experimental,"createTask").mockImplementation(
110+
()=>
111+
// Never resolve to keep the component in the submitting state for visual testing.
112+
newPromise(()=>{}),
113+
);
114+
},
115+
play:async({ canvasElement})=>{
116+
constcanvas=within(canvasElement);
117+
118+
constprompt=awaitcanvas.findByLabelText(/prompt/i);
119+
awaituserEvent.type(
120+
prompt,
121+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.{enter}{enter}Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
122+
);
123+
124+
constsubmitButton=canvas.getByRole("button",{name:/runtask/i});
125+
awaitwaitFor(()=>expect(submitButton).toBeEnabled());
126+
awaituserEvent.click(submitButton);
127+
},
128+
parameters:{
129+
chromatic:{
130+
disableSnapshot:true,
131+
},
132+
},
133+
};
134+
106135
exportconstOnSuccess:Story={
107136
decorators:[withGlobalSnackbar],
108137
parameters:{

‎site/src/modules/tasks/TaskPrompt/TaskPrompt.tsx‎

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ const CreateTaskForm: FC<CreateTaskFormProps> = ({ templates, onSuccess }) => {
259259
value={prompt}
260260
onChange={(e)=>setPrompt(e.target.value)}
261261
readOnly={isPromptReadOnly}
262+
isSubmitting={createTaskMutation.isPending}
262263
/>
263264
<divclassName="flex items-center justify-between pt-2">
264265
<divclassName="flex items-center gap-1">
@@ -457,17 +458,35 @@ async function createTaskWithLatestTemplateVersion(
457458
});
458459
}
459460

460-
constPromptTextarea:FC<TextareaAutosizeProps>=(props)=>{
461+
typePromptTextareaProps=TextareaAutosizeProps&{
462+
isSubmitting?:boolean;
463+
};
464+
465+
constPromptTextarea:FC<PromptTextareaProps>=({
466+
isSubmitting,
467+
...props
468+
})=>{
461469
return(
462-
<TextareaAutosize
463-
{...props}
464-
required
465-
id="prompt"
466-
name="prompt"
467-
placeholder="Prompt your AI agent to start a task..."
468-
className={`border-0 px-3 py-2 resize-none w-full h-full bg-transparent rounded-lg
469-
outline-none flex min-h-24 text-sm shadow-sm text-content-primary
470-
placeholder:text-content-secondary md:text-sm${props.readOnly ?"opacity-60 cursor-not-allowed" :""}`}
471-
/>
470+
<divclassName="relative">
471+
<TextareaAutosize
472+
{...props}
473+
required
474+
id="prompt"
475+
name="prompt"
476+
placeholder="Prompt your AI agent to start a task..."
477+
className={`border-0 px-3 py-2 resize-none w-full h-full bg-transparent rounded-lg
478+
outline-none flex min-h-24 text-sm shadow-sm text-content-primary
479+
placeholder:text-content-secondary md:text-sm${props.readOnly||isSubmitting ?"opacity-60 cursor-not-allowed" :""}`}
480+
/>
481+
{isSubmitting&&(
482+
<divclassName="absolute inset-0 pointer-events-none overflow-hidden">
483+
<div
484+
className={`absolute top-0 w-0.5 h-full
485+
bg-green-400/90 animate-caret-scan rounded-sm
486+
shadow-[-15px_0_15px_rgba(0,255,0,0.9),-30px_0_30px_rgba(0,255,0,0.7),-45px_0_45px_rgba(0,255,0,0.5),-60px_0_60px_rgba(0,255,0,0.3)]`}
487+
/>
488+
</div>
489+
)}
490+
</div>
472491
);
473492
};

‎site/tailwind.config.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ module.exports = {
8383
"75%":{opacity:0.3},
8484
"100%":{opacity:0.2},
8585
},
86+
"caret-scan":{
87+
"0%":{left:"0%"},
88+
"100%":{left:"100%"},
89+
},
90+
},
91+
animation:{
92+
loading:"loading 2s ease-in-out infinite alternate",
93+
"caret-scan":"caret-scan 3s ease-in-out infinite",
8694
},
8795
},
8896
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp