pi-web-ui 0.115.0 → 0.117.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -2
- package/bin/device-hub-cli.mjs +26 -3
- package/bin/pi-web-ui.mjs +159 -71
- package/dist/server/agent-service-daemon.js +136 -8
- package/dist/server/agent-service.js +594 -159
- package/dist/server/canvas/canvas-workspace.js +18 -86
- package/dist/server/client-state.js +52 -8
- package/dist/server/compaction-markers.js +43 -24
- package/dist/server/dangling-tools.js +172 -16
- package/dist/server/device-center/bot-execution.js +77 -2
- package/dist/server/device-center/collab-service.js +61 -12
- package/dist/server/device-center/collab-tool.js +482 -21
- package/dist/server/device-center/connector.js +107 -37
- package/dist/server/device-center/delivery-authority.js +98 -0
- package/dist/server/device-center/delivery-subject.js +30 -0
- package/dist/server/device-center/device-integration.js +453 -183
- package/dist/server/device-center/execution-guides.js +17 -7
- package/dist/server/device-center/execution-instructions.js +2 -1
- package/dist/server/device-center/execution-settings.js +138 -25
- package/dist/server/device-center/executor.js +51 -6
- package/dist/server/device-center/file-sync.js +14 -13
- package/dist/server/device-center/group-context-message.js +3 -1
- package/dist/server/device-center/group-context.js +73 -3
- package/dist/server/device-center/hub-conversations.js +71 -6
- package/dist/server/device-center/hub-deliveries.js +120 -15
- package/dist/server/device-center/hub-integration.js +655 -334
- package/dist/server/device-center/hub-locks.js +320 -0
- package/dist/server/device-center/hub-page.js +16 -35
- package/dist/server/device-center/hub-setup.js +23 -1
- package/dist/server/device-center/hub-transaction-log.js +197 -0
- package/dist/server/device-center/hub-webhooks.js +165 -0
- package/dist/server/device-center/hub.js +1531 -305
- package/dist/server/device-center/integration-verification.js +113 -0
- package/dist/server/device-center/local-hub.js +8 -3
- package/dist/server/device-center/local-publication.js +423 -0
- package/dist/server/device-center/local-verification-job.js +97 -0
- package/dist/server/device-center/local-verification.js +274 -0
- package/dist/server/device-center/local.js +181 -13
- package/dist/server/device-center/main.js +4 -1
- package/dist/server/device-center/partition-log.js +330 -0
- package/dist/server/device-center/publication-journal.js +312 -0
- package/dist/server/device-center/publish-intent.js +379 -0
- package/dist/server/device-center/relay.js +134 -24
- package/dist/server/device-center/runtime.js +475 -42
- package/dist/server/device-center/store.js +366 -89
- package/dist/server/device-center/task-outcome.js +81 -0
- package/dist/server/device-center/task-recovery.js +603 -178
- package/dist/server/device-center/task-scheduler.js +48 -3
- package/dist/server/device-center/task-settlement.js +353 -0
- package/dist/server/device-center/task-workspace.js +443 -0
- package/dist/server/device-center/transfers.js +41 -15
- package/dist/server/device-center/verification-limits.js +10 -0
- package/dist/server/device-center/work-contract.js +995 -0
- package/dist/server/dispatch-domain-handlers.js +29 -3
- package/dist/server/dsh/dsh-agent-service.js +9 -2
- package/dist/server/engine-probe.js +112 -1
- package/dist/server/global-loader.js +119 -19
- package/dist/server/index.js +159 -17
- package/dist/server/managed.js +2 -0
- package/dist/server/model-admin.js +48 -6
- package/dist/server/model-enrich.js +10 -1
- package/dist/server/patch-node-pty.js +3 -2
- package/dist/server/patch-remote-catalog.js +3 -2
- package/dist/server/plugins.js +64 -7
- package/dist/server/preset-fields.js +17 -1
- package/dist/server/preset-share.js +1 -0
- package/dist/server/prompt-composer.js +39 -0
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/quick-ask-settings.js +28 -0
- package/dist/server/quick-ask.js +164 -0
- package/dist/server/reasoning-registry.js +207 -0
- package/dist/server/resolve-global-sdk.js +61 -11
- package/dist/server/scheduler-tasks.js +35 -8
- package/dist/server/session-list-scan.js +223 -0
- package/dist/server/session-open.js +93 -0
- package/dist/server/session-parser.js +4 -0
- package/dist/server/session-scan.js +90 -38
- package/dist/server/settings-service.js +9 -1
- package/dist/server/soft-cap.js +5 -0
- package/dist/server/startup-banner.js +35 -0
- package/dist/server/subagents.js +2 -1
- package/dist/server/tool-manager.js +17 -9
- package/dist/server/transcript-prepare.js +73 -0
- package/dist/server/unauthorized-page.js +319 -0
- package/dist/server/universal/drivers/claude-code.js +98 -34
- package/dist/server/universal/universal-session.js +4 -0
- package/dist/server/workspace-handle.js +428 -0
- package/docs/architecture-plugins.md +959 -0
- package/docs/device-center.md +34 -20
- package/package.json +4 -4
- package/plugin-sdk/README.md +16 -8
- package/plugin-sdk/client.d.ts +27 -0
- package/plugin-sdk/client.mjs +82 -0
- package/plugin-sdk/index.d.ts +10 -0
- package/plugin-sdk/index.mjs +4 -683
- package/plugin-sdk/package.json +15 -4
- package/plugin-sdk/testing.d.ts +10 -0
- package/plugin-sdk/testing.mjs +566 -0
- package/themes/flow-cristallo.css +168 -0
- package/themes/flow-ink.css +169 -0
- package/themes/flow-obsidian.css +169 -0
- package/themes/flow-zurich.css +169 -0
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/{BgTasksModal-BYzPgmoq.js → BgTasksModal-BjNRIUIc.js} +1 -1
- package/web/dist/assets/{BgTasksModal-ni0VTmAQ.js → BgTasksModal-C0zuU8FE.js} +1 -1
- package/web/dist/assets/{CanvasStudio-DNmDNBod.js → CanvasStudio-BWvdmJ0M.js} +3 -3
- package/web/dist/assets/{CanvasStudio-BCUeEf25.js → CanvasStudio-VQFjmTGq.js} +3 -3
- package/web/dist/assets/DeviceCenter-DI9_0aBB.js +3 -0
- package/web/dist/assets/DeviceCenter-DsNtXqzY.js +3 -0
- package/web/dist/assets/DeviceExecutionSettings-BLP1Su5G.js +1 -0
- package/web/dist/assets/DeviceGroups-2Pvk0Cds.js +1 -0
- package/web/dist/assets/DeviceGroups-CP7CcyPD.js +1 -0
- package/web/dist/assets/{Dropdown-CGXD0DfT.js → Dropdown-CQtstPGv.js} +1 -1
- package/web/dist/assets/FilePreview-BMB2tNyT.js +2 -0
- package/web/dist/assets/FilePreview-RGFQUbJo.js +2 -0
- package/web/dist/assets/{GlobalSearchModal-mevF-ySi.js → GlobalSearchModal-BM5wxiqU.js} +1 -1
- package/web/dist/assets/{GlobalSearchModal-qL99FN_F.js → GlobalSearchModal-DGv_WINq.js} +1 -1
- package/web/dist/assets/GroupConversation-B7SnuXj1.js +61 -0
- package/web/dist/assets/GroupConversation-Dda69q-2.js +61 -0
- package/web/dist/assets/{HintTip-LHwkS2jV.js → HintTip-ChTW8o1m.js} +1 -1
- package/web/dist/assets/ModelConfigModal-C-0Z4hUZ.js +2 -0
- package/web/dist/assets/ModelConfigModal-yqeadyab.js +2 -0
- package/web/dist/assets/{PiSetupModal-DE5-gEtI.js → PiSetupModal-BX5rUuoI.js} +1 -1
- package/web/dist/assets/{ProviderOAuthControls-6UMARucA.js → ProviderOAuthControls-DY4SCfXg.js} +1 -1
- package/web/dist/assets/SCMPanel-C4KbQvvK.js +2 -0
- package/web/dist/assets/SCMPanel-DPAyY2sW.js +2 -0
- package/web/dist/assets/SettingsModal-DxZp6D_g.js +32 -0
- package/web/dist/assets/SettingsModal-WhQzaOPt.js +32 -0
- package/web/dist/assets/{TerminalPanel-CTp_BZ4S.js → TerminalPanel-D4By_RVc.js} +2 -2
- package/web/dist/assets/{TerminalPanel-CkYxC-Gh.js → TerminalPanel-lZw8-i3j.js} +2 -2
- package/web/dist/assets/{TuiOverlayModal-1cRLP8IF.js → TuiOverlayModal-C3pAVuC8.js} +1 -1
- package/web/dist/assets/{TuiOverlayModal-2xlptqWX.js → TuiOverlayModal-D7_rEXcJ.js} +1 -1
- package/web/dist/assets/app-globals-KqOVtmp1.js +123 -0
- package/web/dist/assets/{canvas-client-Bye9nSFO.js → canvas-client-BY6ojmle.js} +1 -1
- package/web/dist/assets/{desktop-kjBoE3Nu.js → desktop-CV6KKp9R.js} +1 -1
- package/web/dist/assets/index-BawF7ZP5.js +397 -0
- package/web/dist/assets/index-BoGCoq5X.js +397 -0
- package/web/dist/assets/index-CVW9FoY2.css +1 -0
- package/web/dist/assets/{plugin-host-C8mNgghx.js → plugin-host-Dn8Dd6SC.js} +1 -1
- package/web/dist/assets/{remote-ssh-client-CeP3CLUW.js → remote-ssh-client-Dzi-eEyE.js} +1 -1
- package/web/dist/assets/{theme-BXGpyTMh.js → theme-D_bihpdN.js} +1 -1
- package/web/dist/index.html +11 -11
- package/web/dist/sw.js +1 -1
- package/dist/server/patch-turn-end-boundary.js +0 -77
- package/web/dist/assets/DeviceCenter-BcBhRgL6.js +0 -3
- package/web/dist/assets/DeviceCenter-CmL5FZmt.js +0 -3
- package/web/dist/assets/DeviceGroups-CLdpdnI7.js +0 -1
- package/web/dist/assets/DeviceGroups-CgBaDPrD.js +0 -1
- package/web/dist/assets/FilePreview-B8iqnBjy.js +0 -2
- package/web/dist/assets/FilePreview-BqviZKCN.js +0 -2
- package/web/dist/assets/GroupConversation-B88Yy-lt.js +0 -3
- package/web/dist/assets/GroupConversation-BwP5NVOE.js +0 -3
- package/web/dist/assets/ModelConfigModal-Do3Fe3jH.js +0 -2
- package/web/dist/assets/SCMPanel-Hi6QqC1Q.js +0 -2
- package/web/dist/assets/SCMPanel-ezY_ZtCu.js +0 -2
- package/web/dist/assets/SettingsModal-6HgeEsJ8.js +0 -20
- package/web/dist/assets/SettingsModal-CF-7MwqS.js +0 -20
- package/web/dist/assets/app-globals-DZNa9v8u.js +0 -325
- package/web/dist/assets/index-CsFs_HMb.css +0 -1
- package/web/dist/assets/index-DHeeHS_l.js +0 -85
- package/web/dist/assets/index-DTZch8uz.js +0 -85
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t,Sn as n,Vt as r,fn as i,l as a,t as o}from"./app-globals-KqOVtmp1.js";import{i as s,t as c}from"./react-CR5VJ85Q.js";import{r as l}from"./desktop-CV6KKp9R.js";import{t as u}from"./ProviderOAuthControls-DY4SCfXg.js";var d=e(s(),1),f=c();function p({piConfigured:e,piAgentInstalled:s,providers:c,providerOAuthFlows:p,providerOAuthResults:m,installResult:h,onClose:g}){let _=n(),v=l(),y=a(),[b,x]=(0,d.useState)(!1),[S,C]=(0,d.useState)(``),[w,T]=(0,d.useState)(``),[E,D]=(0,d.useState)(!1);(0,d.useEffect)(()=>{o({type:`list_providers`}),o({type:`list_provider_oauth_flows`})},[]),(0,d.useEffect)(()=>{e&&g()},[e,g]),(0,d.useEffect)(()=>{h&&x(!1)},[h]),(0,d.useEffect)(()=>{!S&&c.length>0&&C(c.find(e=>!e.configured)?.id??c[0].id)},[c,S]);let O=()=>{b||(x(!0),o({type:`install_pi_agent`}))},k=()=>{w.trim()&&!E&&(D(!0),o({type:`set_provider_api_key`,provider:S.trim(),apiKey:w.trim()}),setTimeout(()=>D(!1),3e3))},A=()=>{o({type:`get_state`}),o({type:`list_providers`})},j=c.find(e=>e.id===S),M=h!==null&&!h.ok;return(0,f.jsx)(`div`,{className:`modal-backdrop`,children:(0,f.jsxs)(`div`,{className:`modal setup-modal`,children:[(0,f.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":_(`close`),onClick:g,children:(0,f.jsx)(i,{})}),(0,f.jsxs)(`div`,{className:`modal-head`,children:[(0,f.jsx)(t,{className:`modal-head-icon`}),(0,f.jsx)(`h2`,{children:_(`setupTitle`)})]}),(0,f.jsx)(`p`,{className:`modal-desc`,children:_(`setupDesc`)}),M?(0,f.jsxs)(`div`,{className:`setup-failed`,children:[(0,f.jsx)(`div`,{className:`setup-done`,children:_(`installFailed`)}),(0,f.jsx)(`pre`,{className:`setup-detail`,children:h.detail}),(0,f.jsxs)(`div`,{className:`setup-actions`,children:[(0,f.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:b,onClick:O,children:_(`retryInstall`)}),(0,f.jsx)(`button`,{type:`button`,className:`btn`,onClick:g,children:_(`skip`)})]})]}):s||h?.ok||v?(0,f.jsxs)(`div`,{className:`setup-key-form`,children:[(0,f.jsx)(`div`,{className:`setup-done`,children:h?.ok?_(`installDone`):_(`cliReadyHint`)}),(0,f.jsxs)(`label`,{className:`field`,children:[(0,f.jsx)(`span`,{className:`field-label`,children:_(`provider`)}),(0,f.jsxs)(`select`,{value:S,onChange:e=>C(e.target.value),children:[c.length===0&&(0,f.jsx)(`option`,{value:``,children:_(`loading`)}),c.map(e=>(0,f.jsxs)(`option`,{value:e.id,children:[e.name,`(`,e.id,`)`,e.configured?` · ${_(`configured`)}`:``]},e.id))]}),j?.configured&&(0,f.jsx)(`div`,{className:`field-hint`,children:_(`providerKeyReady`)})]}),j?.supportsOAuth&&(0,f.jsx)(u,{provider:j,flow:p.find(e=>e.provider===j.id),result:m[j.id]}),j?.supportsApiKey&&(0,f.jsxs)(`label`,{className:`field`,children:[(0,f.jsx)(`span`,{className:`field-label`,children:_(`apiKey`)}),(0,f.jsx)(`input`,{type:`password`,value:w,onChange:e=>T(e.target.value),placeholder:`sk-…`})]}),(0,f.jsxs)(`div`,{className:`setup-actions`,children:[j?.supportsApiKey&&(0,f.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!w.trim()||E||!S,onClick:k,children:_(E?`saving`:`saveAndStart`)}),(0,f.jsxs)(`button`,{type:`button`,className:`btn`,onClick:A,children:[(0,f.jsx)(r,{}),` `,_(`recheck`)]})]})]}):y?(0,f.jsxs)(`div`,{className:`setup-actions`,children:[(0,f.jsx)(`div`,{className:`setup-done`,children:_(`updatesManaged`)}),(0,f.jsx)(`button`,{type:`button`,className:`btn`,onClick:g,children:_(`skip`)})]}):(0,f.jsxs)(`div`,{className:`setup-actions`,children:[(0,f.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:b,onClick:O,children:_(b?`installing`:`autoInstall`)}),(0,f.jsx)(`button`,{type:`button`,className:`btn`,onClick:g,children:_(`skip`)})]})]})})}export{p as PiSetupModal};
|
package/web/dist/assets/{ProviderOAuthControls-6UMARucA.js → ProviderOAuthControls-DY4SCfXg.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Sn as t,t as n}from"./app-globals-KqOVtmp1.js";import{i as r,t as i}from"./react-CR5VJ85Q.js";var a=e(r(),1),o=i();function s({provider:e,flow:r,result:i}){let s=t(),c=r?.event,l=e.oauthName??e.name,[u,d]=(0,a.useState)(``);return(0,a.useEffect)(()=>d(``),[r?.promptId]),e.usingOAuth?(0,o.jsxs)(`div`,{className:`provider-oauth`,children:[(0,o.jsx)(`span`,{className:`provider-oauth-status`,children:s(`oauthConnected`,{name:l})}),(0,o.jsx)(`button`,{type:`button`,className:`btn sm danger`,"data-provider-oauth-logout":e.id,onClick:()=>n({type:`provider_oauth_logout`,provider:e.id}),children:s(`oauthLogout`)}),i?.error&&(0,o.jsx)(`div`,{className:`provider-oauth-error`,children:i.error})]}):(0,o.jsxs)(`div`,{className:`provider-oauth`,children:[r?(0,o.jsxs)(o.Fragment,{children:[c?.type===`device_code`&&(0,o.jsxs)(`div`,{className:`provider-oauth-device`,children:[(0,o.jsx)(`div`,{children:s(`oauthDeviceCode`)}),(0,o.jsx)(`code`,{"data-oauth-device-code":!0,children:c.userCode}),(0,o.jsx)(`a`,{"data-oauth-verification-url":!0,href:c.verificationUri,target:`_blank`,rel:`noreferrer`,children:s(`oauthOpenVerification`)})]}),c?.type===`auth_url`&&(0,o.jsxs)(`div`,{className:`provider-oauth-event`,children:[c.instructions&&(0,o.jsx)(`div`,{children:c.instructions}),(0,o.jsx)(`a`,{href:c.url,target:`_blank`,rel:`noreferrer`,children:s(`oauthOpenVerification`)})]}),c?.type===`progress`&&(0,o.jsx)(`div`,{className:`provider-oauth-message`,children:c.message}),c?.type===`info`&&(0,o.jsxs)(`div`,{className:`provider-oauth-event`,children:[(0,o.jsx)(`div`,{children:c.message}),c.links?.map(e=>(0,o.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.label??e.url},e.url))]}),r.prompt&&(0,o.jsx)(`div`,{className:`provider-oauth-message`,children:r.prompt.message}),r.prompt?.type===`select`&&r.promptId&&(0,o.jsx)(`div`,{className:`provider-oauth-options`,children:r.prompt.options.map(e=>(0,o.jsx)(`button`,{type:`button`,className:`btn sm`,"data-oauth-option":e.id,onClick:()=>n({type:`provider_oauth_reply`,flowId:r.flowId,promptId:r.promptId,value:e.id}),children:e.label},e.id))}),r.prompt&&r.prompt.type!==`select`&&r.promptId&&(0,o.jsxs)(`form`,{className:`provider-oauth-prompt`,onSubmit:e=>{e.preventDefault(),u.trim()&&n({type:`provider_oauth_reply`,flowId:r.flowId,promptId:r.promptId,value:u.trim()})},children:[(0,o.jsx)(`input`,{"data-oauth-prompt-input":!0,type:r.prompt.type===`secret`?`password`:`text`,className:`key-input`,placeholder:r.prompt.placeholder,value:u,onChange:e=>d(e.target.value)}),(0,o.jsx)(`button`,{type:`submit`,className:`btn primary sm`,"data-oauth-prompt-submit":!0,disabled:!u.trim(),children:s(`oauthContinue`)})]}),(0,o.jsx)(`button`,{type:`button`,className:`btn sm danger`,"data-oauth-cancel":r.flowId,onClick:()=>n({type:`provider_oauth_cancel`,flowId:r.flowId}),children:s(`cancel`)})]}):(0,o.jsx)(`button`,{type:`button`,className:`btn primary sm`,"data-provider-oauth-login":e.id,onClick:()=>n({type:`provider_oauth_start`,provider:e.id}),children:s(`oauthLogin`,{name:l})}),i?.error&&(0,o.jsx)(`div`,{className:`provider-oauth-error`,children:i.error})]})}export{s as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,K as n,Sn as r,Vt as i,_ as a,ct as o,nn as ee,t as te,x as ne}from"./app-globals-KqOVtmp1.js";import{i as s,t as c}from"./react-CR5VJ85Q.js";import{t as re}from"./uuid-BzDIGCwP.js";import{H as l}from"./index-BawF7ZP5.js";var u=e(s(),1),ie=e=>`'${e.replace(/'/g,`'\\''`)}'`,ae=`pi-web-ui:scm-sidebar-width`;function oe(e,t=0){if(!Number.isFinite(e))return 300;let n=Math.max(200,Math.min(720,t>0?t-220:720));return Math.min(n,Math.max(200,Math.round(e)))}function se(e){return e===null||e.trim()===``?300:oe(Number(e))}function d(e,t){let n=t.toLowerCase();return e.subject.toLowerCase().includes(n)||e.author.toLowerCase().includes(n)||e.shortHash.toLowerCase().includes(n)||e.hash.toLowerCase().includes(n)||e.decorations!==void 0&&e.decorations.toLowerCase().includes(n)}function ce(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(e=>n.every(t=>d(e,t)))}var f=`scm-commit-history`;function le(e=localStorage){try{let t=e.getItem(f);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}catch{return[]}}function ue(e,t=localStorage){let n=e.trim();if(!n)return le(t);let r=[n,...le(t).filter(e=>e!==n)].slice(0,20);try{t.setItem(f,JSON.stringify(r))}catch{}return r}var p={idx:-1,draft:``};function de(e,t,n,r){return e.length===0?null:r===`up`?t.idx>=e.length-1?null:t.idx===-1?{state:{idx:0,draft:n},text:e[0]}:{state:{idx:t.idx+1,draft:t.draft},text:e[t.idx+1]}:t.idx===-1?null:t.idx===0?{state:p,text:t.draft}:{state:{idx:t.idx-1,draft:t.draft},text:e[t.idx-1]}}var m=c();function fe(e){if(e.x===`?`&&e.y===`?`)return`untracked`;let t=e.x!==` `&&e.x!==`?`,n=e.y!==` `&&e.y!==`?`;return t&&n?`both`:t?`staged`:`unstaged`}function h({chat:e,terminal:s,active:c,onSwitchToTerminal:d,uiScmToolbar:f,onUiAction:h}){let g=r(),[_,v]=(0,u.useState)(null),[y,b]=(0,u.useState)([]),[x,pe]=(0,u.useState)(``),[me,he]=(0,u.useState)(new Map),[S,ge]=(0,u.useState)(`changes`),[C,_e]=(0,u.useState)([]),[w,T]=(0,u.useState)(null),[ve,E]=(0,u.useState)(``),[D,O]=(0,u.useState)(!1),[k,A]=(0,u.useState)(null),[j,M]=(0,u.useState)(null),[ye,N]=(0,u.useState)(!1),[be,xe]=(0,u.useState)(!1),[Se,Ce]=(0,u.useState)(!1),[P,F]=(0,u.useState)(null),[I,we]=(0,u.useState)(!1),[L,R]=(0,u.useState)(!1),[Te,z]=(0,u.useState)(null),[B,Ee]=(0,u.useState)(()=>se(localStorage.getItem(ae))),[V,H]=(0,u.useState)(``),[U,De]=(0,u.useState)(``),[Oe,ke]=(0,u.useState)(()=>le()),W=(0,u.useRef)(p),Ae=(0,u.useRef)(0),je=(0,u.useRef)(-1),Me=(0,u.useRef)(-1),Ne=(0,u.useRef)(-1),G=(0,u.useRef)(-1),K=(0,u.useRef)(-1),Pe=(0,u.useRef)(void 0),Fe=(0,u.useRef)(null),Ie=(0,u.useRef)([]),Le=(0,u.useRef)(B);Le.current=B;let Re=(0,u.useRef)(null),q=(0,u.useCallback)(e=>{try{localStorage.setItem(ae,String(e))}catch{}},[]),ze=(0,u.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=Le.current,r=Re.current?.getBoundingClientRect().width??0,i=n,a=e=>{i=oe(n+(e.clientX-t),r),Ee(i)},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),document.body.classList.remove(`panel-resizing`),q(i)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),document.body.classList.add(`panel-resizing`)},[q]),Be=(0,u.useCallback)(()=>{Ee(300),q(300)},[q]),Ve=(0,u.useCallback)(e=>{if(e.reqId===je.current){if(je.current=-1,xe(!1),F(null),!e.ok){F(e.error??g(`scmQueryFailedShort`));return}if(e.notRepo){we(!0),v(null),b([]),he(new Map),_e([]),T(null),E(``),M(null);return}we(!1);let t={branch:e.branch??``,detached:!!e.detached,upstream:e.upstream??null,ahead:e.ahead??0,behind:e.behind??0,upstreamGone:!!e.upstreamGone,files:(e.files??[]).map(e=>({...e}))},n=(e.branches??[]).map(e=>({...e})),r=new Map;for(let[t,n]of Object.entries(e.stats??{}))r.set(t,{add:n[0],del:n[1]});v(t),b(n),he(r),pe(e=>t.detached?e||``:t.branch&&n.some(e=>e.name===t.branch)?t.branch:e&&n.some(t=>t.name===e)?e:n[0]?.name??``),M(e=>e&&!t.files.some(t=>t.path===e.file.path)?null:e)}else if(e.reqId===Me.current){if(Me.current=-1,N(!1),!e.ok){F(e.error??g(`scmQueryFailedShort`));return}let t=Fe.current;if(!t)return;M({file:t,staged:e.stagedText??``,worktree:e.worktreeText??``,untracked:!1})}else if(e.reqId===G.current){if(G.current=-1,Ce(!1),!e.ok){F(e.error??g(`scmQueryFailedShort`));return}_e((e.history??[]).map(e=>({...e})))}else if(e.reqId===Ne.current){if(Ne.current=-1,O(!1),!e.ok){F(e.error??g(`scmQueryFailedShort`));return}E(e.text??``)}else if(e.reqId===K.current){if(K.current=-1,R(!1),!e.ok){z(e.error??g(`scmGenMsgFail`));return}z(null),H(e.text??``)}},[]);(0,u.useEffect)(()=>{let t=e.scmData;t&&t.type===`scm_data`&&Ve(t)},[e.scmData,Ve]);let J=(0,u.useCallback)((t,n)=>{if(!e.ready||e.status!==`open`)return!1;let r=++Ae.current;return te({...t,reqId:r})?(n.current=r,!0):(--Ae.current,!1)},[e.ready,e.status]),Y=(0,u.useCallback)((t=!1,n=!1)=>{e.ready&&e.status===`open`&&e.state?.cwd&&(Pe.current!==void 0&&Pe.current!==e.state.cwd&&(v(null),b([]),he(new Map),_e([]),De(``),Ce(!1),G.current=-1,T(null),E(``),M(null),A(null),z(null),R(!1),K.current=-1),Pe.current=e.state.cwd,F(null),J({type:`scm_status`},je)&&(n||xe(!0)))},[e.ready,e.state?.cwd,e.status,J]),He=(0,u.useCallback)(e=>{if(A(e),T(null),Fe.current=e,e.x===`?`&&e.y===`?`){M({file:e,staged:``,worktree:``,untracked:!0});return}N(!0),F(null),J({type:`scm_filediff`,path:e.path},Me)||N(!1)},[J]),Ue=(0,u.useCallback)(e=>{T(e),A(null),M(null),E(``),O(!0),F(null),J({type:`scm_commit`,hash:e.hash},Ne)||O(!1)},[J]),X=(0,u.useCallback)((t,n)=>{if(!e.ready)return;let r={name:t,command:n,cwd:"${pwd}"},i,a=e.terminals.find(e=>e.title===t);a?(s.restart(a.id),te({type:`run_command`,terminalId:a.id,conversationId:a.conversationId,command:r,cols:80,rows:24}),i=a.id):(i=re(),s.create({id:i,conversationId:e.activeConversationId||e.state?.conversationId||``,title:t,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:r})),s.select(i),d()},[e.ready,e.state?.cwd,e.terminals,d,s]),We=(0,u.useCallback)(()=>{let e=V.trim();if(!e||I)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);X(`git commit`,`git commit -m "${t}"`),ke(ue(e)),H(``),W.current=p},[V,I,X]),Ge=(0,u.useCallback)(()=>{let e=V.trim();if(!e||I)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);X(`git commit`,`git add -A && git commit -m "${t}"`),ke(ue(e)),H(``),W.current=p},[V,I,X]),Ke=(0,u.useCallback)(e=>{I||X(`git add`,`git add -- ${ie(e.path)}`)},[I,X]),qe=(0,u.useCallback)(e=>{I||X(`git reset`,`git reset HEAD -- ${ie(e.path)}`)},[I,X]),Je=(0,u.useCallback)(()=>{if(!x||I)return;let e=y.find(e=>e.name===x);if(e?.remote&&typeof e.remote==`string`){let t=x.slice(e.remote.length+1);X(`git checkout`,`git checkout -b ${t} ${x} || git checkout ${x}`)}else X(`git checkout`,`git checkout ${x}`)},[x,y,I,X]),Ye=(0,u.useCallback)(()=>X(`git push`,`git push`),[X]),Xe=(0,u.useCallback)(()=>X(`git pull`,`git pull`),[X]),Ze=(0,u.useCallback)(()=>{L||I||!e.ready||e.status!==`open`||(z(null),J({type:`scm_commitmsg`},K)?R(!0):z(g(`scmGenMsgFail`)))},[L,I,e.ready,e.status,J,g]),Z=(0,u.useCallback)(()=>{J({type:`scm_history`},G)||(G.current=-1)},[J]);(0,u.useEffect)(()=>{c&&Y()},[c,Y]),(0,u.useEffect)(()=>{S===`history`&&_&&Z()},[S,_,Z]),(0,u.useEffect)(()=>{e.scmDirty>0&&c&&Y(!1,!0)},[e.scmDirty]),(0,u.useEffect)(()=>{if(!c||!e.ready||e.status!==`open`)return;let t=setInterval(()=>{document.visibilityState!==`hidden`&&Y(!1,!0)},3e4);return()=>clearInterval(t)},[c,e.ready,e.status,Y]),(0,u.useEffect)(()=>{let t=Ie.current;Ie.current=e.terminals,c&&e.terminals.some(e=>e.running===!1&&t.find(t=>t.id===e.id)?.running===!0&&e.title.startsWith(`git `))&&e.ready&&e.status===`open`&&(Y(!1,!0),S===`history`&&_&&Z())},[e.terminals,c,e.ready,e.status,Y,S,_,Z]);let Qe={staged:g(`scmStaged`),unstaged:g(`scmUnstaged`),untracked:g(`scmUntracked`),both:g(`scmStagedUnstaged`)},$e=ce(C,U),et=e=>{let t=e.split(`
|
|
2
|
+
`);return(0,m.jsx)(`pre`,{className:`scm-diff-pre`,children:t.map((e,t)=>{let n=``;return e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`new file`)||e.startsWith(`deleted file`)||e.startsWith(`old mode`)||e.startsWith(`new mode`)||e.startsWith(`similarity index`)||e.startsWith(`rename `)||e.startsWith(`copy `)||e.startsWith(`Binary files`)||e.startsWith(`---`)||e.startsWith(`+++`)?n=`hdr`:e.startsWith(`@@`)?n=`hunk`:e.startsWith(`+`)?n=`add`:e.startsWith(`-`)&&(n=`del`),(0,m.jsx)(`div`,{className:`scm-diff-line ${n}`,children:e||` `},t)})})},tt=f===void 0?[`host:scm-changes`,`host:scm-history`,`host:scm-refresh`,`host:scm-branch`,`host:scm-switch`,`host:scm-push`,`host:scm-pull`,`host:scm-input`,`host:scm-genmsg`,`host:scm-commit`,`host:scm-commit-all`,`host:scm-term`].map(e=>({id:e,source:`host`})):f.filter(e=>!e.hidden),nt=[`host:scm-branch`,`host:scm-switch`,`host:scm-push`,`host:scm-pull`,`host:scm-input`,`host:scm-genmsg`,`host:scm-commit`,`host:scm-commit-all`],rt=(e,t)=>{let n=new Set(e);return tt.filter(e=>n.has(e.id)||t&&e.source!==`host`)},it=e=>f===void 0||!f.some(t=>t.id===e&&t.hidden),Q=(e,t)=>{let n=tt.find(t=>t.id===e);return n?.labelExplicit?n.label:t},$={"host:scm-changes":(0,m.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":S===`changes`,className:S===`changes`?`active`:``,onClick:()=>{ge(`changes`),F(null)},children:Q(`host:scm-changes`,g(`scmChanges`))}),"host:scm-history":(0,m.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":S===`history`,className:S===`history`?`active`:``,onClick:()=>{ge(`history`),F(null)},children:Q(`host:scm-history`,g(`scmHistory`))}),"host:scm-refresh":(0,m.jsx)(`button`,{type:`button`,className:`panel-refresh`,title:g(`scmRefreshTip`),disabled:be,onClick:()=>Y(!0),children:(0,m.jsx)(i,{className:be?`scm-spin`:``})}),"host:scm-branch":(0,m.jsxs)(`select`,{className:`scm-select`,value:x,disabled:I||y.length===0,title:Q(`host:scm-branch`,g(`scmSwitchBranch`)),onChange:e=>pe(e.target.value),children:[(0,m.jsx)(`option`,{value:``,disabled:!0,children:g(`scmSelectBranch`)}),y.filter(e=>!e.remote).map(e=>(0,m.jsx)(`option`,{value:e.name,children:e.current?`* ${e.name}`:e.name},e.name)),y.some(e=>e.remote)&&(0,m.jsx)(`optgroup`,{label:g(`scmRemoteBranches`),children:y.filter(e=>e.remote).map(e=>(0,m.jsx)(`option`,{value:e.name,children:e.name},e.name))})]}),"host:scm-switch":(0,m.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!x||x===_?.branch||I,title:g(`scmSwitchBranchTip`,{branch:x}),onClick:Je,children:[(0,m.jsx)(o,{}),Q(`host:scm-switch`,g(`scmSwitch`))]}),"host:scm-push":(0,m.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!_||_.detached||I,title:g(`scmPushTip`),onClick:Ye,children:[(0,m.jsx)(ne,{}),Q(`host:scm-push`,g(`scmPush`))]}),"host:scm-pull":(0,m.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!_||_.detached||I,title:g(`scmPullTip`),onClick:Xe,children:[(0,m.jsx)(a,{}),Q(`host:scm-pull`,g(`scmPull`))]}),"host:scm-input":(0,m.jsx)(`input`,{className:`scm-commit-input`,value:V,placeholder:g(`scmCommitPlaceholder`),disabled:I,title:Oe.length>0?g(`scmCommitHistoryTip`):void 0,onChange:e=>{H(e.target.value),W.current=p},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`Enter`){We();return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){let t=de(Oe,W.current,V,e.key===`ArrowUp`?`up`:`down`);t&&(e.preventDefault(),W.current=t.state,H(t.text))}}}}),"host:scm-genmsg":(0,m.jsxs)(`button`,{type:`button`,className:`btn`,disabled:L||I||!_||_.files.length===0,title:g(`scmGenMsgTip`),onClick:Ze,children:[(0,m.jsx)(n,{className:L?`scm-spin`:``}),L?g(`scmGenMsgRunning`):Q(`host:scm-genmsg`,g(`scmGenMsg`))]}),"host:scm-commit":(0,m.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!V.trim()||I,title:g(`scmCommitTip`),onClick:We,children:[(0,m.jsx)(t,{}),Q(`host:scm-commit`,g(`scmCommit`))]}),"host:scm-commit-all":(0,m.jsx)(`button`,{type:`button`,className:`btn`,disabled:!V.trim()||I,title:g(`scmCommitAllTip`),onClick:Ge,children:Q(`host:scm-commit-all`,g(`scmCommitAll`))})};return(0,m.jsxs)(`div`,{className:`scm-view`,children:[(0,m.jsxs)(`div`,{className:`scm-header`,children:[(0,m.jsxs)(`div`,{className:`scm-title-row`,children:[(0,m.jsxs)(`span`,{className:`scm-title`,children:[(0,m.jsx)(o,{}),g(`scmTitle`)]}),(0,m.jsx)(`div`,{className:`scm-view-tabs`,role:`tablist`,children:l(rt([`host:scm-changes`,`host:scm-history`],!1),$,h)}),l(rt([`host:scm-refresh`],!0),$,h)]}),(0,m.jsxs)(`div`,{className:`scm-row`,children:[(0,m.jsxs)(`span`,{className:`scm-branch-current`,title:g(`scmCurrentBranch`),children:[(0,m.jsx)(o,{}),_?_.detached?g(`scmDetached`):_.branch:`…`,_?.upstream&&(0,m.jsx)(`span`,{className:`scm-upstream`,children:_.upstreamGone?g(`scmUpstreamGone`):_.ahead>0||_.behind>0?g(`scmAheadBehind`,{ahead:_.ahead,behind:_.behind}):_.upstream})]}),l(rt(nt,!1),$,h)]}),Te&&(0,m.jsx)(`div`,{className:`scm-gen-error`,role:`alert`,title:g(`close`),onClick:()=>z(null),children:Te})]}),(0,m.jsxs)(`div`,{className:`scm-body`,ref:Re,style:{"--scm-sidebar-w":`${B}px`},children:[S===`history`?(0,m.jsxs)(`div`,{className:`scm-history`,children:[(0,m.jsxs)(`div`,{className:`scm-files-header`,children:[(0,m.jsx)(`span`,{children:g(`scmHistory`)}),C.length>0&&(0,m.jsx)(`span`,{className:`scm-files-count`,children:U.trim()?`${$e.length}/${C.length}`:C.length})]}),C.length>0&&!I&&(0,m.jsx)(`input`,{className:`scm-history-filter`,value:U,placeholder:g(`scmHistoryFilterPlaceholder`),title:g(`scmHistoryFilterTip`),onChange:e=>De(e.target.value)}),(0,m.jsx)(`div`,{className:`scm-history-list`,children:I?(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmNotGitRepo`)}):!_||Se?(0,m.jsx)(`div`,{className:`scm-empty`,children:e.status===`open`?g(`scmLoading`):g(`scmConnecting`)}):C.length===0?(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmNoHistory`)}):$e.length===0?(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmHistoryFilterEmpty`)}):$e.map(e=>(0,m.jsxs)(`button`,{type:`button`,className:`scm-commit ${w?.hash===e.hash?`active`:``}`,onClick:()=>Ue(e),title:e.hash,children:[(0,m.jsx)(`span`,{className:`scm-commit-graph`,"aria-hidden":`true`,children:e.graph||`* `}),(0,m.jsxs)(`span`,{className:`scm-commit-info`,children:[(0,m.jsx)(`span`,{className:`scm-commit-subject`,children:e.subject}),(0,m.jsxs)(`span`,{className:`scm-commit-meta`,children:[e.shortHash,` · `,e.author,` · `,e.date]}),e.decorations&&(0,m.jsx)(`span`,{className:`scm-commit-refs`,children:e.decorations})]})]},e.hash))})]}):(0,m.jsxs)(`div`,{className:`scm-files`,children:[(0,m.jsxs)(`div`,{className:`scm-files-header`,children:[(0,m.jsx)(`span`,{children:g(`scmChanges`)}),_&&_.files.length>0&&(0,m.jsx)(`span`,{className:`scm-files-count`,children:_.files.length})]}),(0,m.jsx)(`div`,{className:`scm-files-list`,children:I?(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmNotGitRepo`)}):_?_.files.length===0?(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmNoChanges`)}):_.files.map(e=>{let t=fe(e),n=me.get(e.path);return(0,m.jsxs)(`div`,{className:`scm-file ${k?.path===e.path?`active`:``}`,title:Qe[t],onClick:()=>He(e),children:[(0,m.jsx)(`span`,{className:`scm-file-xy ${t===`untracked`?`q`:`x`}`,children:e.x===` `?`\xA0`:e.x}),(0,m.jsx)(`span`,{className:`scm-file-xy ${t===`untracked`?`q`:`y`}`,children:e.y===` `?`\xA0`:e.y}),(0,m.jsx)(`span`,{className:`scm-file-path`,children:e.path}),n&&(n.add>0||n.del>0)&&(0,m.jsxs)(`span`,{className:`scm-file-stat`,children:[n.add>0&&(0,m.jsxs)(`span`,{className:`add`,children:[`+`,n.add]}),n.del>0&&(0,m.jsxs)(`span`,{className:`del`,children:[`-`,n.del]})]}),(0,m.jsxs)(`span`,{className:`scm-file-actions`,children:[(e.y!==` `||t===`untracked`)&&(0,m.jsx)(`button`,{type:`button`,className:`scm-act`,title:g(`scmStageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),Ke(e)},children:`+`}),t===`staged`||t===`both`?(0,m.jsx)(`button`,{type:`button`,className:`scm-act`,title:g(`scmUnstageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),qe(e)},children:`−`}):null]})]},e.path)}):(0,m.jsx)(`div`,{className:`scm-empty`,children:e.status===`open`?g(`scmLoading`):g(`scmConnecting`)})})]}),(0,m.jsx)(`div`,{className:`scm-divider`,role:`separator`,"aria-orientation":`vertical`,title:g(`dragToResize`),onPointerDown:ze,onDoubleClick:Be}),(0,m.jsxs)(`div`,{className:`scm-diff`,children:[(0,m.jsxs)(`div`,{className:`scm-diff-header`,children:[(0,m.jsx)(`span`,{children:S===`history`?w?`${w.shortHash} ${w.subject}`:g(`scmCommitDetail`):k?k.path:g(`scmDiff`)}),(S===`history`?D:ye)&&(0,m.jsx)(`span`,{className:`scm-diff-loading`,children:g(`scmLoading`)})]}),(0,m.jsx)(`div`,{className:`scm-diff-body`,children:S===`history`?(0,m.jsxs)(m.Fragment,{children:[P&&(0,m.jsx)(`div`,{className:`scm-error`,children:P}),!w&&!P&&(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmSelectCommitHint`)}),w&&D&&!P&&(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmLoading`)}),w&&!D&&!P&&ve?et(ve):null]}):(0,m.jsxs)(m.Fragment,{children:[P&&(0,m.jsx)(`div`,{className:`scm-error`,children:P}),!k&&!P&&(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmSelectFileHint`)}),k&&!j&&!P&&(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmLoading`)}),k&&j&&j.untracked&&(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmUntrackedNote`)}),k&&j&&!j.untracked&&(0,m.jsxs)(m.Fragment,{children:[j.staged&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`scm-diff-section`,children:g(`scmStaged`)}),et(j.staged)]}),j.worktree&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`scm-diff-section`,children:g(`scmUnstaged`)}),et(j.worktree)]}),!j.staged&&!j.worktree&&(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmNoDiff`)})]})]})})]})]}),(0,m.jsxs)(`div`,{className:`scm-hint`,children:[(0,m.jsx)(ee,{}),(0,m.jsx)(`span`,{children:g(`scmRunsInTerminal`)}),it(`host:scm-term`)&&(0,m.jsx)(`button`,{type:`button`,className:`scm-goto-term`,onClick:d,children:Q(`host:scm-term`,g(`scmViewTerminal`))})]})]})}export{h as ScmPanel};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,K as n,Sn as r,Vt as i,_ as a,ct as o,nn as ee,t as te,x as ne}from"./app-globals-KqOVtmp1.js";import{i as s,t as c}from"./react-CR5VJ85Q.js";import{t as re}from"./uuid-BzDIGCwP.js";import{H as l}from"./index-BoGCoq5X.js";var u=e(s(),1),ie=e=>`'${e.replace(/'/g,`'\\''`)}'`,ae=`pi-web-ui:scm-sidebar-width`;function oe(e,t=0){if(!Number.isFinite(e))return 300;let n=Math.max(200,Math.min(720,t>0?t-220:720));return Math.min(n,Math.max(200,Math.round(e)))}function se(e){return e===null||e.trim()===``?300:oe(Number(e))}function d(e,t){let n=t.toLowerCase();return e.subject.toLowerCase().includes(n)||e.author.toLowerCase().includes(n)||e.shortHash.toLowerCase().includes(n)||e.hash.toLowerCase().includes(n)||e.decorations!==void 0&&e.decorations.toLowerCase().includes(n)}function ce(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(e=>n.every(t=>d(e,t)))}var f=`scm-commit-history`;function le(e=localStorage){try{let t=e.getItem(f);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}catch{return[]}}function ue(e,t=localStorage){let n=e.trim();if(!n)return le(t);let r=[n,...le(t).filter(e=>e!==n)].slice(0,20);try{t.setItem(f,JSON.stringify(r))}catch{}return r}var p={idx:-1,draft:``};function de(e,t,n,r){return e.length===0?null:r===`up`?t.idx>=e.length-1?null:t.idx===-1?{state:{idx:0,draft:n},text:e[0]}:{state:{idx:t.idx+1,draft:t.draft},text:e[t.idx+1]}:t.idx===-1?null:t.idx===0?{state:p,text:t.draft}:{state:{idx:t.idx-1,draft:t.draft},text:e[t.idx-1]}}var m=c();function fe(e){if(e.x===`?`&&e.y===`?`)return`untracked`;let t=e.x!==` `&&e.x!==`?`,n=e.y!==` `&&e.y!==`?`;return t&&n?`both`:t?`staged`:`unstaged`}function h({chat:e,terminal:s,active:c,onSwitchToTerminal:d,uiScmToolbar:f,onUiAction:h}){let g=r(),[_,v]=(0,u.useState)(null),[y,b]=(0,u.useState)([]),[x,pe]=(0,u.useState)(``),[me,he]=(0,u.useState)(new Map),[S,ge]=(0,u.useState)(`changes`),[C,_e]=(0,u.useState)([]),[w,T]=(0,u.useState)(null),[ve,E]=(0,u.useState)(``),[D,O]=(0,u.useState)(!1),[k,A]=(0,u.useState)(null),[j,M]=(0,u.useState)(null),[ye,N]=(0,u.useState)(!1),[be,xe]=(0,u.useState)(!1),[Se,Ce]=(0,u.useState)(!1),[P,F]=(0,u.useState)(null),[I,we]=(0,u.useState)(!1),[L,R]=(0,u.useState)(!1),[Te,z]=(0,u.useState)(null),[B,Ee]=(0,u.useState)(()=>se(localStorage.getItem(ae))),[V,H]=(0,u.useState)(``),[U,De]=(0,u.useState)(``),[Oe,ke]=(0,u.useState)(()=>le()),W=(0,u.useRef)(p),Ae=(0,u.useRef)(0),je=(0,u.useRef)(-1),Me=(0,u.useRef)(-1),Ne=(0,u.useRef)(-1),G=(0,u.useRef)(-1),K=(0,u.useRef)(-1),Pe=(0,u.useRef)(void 0),Fe=(0,u.useRef)(null),Ie=(0,u.useRef)([]),Le=(0,u.useRef)(B);Le.current=B;let Re=(0,u.useRef)(null),q=(0,u.useCallback)(e=>{try{localStorage.setItem(ae,String(e))}catch{}},[]),ze=(0,u.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=Le.current,r=Re.current?.getBoundingClientRect().width??0,i=n,a=e=>{i=oe(n+(e.clientX-t),r),Ee(i)},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),document.body.classList.remove(`panel-resizing`),q(i)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),document.body.classList.add(`panel-resizing`)},[q]),Be=(0,u.useCallback)(()=>{Ee(300),q(300)},[q]),Ve=(0,u.useCallback)(e=>{if(e.reqId===je.current){if(je.current=-1,xe(!1),F(null),!e.ok){F(e.error??g(`scmQueryFailedShort`));return}if(e.notRepo){we(!0),v(null),b([]),he(new Map),_e([]),T(null),E(``),M(null);return}we(!1);let t={branch:e.branch??``,detached:!!e.detached,upstream:e.upstream??null,ahead:e.ahead??0,behind:e.behind??0,upstreamGone:!!e.upstreamGone,files:(e.files??[]).map(e=>({...e}))},n=(e.branches??[]).map(e=>({...e})),r=new Map;for(let[t,n]of Object.entries(e.stats??{}))r.set(t,{add:n[0],del:n[1]});v(t),b(n),he(r),pe(e=>t.detached?e||``:t.branch&&n.some(e=>e.name===t.branch)?t.branch:e&&n.some(t=>t.name===e)?e:n[0]?.name??``),M(e=>e&&!t.files.some(t=>t.path===e.file.path)?null:e)}else if(e.reqId===Me.current){if(Me.current=-1,N(!1),!e.ok){F(e.error??g(`scmQueryFailedShort`));return}let t=Fe.current;if(!t)return;M({file:t,staged:e.stagedText??``,worktree:e.worktreeText??``,untracked:!1})}else if(e.reqId===G.current){if(G.current=-1,Ce(!1),!e.ok){F(e.error??g(`scmQueryFailedShort`));return}_e((e.history??[]).map(e=>({...e})))}else if(e.reqId===Ne.current){if(Ne.current=-1,O(!1),!e.ok){F(e.error??g(`scmQueryFailedShort`));return}E(e.text??``)}else if(e.reqId===K.current){if(K.current=-1,R(!1),!e.ok){z(e.error??g(`scmGenMsgFail`));return}z(null),H(e.text??``)}},[]);(0,u.useEffect)(()=>{let t=e.scmData;t&&t.type===`scm_data`&&Ve(t)},[e.scmData,Ve]);let J=(0,u.useCallback)((t,n)=>{if(!e.ready||e.status!==`open`)return!1;let r=++Ae.current;return te({...t,reqId:r})?(n.current=r,!0):(--Ae.current,!1)},[e.ready,e.status]),Y=(0,u.useCallback)((t=!1,n=!1)=>{e.ready&&e.status===`open`&&e.state?.cwd&&(Pe.current!==void 0&&Pe.current!==e.state.cwd&&(v(null),b([]),he(new Map),_e([]),De(``),Ce(!1),G.current=-1,T(null),E(``),M(null),A(null),z(null),R(!1),K.current=-1),Pe.current=e.state.cwd,F(null),J({type:`scm_status`},je)&&(n||xe(!0)))},[e.ready,e.state?.cwd,e.status,J]),He=(0,u.useCallback)(e=>{if(A(e),T(null),Fe.current=e,e.x===`?`&&e.y===`?`){M({file:e,staged:``,worktree:``,untracked:!0});return}N(!0),F(null),J({type:`scm_filediff`,path:e.path},Me)||N(!1)},[J]),Ue=(0,u.useCallback)(e=>{T(e),A(null),M(null),E(``),O(!0),F(null),J({type:`scm_commit`,hash:e.hash},Ne)||O(!1)},[J]),X=(0,u.useCallback)((t,n)=>{if(!e.ready)return;let r={name:t,command:n,cwd:"${pwd}"},i,a=e.terminals.find(e=>e.title===t);a?(s.restart(a.id),te({type:`run_command`,terminalId:a.id,conversationId:a.conversationId,command:r,cols:80,rows:24}),i=a.id):(i=re(),s.create({id:i,conversationId:e.activeConversationId||e.state?.conversationId||``,title:t,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:r})),s.select(i),d()},[e.ready,e.state?.cwd,e.terminals,d,s]),We=(0,u.useCallback)(()=>{let e=V.trim();if(!e||I)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);X(`git commit`,`git commit -m "${t}"`),ke(ue(e)),H(``),W.current=p},[V,I,X]),Ge=(0,u.useCallback)(()=>{let e=V.trim();if(!e||I)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);X(`git commit`,`git add -A && git commit -m "${t}"`),ke(ue(e)),H(``),W.current=p},[V,I,X]),Ke=(0,u.useCallback)(e=>{I||X(`git add`,`git add -- ${ie(e.path)}`)},[I,X]),qe=(0,u.useCallback)(e=>{I||X(`git reset`,`git reset HEAD -- ${ie(e.path)}`)},[I,X]),Je=(0,u.useCallback)(()=>{if(!x||I)return;let e=y.find(e=>e.name===x);if(e?.remote&&typeof e.remote==`string`){let t=x.slice(e.remote.length+1);X(`git checkout`,`git checkout -b ${t} ${x} || git checkout ${x}`)}else X(`git checkout`,`git checkout ${x}`)},[x,y,I,X]),Ye=(0,u.useCallback)(()=>X(`git push`,`git push`),[X]),Xe=(0,u.useCallback)(()=>X(`git pull`,`git pull`),[X]),Ze=(0,u.useCallback)(()=>{L||I||!e.ready||e.status!==`open`||(z(null),J({type:`scm_commitmsg`},K)?R(!0):z(g(`scmGenMsgFail`)))},[L,I,e.ready,e.status,J,g]),Z=(0,u.useCallback)(()=>{J({type:`scm_history`},G)||(G.current=-1)},[J]);(0,u.useEffect)(()=>{c&&Y()},[c,Y]),(0,u.useEffect)(()=>{S===`history`&&_&&Z()},[S,_,Z]),(0,u.useEffect)(()=>{e.scmDirty>0&&c&&Y(!1,!0)},[e.scmDirty]),(0,u.useEffect)(()=>{if(!c||!e.ready||e.status!==`open`)return;let t=setInterval(()=>{document.visibilityState!==`hidden`&&Y(!1,!0)},3e4);return()=>clearInterval(t)},[c,e.ready,e.status,Y]),(0,u.useEffect)(()=>{let t=Ie.current;Ie.current=e.terminals,c&&e.terminals.some(e=>e.running===!1&&t.find(t=>t.id===e.id)?.running===!0&&e.title.startsWith(`git `))&&e.ready&&e.status===`open`&&(Y(!1,!0),S===`history`&&_&&Z())},[e.terminals,c,e.ready,e.status,Y,S,_,Z]);let Qe={staged:g(`scmStaged`),unstaged:g(`scmUnstaged`),untracked:g(`scmUntracked`),both:g(`scmStagedUnstaged`)},$e=ce(C,U),et=e=>{let t=e.split(`
|
|
2
|
+
`);return(0,m.jsx)(`pre`,{className:`scm-diff-pre`,children:t.map((e,t)=>{let n=``;return e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`new file`)||e.startsWith(`deleted file`)||e.startsWith(`old mode`)||e.startsWith(`new mode`)||e.startsWith(`similarity index`)||e.startsWith(`rename `)||e.startsWith(`copy `)||e.startsWith(`Binary files`)||e.startsWith(`---`)||e.startsWith(`+++`)?n=`hdr`:e.startsWith(`@@`)?n=`hunk`:e.startsWith(`+`)?n=`add`:e.startsWith(`-`)&&(n=`del`),(0,m.jsx)(`div`,{className:`scm-diff-line ${n}`,children:e||` `},t)})})},tt=f===void 0?[`host:scm-changes`,`host:scm-history`,`host:scm-refresh`,`host:scm-branch`,`host:scm-switch`,`host:scm-push`,`host:scm-pull`,`host:scm-input`,`host:scm-genmsg`,`host:scm-commit`,`host:scm-commit-all`,`host:scm-term`].map(e=>({id:e,source:`host`})):f.filter(e=>!e.hidden),nt=[`host:scm-branch`,`host:scm-switch`,`host:scm-push`,`host:scm-pull`,`host:scm-input`,`host:scm-genmsg`,`host:scm-commit`,`host:scm-commit-all`],rt=(e,t)=>{let n=new Set(e);return tt.filter(e=>n.has(e.id)||t&&e.source!==`host`)},it=e=>f===void 0||!f.some(t=>t.id===e&&t.hidden),Q=(e,t)=>{let n=tt.find(t=>t.id===e);return n?.labelExplicit?n.label:t},$={"host:scm-changes":(0,m.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":S===`changes`,className:S===`changes`?`active`:``,onClick:()=>{ge(`changes`),F(null)},children:Q(`host:scm-changes`,g(`scmChanges`))}),"host:scm-history":(0,m.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":S===`history`,className:S===`history`?`active`:``,onClick:()=>{ge(`history`),F(null)},children:Q(`host:scm-history`,g(`scmHistory`))}),"host:scm-refresh":(0,m.jsx)(`button`,{type:`button`,className:`panel-refresh`,title:g(`scmRefreshTip`),disabled:be,onClick:()=>Y(!0),children:(0,m.jsx)(i,{className:be?`scm-spin`:``})}),"host:scm-branch":(0,m.jsxs)(`select`,{className:`scm-select`,value:x,disabled:I||y.length===0,title:Q(`host:scm-branch`,g(`scmSwitchBranch`)),onChange:e=>pe(e.target.value),children:[(0,m.jsx)(`option`,{value:``,disabled:!0,children:g(`scmSelectBranch`)}),y.filter(e=>!e.remote).map(e=>(0,m.jsx)(`option`,{value:e.name,children:e.current?`* ${e.name}`:e.name},e.name)),y.some(e=>e.remote)&&(0,m.jsx)(`optgroup`,{label:g(`scmRemoteBranches`),children:y.filter(e=>e.remote).map(e=>(0,m.jsx)(`option`,{value:e.name,children:e.name},e.name))})]}),"host:scm-switch":(0,m.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!x||x===_?.branch||I,title:g(`scmSwitchBranchTip`,{branch:x}),onClick:Je,children:[(0,m.jsx)(o,{}),Q(`host:scm-switch`,g(`scmSwitch`))]}),"host:scm-push":(0,m.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!_||_.detached||I,title:g(`scmPushTip`),onClick:Ye,children:[(0,m.jsx)(ne,{}),Q(`host:scm-push`,g(`scmPush`))]}),"host:scm-pull":(0,m.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!_||_.detached||I,title:g(`scmPullTip`),onClick:Xe,children:[(0,m.jsx)(a,{}),Q(`host:scm-pull`,g(`scmPull`))]}),"host:scm-input":(0,m.jsx)(`input`,{className:`scm-commit-input`,value:V,placeholder:g(`scmCommitPlaceholder`),disabled:I,title:Oe.length>0?g(`scmCommitHistoryTip`):void 0,onChange:e=>{H(e.target.value),W.current=p},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`Enter`){We();return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){let t=de(Oe,W.current,V,e.key===`ArrowUp`?`up`:`down`);t&&(e.preventDefault(),W.current=t.state,H(t.text))}}}}),"host:scm-genmsg":(0,m.jsxs)(`button`,{type:`button`,className:`btn`,disabled:L||I||!_||_.files.length===0,title:g(`scmGenMsgTip`),onClick:Ze,children:[(0,m.jsx)(n,{className:L?`scm-spin`:``}),L?g(`scmGenMsgRunning`):Q(`host:scm-genmsg`,g(`scmGenMsg`))]}),"host:scm-commit":(0,m.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!V.trim()||I,title:g(`scmCommitTip`),onClick:We,children:[(0,m.jsx)(t,{}),Q(`host:scm-commit`,g(`scmCommit`))]}),"host:scm-commit-all":(0,m.jsx)(`button`,{type:`button`,className:`btn`,disabled:!V.trim()||I,title:g(`scmCommitAllTip`),onClick:Ge,children:Q(`host:scm-commit-all`,g(`scmCommitAll`))})};return(0,m.jsxs)(`div`,{className:`scm-view`,children:[(0,m.jsxs)(`div`,{className:`scm-header`,children:[(0,m.jsxs)(`div`,{className:`scm-title-row`,children:[(0,m.jsxs)(`span`,{className:`scm-title`,children:[(0,m.jsx)(o,{}),g(`scmTitle`)]}),(0,m.jsx)(`div`,{className:`scm-view-tabs`,role:`tablist`,children:l(rt([`host:scm-changes`,`host:scm-history`],!1),$,h)}),l(rt([`host:scm-refresh`],!0),$,h)]}),(0,m.jsxs)(`div`,{className:`scm-row`,children:[(0,m.jsxs)(`span`,{className:`scm-branch-current`,title:g(`scmCurrentBranch`),children:[(0,m.jsx)(o,{}),_?_.detached?g(`scmDetached`):_.branch:`…`,_?.upstream&&(0,m.jsx)(`span`,{className:`scm-upstream`,children:_.upstreamGone?g(`scmUpstreamGone`):_.ahead>0||_.behind>0?g(`scmAheadBehind`,{ahead:_.ahead,behind:_.behind}):_.upstream})]}),l(rt(nt,!1),$,h)]}),Te&&(0,m.jsx)(`div`,{className:`scm-gen-error`,role:`alert`,title:g(`close`),onClick:()=>z(null),children:Te})]}),(0,m.jsxs)(`div`,{className:`scm-body`,ref:Re,style:{"--scm-sidebar-w":`${B}px`},children:[S===`history`?(0,m.jsxs)(`div`,{className:`scm-history`,children:[(0,m.jsxs)(`div`,{className:`scm-files-header`,children:[(0,m.jsx)(`span`,{children:g(`scmHistory`)}),C.length>0&&(0,m.jsx)(`span`,{className:`scm-files-count`,children:U.trim()?`${$e.length}/${C.length}`:C.length})]}),C.length>0&&!I&&(0,m.jsx)(`input`,{className:`scm-history-filter`,value:U,placeholder:g(`scmHistoryFilterPlaceholder`),title:g(`scmHistoryFilterTip`),onChange:e=>De(e.target.value)}),(0,m.jsx)(`div`,{className:`scm-history-list`,children:I?(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmNotGitRepo`)}):!_||Se?(0,m.jsx)(`div`,{className:`scm-empty`,children:e.status===`open`?g(`scmLoading`):g(`scmConnecting`)}):C.length===0?(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmNoHistory`)}):$e.length===0?(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmHistoryFilterEmpty`)}):$e.map(e=>(0,m.jsxs)(`button`,{type:`button`,className:`scm-commit ${w?.hash===e.hash?`active`:``}`,onClick:()=>Ue(e),title:e.hash,children:[(0,m.jsx)(`span`,{className:`scm-commit-graph`,"aria-hidden":`true`,children:e.graph||`* `}),(0,m.jsxs)(`span`,{className:`scm-commit-info`,children:[(0,m.jsx)(`span`,{className:`scm-commit-subject`,children:e.subject}),(0,m.jsxs)(`span`,{className:`scm-commit-meta`,children:[e.shortHash,` · `,e.author,` · `,e.date]}),e.decorations&&(0,m.jsx)(`span`,{className:`scm-commit-refs`,children:e.decorations})]})]},e.hash))})]}):(0,m.jsxs)(`div`,{className:`scm-files`,children:[(0,m.jsxs)(`div`,{className:`scm-files-header`,children:[(0,m.jsx)(`span`,{children:g(`scmChanges`)}),_&&_.files.length>0&&(0,m.jsx)(`span`,{className:`scm-files-count`,children:_.files.length})]}),(0,m.jsx)(`div`,{className:`scm-files-list`,children:I?(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmNotGitRepo`)}):_?_.files.length===0?(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmNoChanges`)}):_.files.map(e=>{let t=fe(e),n=me.get(e.path);return(0,m.jsxs)(`div`,{className:`scm-file ${k?.path===e.path?`active`:``}`,title:Qe[t],onClick:()=>He(e),children:[(0,m.jsx)(`span`,{className:`scm-file-xy ${t===`untracked`?`q`:`x`}`,children:e.x===` `?`\xA0`:e.x}),(0,m.jsx)(`span`,{className:`scm-file-xy ${t===`untracked`?`q`:`y`}`,children:e.y===` `?`\xA0`:e.y}),(0,m.jsx)(`span`,{className:`scm-file-path`,children:e.path}),n&&(n.add>0||n.del>0)&&(0,m.jsxs)(`span`,{className:`scm-file-stat`,children:[n.add>0&&(0,m.jsxs)(`span`,{className:`add`,children:[`+`,n.add]}),n.del>0&&(0,m.jsxs)(`span`,{className:`del`,children:[`-`,n.del]})]}),(0,m.jsxs)(`span`,{className:`scm-file-actions`,children:[(e.y!==` `||t===`untracked`)&&(0,m.jsx)(`button`,{type:`button`,className:`scm-act`,title:g(`scmStageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),Ke(e)},children:`+`}),t===`staged`||t===`both`?(0,m.jsx)(`button`,{type:`button`,className:`scm-act`,title:g(`scmUnstageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),qe(e)},children:`−`}):null]})]},e.path)}):(0,m.jsx)(`div`,{className:`scm-empty`,children:e.status===`open`?g(`scmLoading`):g(`scmConnecting`)})})]}),(0,m.jsx)(`div`,{className:`scm-divider`,role:`separator`,"aria-orientation":`vertical`,title:g(`dragToResize`),onPointerDown:ze,onDoubleClick:Be}),(0,m.jsxs)(`div`,{className:`scm-diff`,children:[(0,m.jsxs)(`div`,{className:`scm-diff-header`,children:[(0,m.jsx)(`span`,{children:S===`history`?w?`${w.shortHash} ${w.subject}`:g(`scmCommitDetail`):k?k.path:g(`scmDiff`)}),(S===`history`?D:ye)&&(0,m.jsx)(`span`,{className:`scm-diff-loading`,children:g(`scmLoading`)})]}),(0,m.jsx)(`div`,{className:`scm-diff-body`,children:S===`history`?(0,m.jsxs)(m.Fragment,{children:[P&&(0,m.jsx)(`div`,{className:`scm-error`,children:P}),!w&&!P&&(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmSelectCommitHint`)}),w&&D&&!P&&(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmLoading`)}),w&&!D&&!P&&ve?et(ve):null]}):(0,m.jsxs)(m.Fragment,{children:[P&&(0,m.jsx)(`div`,{className:`scm-error`,children:P}),!k&&!P&&(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmSelectFileHint`)}),k&&!j&&!P&&(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmLoading`)}),k&&j&&j.untracked&&(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmUntrackedNote`)}),k&&j&&!j.untracked&&(0,m.jsxs)(m.Fragment,{children:[j.staged&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`scm-diff-section`,children:g(`scmStaged`)}),et(j.staged)]}),j.worktree&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`scm-diff-section`,children:g(`scmUnstaged`)}),et(j.worktree)]}),!j.staged&&!j.worktree&&(0,m.jsx)(`div`,{className:`scm-empty`,children:g(`scmNoDiff`)})]})]})})]})]}),(0,m.jsxs)(`div`,{className:`scm-hint`,children:[(0,m.jsx)(ee,{}),(0,m.jsx)(`span`,{children:g(`scmRunsInTerminal`)}),it(`host:scm-term`)&&(0,m.jsx)(`button`,{type:`button`,className:`scm-goto-term`,onClick:d,children:Q(`host:scm-term`,g(`scmViewTerminal`))})]})]})}export{h as ScmPanel};
|