fix(automations): clarify chat review and scheduling choices
This commit is contained in:
1 parent
17a66dcecf
commit
052ad09983
19 files changed
+139
-19
No files matched your search
@@ -45,7 +45,7 @@ export function AutomationChatBinding({ job, token, chatNames, onSave, children
|
||||
const [data, setData] = useState<AutomationChatsPayload | null>(null);
|
||||
const [loadError, setLoadError] = useState(false);
|
||||
const [reload, setReload] = useState(0);
|
||||
const [draft, setDraft] = useState<{ target: AutomationChat; previous: AutomationChat; revision: string; message: string } | null>(null);
|
||||
const [draft, setDraft] = useState<{ target: AutomationChat; previous: AutomationChat; revision: string; message: string; editingMessage?: boolean } | null>(null);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
const [saved, setSaved] = useState<{ target: AutomationChat; previous: AutomationChat } | null>(null);
|
||||
@@ -159,16 +159,26 @@ export function AutomationChatBinding({ job, token, chatNames, onSave, children
|
||||
<p className="text-[13px] leading-5">{tx("effect")}</p>
|
||||
<p className="text-[12px] leading-5 text-muted-foreground">{tx("history")}</p>
|
||||
</div>
|
||||
<label className="block space-y-2"><span className="text-[13px] font-medium">{tx("message")}</span>
|
||||
<Textarea rows={3} value={draft.message} disabled={saving} onChange={event => setDraft({ ...draft, message: event.target.value })}
|
||||
className="min-h-20 resize-y text-base leading-6 sm:text-[13px] sm:leading-5" />
|
||||
</label>
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<p className="text-[13px] font-medium">{tx("message")}</p>
|
||||
{!draft.editingMessage ? <Button variant="link" size="sm" disabled={saving}
|
||||
className="h-11 shrink-0 p-0 text-[12px] sm:h-9"
|
||||
onClick={() => setDraft({ ...draft, editingMessage: true })}>{tx("editInstructions")}</Button> : null}
|
||||
</div>
|
||||
{draft.editingMessage ? <>
|
||||
<Textarea autoFocus aria-label={tx("message")} rows={3} value={draft.message} disabled={saving}
|
||||
onChange={event => setDraft({ ...draft, message: event.target.value })}
|
||||
className="min-h-20 resize-y text-base leading-6 sm:text-[13px] sm:leading-5" />
|
||||
<p className="text-[12px] leading-5 text-muted-foreground">{tx("editInstructionsHint")}</p>
|
||||
</> : <p className="whitespace-pre-wrap break-words text-[13px] leading-5 [overflow-wrap:anywhere]">{draft.message}</p>}
|
||||
</div>
|
||||
<p className="text-[12px] leading-5 text-muted-foreground">{tx("review")}</p>
|
||||
{error || targetUnavailable ? <p role="alert" className="text-[12px] leading-5 text-destructive">{error || tx("unavailable")}</p> : null}
|
||||
</div>
|
||||
<DialogFooter className="shrink-0 flex-row justify-end gap-2 px-6 pb-5 pt-3">
|
||||
<Button variant="ghost" size="sm" disabled={saving} className="h-11 font-normal text-muted-foreground sm:h-9" onClick={back}>{t("settings.automations.cancel")}</Button>
|
||||
<Button size="sm" className="h-11 sm:h-9" disabled={locked || targetUnavailable || !draft.message.trim()} aria-busy={saving} onClick={() => void save()}>{tx(saving ? "saving" : "confirm")}</Button>
|
||||
<Button size="sm" className="h-11 sm:h-9" disabled={locked || targetUnavailable || !draft.message.trim()} aria-busy={saving} onClick={() => void save()}>{tx(saving ? "saving" : draft.editingMessage ? "saveAndChange" : "confirm")}</Button>
|
||||
</DialogFooter>
|
||||
</>;
|
||||
}
|
||||
@@ -1396,6 +1396,9 @@
|
||||
"automations": {
|
||||
"chat": {
|
||||
"changeBack": "Change back to “{{chat}}”",
|
||||
"editInstructions": "Edit instructions",
|
||||
"editInstructionsHint": "These edits are saved with the chat change.",
|
||||
"saveAndChange": "Save and change",
|
||||
"conflict": "The task changed elsewhere. Your draft is kept. Reopen the task to review the latest settings.",
|
||||
"unavailable": "This chat is no longer available with the same workspace and access mode. Select another chat.",
|
||||
"schedulerBusy": "A task is running or queued. Wait for it to finish, then try again.",
|
||||
|
||||
@@ -1197,6 +1197,9 @@
|
||||
"automations": {
|
||||
"chat": {
|
||||
"changeBack": "Volver a «{{chat}}»",
|
||||
"editInstructions": "Editar instrucciones",
|
||||
"editInstructionsHint": "Los cambios se guardan junto con el cambio de chat.",
|
||||
"saveAndChange": "Guardar y cambiar",
|
||||
"conflict": "La tarea cambió en otro lugar. Se conserva el borrador. Abre la tarea de nuevo para revisar los ajustes.",
|
||||
"unavailable": "Este chat ya no está disponible con el mismo espacio de trabajo y modo de acceso. Elige otro chat.",
|
||||
"schedulerBusy": "Hay una tarea en ejecución o en cola. Espera a que termine e inténtalo de nuevo.",
|
||||
|
||||
@@ -1196,6 +1196,9 @@
|
||||
"automations": {
|
||||
"chat": {
|
||||
"changeBack": "Revenir à « {{chat}} »",
|
||||
"editInstructions": "Modifier les instructions",
|
||||
"editInstructionsHint": "Ces modifications sont enregistrées avec le changement de conversation.",
|
||||
"saveAndChange": "Enregistrer et changer",
|
||||
"conflict": "La tâche a été modifiée ailleurs. Le brouillon est conservé. Rouvrez la tâche pour vérifier ses paramètres.",
|
||||
"unavailable": "Cette discussion n’est plus disponible avec le même espace de travail et mode d’accès. Choisissez-en une autre.",
|
||||
"schedulerBusy": "Une tâche est en cours ou en attente. Attendez la fin, puis réessayez.",
|
||||
|
||||
@@ -1196,6 +1196,9 @@
|
||||
"automations": {
|
||||
"chat": {
|
||||
"changeBack": "Kembali ke “{{chat}}”",
|
||||
"editInstructions": "Ubah instruksi",
|
||||
"editInstructionsHint": "Perubahan ini disimpan bersama perubahan chat.",
|
||||
"saveAndChange": "Simpan dan ubah",
|
||||
"conflict": "Tugas diubah di tempat lain. Draf disimpan. Buka ulang tugas untuk memeriksa pengaturan terbaru.",
|
||||
"unavailable": "Chat ini tidak tersedia lagi dengan ruang kerja dan mode akses yang sama. Pilih chat lain.",
|
||||
"schedulerBusy": "Ada tugas berjalan atau mengantre. Tunggu hingga selesai, lalu coba lagi.",
|
||||
|
||||
@@ -1196,6 +1196,9 @@
|
||||
"automations": {
|
||||
"chat": {
|
||||
"changeBack": "「{{chat}}」に戻す",
|
||||
"editInstructions": "指示を編集",
|
||||
"editInstructionsHint": "編集内容はチャットの変更と一緒に保存されます。",
|
||||
"saveAndChange": "保存して変更",
|
||||
"conflict": "タスクが別の場所で変更されました。下書きは保持されています。タスクを開き直して最新の設定を確認してください。",
|
||||
"unavailable": "このチャットは利用できないか、作業場所や権限が変わりました。別のチャットを選んでください。",
|
||||
"schedulerBusy": "実行中または待機中のタスクがあります。完了後に再試行してください。",
|
||||
|
||||
@@ -1196,6 +1196,9 @@
|
||||
"automations": {
|
||||
"chat": {
|
||||
"changeBack": "“{{chat}}”(으)로 되돌리기",
|
||||
"editInstructions": "지침 수정",
|
||||
"editInstructionsHint": "수정한 지침은 채팅 변경과 함께 저장됩니다.",
|
||||
"saveAndChange": "저장 후 변경",
|
||||
"conflict": "다른 곳에서 작업이 변경되었습니다. 초안은 유지됩니다. 작업을 다시 열어 최신 설정을 확인하세요.",
|
||||
"unavailable": "이 채팅을 사용할 수 없거나 작업 공간 또는 권한이 변경되었습니다. 다른 채팅을 선택하세요.",
|
||||
"schedulerBusy": "실행 중이거나 대기 중인 작업이 있습니다. 완료 후 다시 시도하세요.",
|
||||
|
||||
@@ -1210,6 +1210,9 @@
|
||||
"automations": {
|
||||
"chat": {
|
||||
"changeBack": "Voltar para “{{chat}}”",
|
||||
"editInstructions": "Editar instruções",
|
||||
"editInstructionsHint": "Estas alterações são salvas junto com a mudança de conversa.",
|
||||
"saveAndChange": "Salvar e mudar",
|
||||
"conflict": "A tarefa foi alterada em outro lugar. O rascunho foi mantido. Abra a tarefa novamente para conferir os ajustes.",
|
||||
"unavailable": "Esta conversa não está mais disponível com o mesmo espaço de trabalho e modo de acesso. Escolha outra conversa.",
|
||||
"schedulerBusy": "Há uma tarefa em execução ou na fila. Aguarde a conclusão e tente novamente.",
|
||||
|
||||
@@ -1196,6 +1196,9 @@
|
||||
"automations": {
|
||||
"chat": {
|
||||
"changeBack": "Chuyển lại về “{{chat}}”",
|
||||
"editInstructions": "Sửa hướng dẫn",
|
||||
"editInstructionsHint": "Các chỉnh sửa được lưu cùng với việc đổi cuộc trò chuyện.",
|
||||
"saveAndChange": "Lưu và đổi",
|
||||
"conflict": "Tác vụ đã được đổi ở nơi khác. Bản nháp được giữ lại. Mở lại tác vụ để kiểm tra cài đặt mới nhất.",
|
||||
"unavailable": "Cuộc trò chuyện này không còn khả dụng với cùng không gian làm việc và quyền truy cập. Hãy chọn cuộc trò chuyện khác.",
|
||||
"schedulerBusy": "Có tác vụ đang chạy hoặc chờ. Hãy đợi hoàn tất rồi thử lại.",
|
||||
|
||||
@@ -1396,6 +1396,9 @@
|
||||
"automations": {
|
||||
"chat": {
|
||||
"changeBack": "改回「{{chat}}」",
|
||||
"editInstructions": "修改说明",
|
||||
"editInstructionsHint": "说明会与聊天更换一起保存。",
|
||||
"saveAndChange": "保存并更换",
|
||||
"conflict": "任务已在别处修改,草稿已保留。请重新打开任务,核对最新设置后再更换。",
|
||||
"unavailable": "这个聊天已不可用,或工作目录、权限已改变。请选择其他聊天。",
|
||||
"schedulerBusy": "有任务正在执行或排队。请等任务结束后再试。",
|
||||
|
||||
@@ -1196,6 +1196,9 @@
|
||||
"automations": {
|
||||
"chat": {
|
||||
"changeBack": "改回「{{chat}}」",
|
||||
"editInstructions": "修改說明",
|
||||
"editInstructionsHint": "說明會與聊天更換一起儲存。",
|
||||
"saveAndChange": "儲存並更換",
|
||||
"conflict": "任務已在別處修改,草稿已保留。請重新開啟任務,確認最新設定後再更換。",
|
||||
"unavailable": "這個聊天已無法使用,或工作目錄、權限已變更。請選擇其他聊天。",
|
||||
"schedulerBusy": "有任務正在執行或排隊。請等任務結束後再試。",
|
||||
|
||||
@@ -36,9 +36,13 @@ it("keeps the original route until acknowledgement and saves the reviewed prompt
|
||||
await choose();
|
||||
expect(save).not.toHaveBeenCalled();
|
||||
expect(screen.getByRole("group", { name: "Now" })).toHaveTextContent("My planning");
|
||||
expect(screen.queryByRole("textbox", { name: "Task instructions" })).not.toBeInTheDocument();
|
||||
expect(screen.getByText(job.payload.message)).toBeInTheDocument();
|
||||
await user.click(screen.getByRole("button", { name: "Edit instructions" }));
|
||||
expect(screen.getByRole("textbox", { name: "Task instructions" })).toHaveFocus();
|
||||
await user.clear(screen.getByRole("textbox", { name: "Task instructions" }));
|
||||
await user.type(screen.getByRole("textbox", { name: "Task instructions" }), "New instructions");
|
||||
await user.click(screen.getByRole("button", { name: "Confirm change" }));
|
||||
await user.click(screen.getByRole("button", { name: "Save and change" }));
|
||||
expect(save).toHaveBeenCalledWith(job, { target_id: "target", revision: "rev-1", message: "New instructions" });
|
||||
expect(screen.getByRole("button", { name: "Changing…" })).toBeDisabled();
|
||||
expect(screen.queryByRole("status")).not.toBeInTheDocument();
|
||||
@@ -84,6 +88,11 @@ it("uses Chinese for the task menu and the change/cancel path", async () => {
|
||||
await user.click(await screen.findByRole("option", { name: /Product team/ }));
|
||||
expect(screen.getByRole("heading", { name: "更换聊天" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "确认并更换" })).toBeInTheDocument();
|
||||
expect(screen.queryByRole("textbox", { name: "任务说明" })).not.toBeInTheDocument();
|
||||
await user.click(screen.getByRole("button", { name: "修改说明" }));
|
||||
expect(screen.getByRole("textbox", { name: "任务说明" })).toHaveFocus();
|
||||
expect(screen.getByText("说明会与聊天更换一起保存。")).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "保存并更换" })).toBeInTheDocument();
|
||||
await user.click(screen.getByRole("button", { name: "取消" }));
|
||||
expect(screen.getByRole("heading", { name: "Daily report" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("combobox", { name: "运行与回复" })).toHaveFocus();
|
||||
@@ -132,6 +141,7 @@ it("cancels a chat change without saving the edited instructions", async () => {
|
||||
const save = vi.fn();
|
||||
render(<AutomationDetailDialog {...props} job={job} onChangeChat={save} />);
|
||||
await choose();
|
||||
await user.click(screen.getByRole("button", { name: "Edit instructions" }));
|
||||
await user.clear(screen.getByRole("textbox", { name: "Task instructions" }));
|
||||
await user.type(screen.getByRole("textbox", { name: "Task instructions" }), "Discard this draft");
|
||||
await user.click(screen.getByRole("button", { name: "Cancel" }));
|
||||
@@ -139,6 +149,8 @@ it("cancels a chat change without saving the edited instructions", async () => {
|
||||
expect(screen.getByRole("combobox", { name: "Run and reply in" })).toHaveTextContent("My planning");
|
||||
expect(screen.getByRole("combobox", { name: "Run and reply in" })).toHaveFocus();
|
||||
await choose();
|
||||
expect(screen.queryByRole("textbox", { name: "Task instructions" })).not.toBeInTheDocument();
|
||||
await user.click(screen.getByRole("button", { name: "Edit instructions" }));
|
||||
expect(screen.getByRole("textbox", { name: "Task instructions" })).toHaveValue("Summarize the work.");
|
||||
});
|
||||
|
||||
@@ -147,9 +159,10 @@ it("keeps a rejected draft and its original revision across polling", async () =
|
||||
const save = vi.fn().mockRejectedValue(new Error("automation_chat_conflict"));
|
||||
const { rerender } = render(<AutomationDetailDialog {...props} job={job} onChangeChat={save} />);
|
||||
await choose();
|
||||
await user.click(screen.getByRole("button", { name: "Edit instructions" }));
|
||||
await user.type(screen.getByRole("textbox", { name: "Task instructions" }), " Reviewed");
|
||||
rerender(<AutomationDetailDialog {...props} job={{ ...job, chat_binding_revision: "rev-2" }} onChangeChat={save} />);
|
||||
await user.click(screen.getByRole("button", { name: "Confirm change" }));
|
||||
await user.click(screen.getByRole("button", { name: "Save and change" }));
|
||||
expect(save.mock.calls[0][1].revision).toBe("rev-1");
|
||||
expect(await screen.findByRole("alert")).toHaveTextContent("draft is kept");
|
||||
expect(screen.getByRole("textbox", { name: "Task instructions" })).toHaveValue("Summarize the work. Reviewed");
|
||||
@@ -172,6 +185,7 @@ it("keeps the reviewed chat identity when refreshed choices no longer contain it
|
||||
const save = vi.fn();
|
||||
const { rerender } = render(<AutomationDetailDialog {...props} job={job} onChangeChat={save} />);
|
||||
await choose();
|
||||
await user.click(screen.getByRole("button", { name: "Edit instructions" }));
|
||||
await user.type(screen.getByRole("textbox", { name: "Task instructions" }), " Reviewed");
|
||||
vi.mocked(fetchAutomationChats).mockResolvedValue({
|
||||
revision: "rev-2", current: { ...source, title: "Renamed planning" }, chats: [source],
|
||||
@@ -181,7 +195,7 @@ it("keeps the reviewed chat identity when refreshed choices no longer contain it
|
||||
expect(screen.getByRole("combobox", { name: "Change to" })).toHaveTextContent("Product team");
|
||||
expect(screen.getByRole("group", { name: "Now" })).toHaveTextContent("My planning");
|
||||
expect(screen.getByRole("textbox", { name: "Task instructions" })).toHaveValue("Summarize the work. Reviewed");
|
||||
expect(screen.getByRole("button", { name: "Confirm change" })).toBeDisabled();
|
||||
expect(screen.getByRole("button", { name: "Save and change" })).toBeDisabled();
|
||||
expect(save).not.toHaveBeenCalled();
|
||||
await user.click(screen.getByRole("button", { name: "Cancel" }));
|
||||
expect(screen.getByRole("combobox", { name: "Run and reply in" })).toHaveTextContent("Renamed planning");
|
||||
|
||||
Reference in new issue
Block a user