fix(config-profiles): synchronize shared mount working copies
Use canonical profile files and writable Git working copies so editor and container changes share one source. Require confirmation before destructive Git refreshes and overlay profile files without composite snapshots.
This commit is contained in:
@@ -44,6 +44,7 @@ export const useConfigProfiles = () => {
|
||||
const [previewData, setPreviewData] = useState<ResolvedProfile | null>(null);
|
||||
const [previewingId, setPreviewingId] = useState<string | null>(null);
|
||||
const [isRefreshingGitMounts, setIsRefreshingGitMounts] = useState(false);
|
||||
const [isReloadingWorkingCopy, setIsReloadingWorkingCopy] = useState(false);
|
||||
const [formData, setFormData] =
|
||||
useState<CreateConfigProfileRequest>(defaultForm);
|
||||
const [includedProfileIds, setIncludedProfileIds] = useState<string[]>([]);
|
||||
@@ -275,8 +276,33 @@ export const useConfigProfiles = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleReloadWorkingCopy = async (): Promise<void> => {
|
||||
if (!selectedProfileId || isReloadingWorkingCopy) return;
|
||||
|
||||
setError(null);
|
||||
setIsReloadingWorkingCopy(true);
|
||||
try {
|
||||
const refreshedProfiles = await listConfigProfiles();
|
||||
setProfiles(refreshedProfiles);
|
||||
const refreshedProfile = refreshedProfiles.find(
|
||||
(profile) => profile.id === selectedProfileId,
|
||||
);
|
||||
if (refreshedProfile) populateForm(refreshedProfile);
|
||||
} catch (err) {
|
||||
setError(extractErrorMessage(err));
|
||||
} finally {
|
||||
setIsReloadingWorkingCopy(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleRefreshGitMounts = async (id: string): Promise<boolean> => {
|
||||
if (isRefreshingGitMounts) return false;
|
||||
if (
|
||||
!window.confirm(
|
||||
"Refresh Git mounts? This replaces local container and editor edits with the configured remote branch.",
|
||||
)
|
||||
)
|
||||
return false;
|
||||
|
||||
setError(null);
|
||||
setIsRefreshingGitMounts(true);
|
||||
@@ -452,6 +478,7 @@ export const useConfigProfiles = () => {
|
||||
previewData,
|
||||
previewingId,
|
||||
isRefreshingGitMounts,
|
||||
isReloadingWorkingCopy,
|
||||
formData,
|
||||
includedProfileIds,
|
||||
dragOverIndex,
|
||||
@@ -461,6 +488,7 @@ export const useConfigProfiles = () => {
|
||||
handleSubmit,
|
||||
handleDelete,
|
||||
handlePreview,
|
||||
handleReloadWorkingCopy,
|
||||
handleRefreshGitMounts,
|
||||
updateFormField,
|
||||
addEnvVar,
|
||||
|
||||
Reference in New Issue
Block a user