app: trim ChatGPT native integration changes

This commit is contained in:
Eva Ho
2026-09-03 20:07:37 -04:00
parent 58850d25de
commit 21f1c12080
3 changed files with 12 additions and 35 deletions
+1 -5
View File
@@ -1908,13 +1908,9 @@ func quitForHandoff() {
}
func quit() {
handoff := appHandoffInProgress.Load()
ctx, cancel := context.WithTimeout(context.Background(), claudeShutdownTimeout)
defer cancel()
// ChatGPT's loopback configuration is persistent. Leave it and the running
// app untouched so reopening Ollama resumes routing without another restart.
if err := restoreClaudeAppForTermination(ctx, handoff); err != nil {
if err := restoreClaudeAppForTermination(ctx, appHandoffInProgress.Load()); err != nil {
slog.Warn("failed to restore Claude before quitting", "error", err)
}
C.quit()
-1
View File
@@ -60,7 +60,6 @@ bool IsCodexDesktopConnected(void);
bool IsCodexDesktopRunning(void);
unsigned long long CodexDesktopRequestCount(void);
bool SetCodexDesktopConnected(bool connected, bool restartConfirmed);
bool OpenChatGPTDownloadPage(void);
bool ClaudeGatewayStartFailed(void);
bool ClaudeGatewayPortConflict(void);
char *ClaudeGatewayErrorMessage(void);
+11 -29
View File
@@ -901,7 +901,8 @@ static NSImage *ollamaApplicationIcon(void) {
[alert addButtonWithTitle:@"Open download page"];
[alert addButtonWithTitle:@"Cancel"];
if ([alert runModal] == NSAlertFirstButtonReturn) {
OpenChatGPTDownloadPage();
[[NSWorkspace sharedWorkspace]
openURL:[NSURL URLWithString:ChatGPTDownloadPageURL]];
}
}
@@ -917,7 +918,8 @@ static NSImage *ollamaApplicationIcon(void) {
[alert addButtonWithTitle:@"Open download page"];
[alert addButtonWithTitle:@"Cancel"];
if ([alert runModal] == NSAlertFirstButtonReturn) {
OpenChatGPTDownloadPage();
[[NSWorkspace sharedWorkspace]
openURL:[NSURL URLWithString:ChatGPTDownloadPageURL]];
}
}
@@ -1452,7 +1454,8 @@ didCompleteWithError:(NSError *)error {
}
self.quitInProgress = YES;
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
if (IsClaudeGatewayConfigured() && !RestoreClaudeGatewayForShutdown()) {
BOOL succeeded = RestoreClaudeGatewayForShutdown();
if (!succeeded) {
appLogInfo(@"Unable to restore Claude during system shutdown");
}
dispatch_async(dispatch_get_main_queue(), ^{
@@ -1527,16 +1530,12 @@ didCompleteWithError:(NSError *)error {
if (self.quitInProgress) {
return;
}
// ChatGPT remains configured across Ollama exits so reopening Ollama can
// resume routing without interrupting the app or resetting the toggle.
BOOL claudeConfigured = IsClaudeGatewayConfigured();
if (!claudeConfigured) {
if (!IsClaudeGatewayConfigured()) {
[self quit];
return;
}
BOOL restartClaude = claudeConfigured && IsClaudeDesktopRunning();
BOOL restartClaude = IsClaudeDesktopRunning();
if (restartClaude) {
NSAlert *alert = [[NSAlert alloc] init];
[alert setAlertStyle:NSAlertStyleWarning];
@@ -1553,22 +1552,21 @@ didCompleteWithError:(NSError *)error {
self.quitInProgress = YES;
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
BOOL claudeSucceeded = SetClaudeGatewayInstalled(false, restartClaude);
BOOL succeeded = SetClaudeGatewayInstalled(false, restartClaude);
dispatch_async(dispatch_get_main_queue(), ^{
if (self.systemTerminationReplyPending) {
if (!claudeSucceeded) {
if (!succeeded) {
appLogInfo(@"Unable to restore Claude during system shutdown");
}
[self completeSystemTermination];
return;
}
if (claudeSucceeded) {
if (succeeded) {
[self quit];
return;
}
self.quitInProgress = NO;
[self refreshCodexAppState];
[self refreshClaudeAppState];
NSAlert *alert = [[NSAlert alloc] init];
[alert setAlertStyle:NSAlertStyleWarning];
@@ -2347,22 +2345,6 @@ enum ClaudeInstallResult installCodexDesktop(void) {
return result;
}
bool OpenChatGPTDownloadPage(void) {
__block BOOL opened = NO;
void (^openPage)(void) = ^{
NSURL *url = [NSURL URLWithString:ChatGPTDownloadPageURL];
if (url != nil) {
opened = [[NSWorkspace sharedWorkspace] openURL:url];
}
};
if ([NSThread isMainThread]) {
openPage();
} else {
dispatch_sync(dispatch_get_main_queue(), openPage);
}
return opened;
}
void quit() {
dispatch_async(dispatch_get_main_queue(), ^{
[appDelegate quit];