thepopebot 1.2.76-beta.21 → 1.2.76-beta.23
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/lib/code/terminal-view.js +26 -8
- package/lib/code/terminal-view.jsx +31 -8
- package/package.json +1 -1
|
@@ -780,32 +780,50 @@ function TerminalView({ codeWorkspaceId, wsPath, isActive = true, showToolbar =
|
|
|
780
780
|
] }) })
|
|
781
781
|
] });
|
|
782
782
|
}
|
|
783
|
-
const STORAGE_KEY = "thepopebot-workspace-command
|
|
783
|
+
const STORAGE_KEY = "thepopebot-workspace-command";
|
|
784
|
+
const FALLBACK_BY_MODE = { agent: "push", code: "create-pr" };
|
|
784
785
|
function ToolbarCommandButton({ codeWorkspaceId, diffStats, onDiffStatsRefresh, onShowDiff }) {
|
|
786
|
+
const [chatMode, setChatMode] = useState("code");
|
|
787
|
+
useEffect(() => {
|
|
788
|
+
if (!codeWorkspaceId) return;
|
|
789
|
+
let cancelled = false;
|
|
790
|
+
fetch(`/code/${codeWorkspaceId}/chat-data`).then((r) => r.json()).then((data) => {
|
|
791
|
+
if (cancelled) return;
|
|
792
|
+
if (data?.chatMode) setChatMode(data.chatMode);
|
|
793
|
+
}).catch(() => {
|
|
794
|
+
});
|
|
795
|
+
return () => {
|
|
796
|
+
cancelled = true;
|
|
797
|
+
};
|
|
798
|
+
}, [codeWorkspaceId]);
|
|
799
|
+
const storageKey = `${STORAGE_KEY}:${chatMode}`;
|
|
785
800
|
const [selectedCommand, setSelectedCommandState] = useState(() => {
|
|
786
801
|
try {
|
|
787
|
-
return localStorage.getItem(
|
|
802
|
+
return localStorage.getItem(storageKey) || FALLBACK_BY_MODE[chatMode] || "create-pr";
|
|
788
803
|
} catch {
|
|
789
|
-
return "create-pr";
|
|
804
|
+
return FALLBACK_BY_MODE[chatMode] || "create-pr";
|
|
790
805
|
}
|
|
791
806
|
});
|
|
792
807
|
const setSelectedCommand = (cmd) => {
|
|
793
808
|
setSelectedCommandState(cmd);
|
|
794
809
|
try {
|
|
795
|
-
localStorage.setItem(
|
|
810
|
+
localStorage.setItem(storageKey, cmd);
|
|
796
811
|
} catch {
|
|
797
812
|
}
|
|
798
813
|
};
|
|
799
814
|
useEffect(() => {
|
|
800
815
|
let stored = null;
|
|
801
816
|
try {
|
|
802
|
-
stored = localStorage.getItem(
|
|
817
|
+
stored = localStorage.getItem(storageKey);
|
|
803
818
|
} catch {
|
|
804
819
|
}
|
|
805
|
-
if (stored)
|
|
820
|
+
if (stored) {
|
|
821
|
+
setSelectedCommandState(stored);
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
806
824
|
let cancelled = false;
|
|
807
825
|
import("../chat/actions.js").then(({ getModeGitActionDefault }) => {
|
|
808
|
-
getModeGitActionDefault(
|
|
826
|
+
getModeGitActionDefault(chatMode).then((val) => {
|
|
809
827
|
if (cancelled || !val) return;
|
|
810
828
|
setSelectedCommandState(val);
|
|
811
829
|
}).catch(() => {
|
|
@@ -815,7 +833,7 @@ function ToolbarCommandButton({ codeWorkspaceId, diffStats, onDiffStatsRefresh,
|
|
|
815
833
|
return () => {
|
|
816
834
|
cancelled = true;
|
|
817
835
|
};
|
|
818
|
-
}, []);
|
|
836
|
+
}, [chatMode, storageKey]);
|
|
819
837
|
const [commandRunning, setCommandRunning] = useState(false);
|
|
820
838
|
const [dialogOpen, setDialogOpen] = useState(false);
|
|
821
839
|
const [commandOutput, setCommandOutput] = useState("");
|
|
@@ -842,31 +842,54 @@ export default function TerminalView({ codeWorkspaceId, wsPath, isActive = true,
|
|
|
842
842
|
);
|
|
843
843
|
}
|
|
844
844
|
|
|
845
|
-
const STORAGE_KEY = 'thepopebot-workspace-command
|
|
845
|
+
const STORAGE_KEY = 'thepopebot-workspace-command';
|
|
846
|
+
const FALLBACK_BY_MODE = { agent: 'push', code: 'create-pr' };
|
|
846
847
|
|
|
847
848
|
function ToolbarCommandButton({ codeWorkspaceId, diffStats, onDiffStatsRefresh, onShowDiff }) {
|
|
849
|
+
// Resolve chatMode from the workspace's chat (matches code-mode-toggle's per-mode behavior).
|
|
850
|
+
// Defaults to 'code' until the fetch resolves, since code workspaces are most often code-mode.
|
|
851
|
+
const [chatMode, setChatMode] = useState('code');
|
|
852
|
+
|
|
853
|
+
useEffect(() => {
|
|
854
|
+
if (!codeWorkspaceId) return;
|
|
855
|
+
let cancelled = false;
|
|
856
|
+
fetch(`/code/${codeWorkspaceId}/chat-data`)
|
|
857
|
+
.then((r) => r.json())
|
|
858
|
+
.then((data) => {
|
|
859
|
+
if (cancelled) return;
|
|
860
|
+
if (data?.chatMode) setChatMode(data.chatMode);
|
|
861
|
+
})
|
|
862
|
+
.catch(() => {});
|
|
863
|
+
return () => { cancelled = true; };
|
|
864
|
+
}, [codeWorkspaceId]);
|
|
865
|
+
|
|
866
|
+
const storageKey = `${STORAGE_KEY}:${chatMode}`;
|
|
848
867
|
const [selectedCommand, setSelectedCommandState] = useState(() => {
|
|
849
|
-
try { return localStorage.getItem(
|
|
868
|
+
try { return localStorage.getItem(storageKey) || FALLBACK_BY_MODE[chatMode] || 'create-pr'; }
|
|
869
|
+
catch { return FALLBACK_BY_MODE[chatMode] || 'create-pr'; }
|
|
850
870
|
});
|
|
851
871
|
const setSelectedCommand = (cmd) => {
|
|
852
872
|
setSelectedCommandState(cmd);
|
|
853
|
-
try { localStorage.setItem(
|
|
873
|
+
try { localStorage.setItem(storageKey, cmd); } catch {}
|
|
854
874
|
};
|
|
855
875
|
|
|
856
|
-
//
|
|
876
|
+
// When chatMode resolves (or changes), reload preference from its storage key, then seed from admin default if unset.
|
|
857
877
|
useEffect(() => {
|
|
858
878
|
let stored = null;
|
|
859
|
-
try { stored = localStorage.getItem(
|
|
860
|
-
if (stored)
|
|
879
|
+
try { stored = localStorage.getItem(storageKey); } catch {}
|
|
880
|
+
if (stored) {
|
|
881
|
+
setSelectedCommandState(stored);
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
861
884
|
let cancelled = false;
|
|
862
885
|
import('../chat/actions.js').then(({ getModeGitActionDefault }) => {
|
|
863
|
-
getModeGitActionDefault(
|
|
886
|
+
getModeGitActionDefault(chatMode).then((val) => {
|
|
864
887
|
if (cancelled || !val) return;
|
|
865
888
|
setSelectedCommandState(val);
|
|
866
889
|
}).catch(() => {});
|
|
867
890
|
}).catch(() => {});
|
|
868
891
|
return () => { cancelled = true; };
|
|
869
|
-
}, []);
|
|
892
|
+
}, [chatMode, storageKey]);
|
|
870
893
|
const [commandRunning, setCommandRunning] = useState(false);
|
|
871
894
|
const [dialogOpen, setDialogOpen] = useState(false);
|
|
872
895
|
const [commandOutput, setCommandOutput] = useState('');
|