Skip to content

Commit eff0457

Browse files
committed
PR Feedback
1 parent aeeb935 commit eff0457

File tree

1 file changed

+4
-60
lines changed

1 file changed

+4
-60
lines changed

UnityMcpBridge/Editor/Windows/MCPForUnityEditorWindow.cs

Lines changed: 4 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -568,12 +568,8 @@ private void AutoFirstRunSetup()
568568
}
569569
else
570570
{
571-
bool alreadyConfigured = client.mcpType switch
572-
{
573-
McpTypes.Codex => CodexConfigHelper.IsCodexConfigured(pythonDir),
574-
_ => IsCursorConfigured(pythonDir)
575-
};
576-
571+
CheckMcpConfiguration(client);
572+
bool alreadyConfigured = client.status == McpStatus.Configured;
577573
if (!alreadyConfigured)
578574
{
579575
ConfigureMcpClient(client);
@@ -666,12 +662,8 @@ private void RunSetupNow()
666662
}
667663
else
668664
{
669-
bool alreadyConfigured = client.mcpType switch
670-
{
671-
McpTypes.Codex => CodexConfigHelper.IsCodexConfigured(pythonDir),
672-
_ => IsCursorConfigured(pythonDir)
673-
};
674-
665+
CheckMcpConfiguration(client);
666+
bool alreadyConfigured = client.status == McpStatus.Configured;
675667
if (!alreadyConfigured)
676668
{
677669
ConfigureMcpClient(client);
@@ -1149,54 +1141,6 @@ private static bool ArgsEqual(string[] a, string[] b)
11491141
return true;
11501142
}
11511143

1152-
private static void WriteAtomicFile(string path, string contents)
1153-
{
1154-
string tmp = path + ".tmp";
1155-
string backup = path + ".backup";
1156-
bool writeDone = false;
1157-
try
1158-
{
1159-
File.WriteAllText(tmp, contents, new UTF8Encoding(false));
1160-
try
1161-
{
1162-
File.Replace(tmp, path, backup);
1163-
writeDone = true;
1164-
}
1165-
catch (FileNotFoundException)
1166-
{
1167-
File.Move(tmp, path);
1168-
writeDone = true;
1169-
}
1170-
catch (PlatformNotSupportedException)
1171-
{
1172-
if (File.Exists(path))
1173-
{
1174-
try { if (File.Exists(backup)) File.Delete(backup); } catch { }
1175-
File.Move(path, backup);
1176-
}
1177-
File.Move(tmp, path);
1178-
writeDone = true;
1179-
}
1180-
}
1181-
catch (Exception ex)
1182-
{
1183-
try
1184-
{
1185-
if (!writeDone && File.Exists(backup))
1186-
{
1187-
try { File.Copy(backup, path, true); } catch { }
1188-
}
1189-
}
1190-
catch { }
1191-
throw new Exception($"Failed to write config file '{path}': {ex.Message}", ex);
1192-
}
1193-
finally
1194-
{
1195-
try { if (File.Exists(tmp)) File.Delete(tmp); } catch { }
1196-
try { if (writeDone && File.Exists(backup)) File.Delete(backup); } catch { }
1197-
}
1198-
}
1199-
12001144
private string WriteToConfig(string pythonDir, string configPath, McpClient mcpClient = null)
12011145
{
12021146
// 0) Respect explicit lock (hidden pref or UI toggle)

0 commit comments

Comments
 (0)