import{u as y,a as _,b as A,c as E,r as i,t as m,j as s,S as T,d as I,e as p,f as M,B as g}from"./index-B48HCCvn.js";import{S as v}from"./select-YFykpbyQ.js";import{T as O}from"./textarea-PjCFOxmD.js";import{u as k}from"./use-providers-CSQgeUSp.js";import"./chevron-down-DBS9-_Q3.js";import"./check-CadkXmJ-.js";const L=[{value:"zh-CN",label:"简体中文"},{value:"en",label:"English"}],l="__follow_task__";function F(){const{locale:x,setLocale:S,t:e}=y(),{data:r}=_(),{data:f}=k(),{data:o}=A(),a=E(),[h,u]=i.useState(l),[c,d]=i.useState(""),[j,n]=i.useState(!1);i.useEffect(()=>{!r||!o||(u(r.commitMessageProviderId||l),d(r.commitMessagePrompt||o.prompt),n(!1))},[r,o]);const P=[{value:l,label:e("跟随任务")},...(f??[]).filter(t=>t.availability.type!=="NOT_FOUND").map(t=>({value:t.provider.id,label:t.provider.name}))],b=i.useCallback(t=>{u(t);const N=t===l?null:t;a.mutate({commitMessageProviderId:N},{onError:()=>m.error(e("保存失败"))})},[a,e]),C=i.useCallback(()=>{const t=c.trim()||null;a.mutate({commitMessagePrompt:t},{onSuccess:()=>{n(!1),m.success(e("已保存"))},onError:()=>m.error(e("保存失败"))})},[c,a,e]);return s.jsxs(T,{children:[s.jsx(I,{title:e("通用设置"),className:"mb-1"}),s.jsx("div",{className:"divide-y divide-border/60",children:s.jsx(p,{label:e("显示语言"),description:e("界面语言会保存到本地数据库，重启后继续生效。"),align:"center",children:s.jsx(v,{value:x,onChange:t=>S(t),options:L})})}),s.jsx(M,{className:"mt-8 mb-1",children:e("Git Commit Message")}),s.jsxs("div",{className:"divide-y divide-border/60",children:[s.jsx(p,{label:e("Agent 渠道"),description:e('"跟随任务"表示使用当前任务所用的 Agent 渠道。选择具体渠道可使用更经济的模型。'),children:s.jsx(v,{value:h,onChange:b,options:P})}),s.jsx(p,{label:e("提示词模板"),description:e("自定义生成 commit message 的提示词。留空则使用内置默认模板。"),children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(O,{value:c,onChange:t=>{d(t.target.value),n(!0)},rows:5,className:"font-mono resize-y"}),j&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx(g,{size:"sm",variant:"ghost",onClick:()=>{d(r?.commitMessagePrompt||o?.prompt||""),n(!1)},children:e("取消")}),s.jsx(g,{size:"sm",onClick:C,disabled:a.isPending,children:a.isPending?e("保存中..."):e("保存")})]})]})})]})]})}export{F as GeneralSettingsPage};
