app: remove Claude and ChatGPT switches from the macOS menu bar (#20015)

This commit is contained in:
Jeffrey Morgan authored and GitHub committed 2026-12-02 19:22:11 -08:00
1 parent 0f111826dd
commit bb0a02c280
14 files changed
+25 -982

No files matched your search

+5 -117
View File
@@ -612,12 +612,11 @@ func startClaudeAppProxy() error {
return recordClaudeProxyFailure(err, claudeProxyFailureNone)
}
gateway, err := proxy.NewClaudeDesktop(proxy.ClaudeDesktopConfig{
ListenAddr: claudeProxyListenAddr,
OllamaURL: ollamaURL.String(),
Model: activeModels[0].OllamaModel,
Models: activeModels,
Logger: slog.Default(),
OnCountsChanged: updateClaudeProxyMenu,
ListenAddr: claudeProxyListenAddr,
OllamaURL: ollamaURL.String(),
Model: activeModels[0].OllamaModel,
Models: activeModels,
Logger: slog.Default(),
RefreshModels: func(ctx context.Context, current []proxy.ClaudeDesktopModel) ([]proxy.ClaudeDesktopModel, error) {
_, selected, _ := refreshClaudeDesktopCatalog(ctx, current, false)
return selected, nil
@@ -1122,19 +1121,6 @@ func claudeGatewayPort() (string, error) {
return port, nil
}
//export ClaudeGatewayPort
func ClaudeGatewayPort() C.int {
portText, err := claudeGatewayPort()
if err != nil {
return 0
}
port, err := strconv.Atoi(portText)
if err != nil {
return 0
}
return C.int(port)
}
// These helpers require claudeProxyMu to be held.
func setClaudeProxyFailure(err error, failure claudeProxyFailure) error {
claudeProxyErr = err
@@ -1164,11 +1150,6 @@ func SetClaudeGatewayInstalled(installed C.bool, restartClaude C.bool) C.bool {
return C._Bool(true)
}
//export HasUsedClaudeDesktopIntegration
func HasUsedClaudeDesktopIntegration() C.bool {
return C._Bool(hasUsedClaudeDesktopIntegration())
}
func hasUsedClaudeDesktopIntegration() bool {
if appStore == nil {
return false
@@ -1233,86 +1214,16 @@ func setClaudeGatewayInstalled(installed, restart bool) error {
return nil
}
//export IsClaudeDesktopInstalled
func IsClaudeDesktopInstalled() C.bool {
return C._Bool(claudeDesktopInstalled())
}
//export IsClaudeDesktopRunning
func IsClaudeDesktopRunning() C.bool {
return C._Bool(launch.ClaudeDesktopRunning())
}
//export IsCodexDesktopInstalled
func IsCodexDesktopInstalled() C.bool {
return C._Bool(codexDesktop.Installed())
}
//export IsCodexDesktopConnected
func IsCodexDesktopConnected() C.bool {
return C._Bool(codexDesktop.OllamaConfigured())
}
//export IsCodexDesktopDisconnectPending
func IsCodexDesktopDisconnectPending() C.bool {
return C._Bool(!codexDesktop.OllamaConfigured() && codexDesktop.RestorePending())
}
//export IsCodexDesktopRunning
func IsCodexDesktopRunning() C.bool {
return C._Bool(codexDesktop.Running())
}
//export CodexDesktopRequestCount
func CodexDesktopRequestCount() C.ulonglong {
return C.ulonglong(codexDesktop.OllamaRequestCount())
}
//export SetCodexDesktopConnected
func SetCodexDesktopConnected(connected, restartConfirmed C.bool) C.bool {
shouldConnect := connected != C._Bool(false)
confirmed := restartConfirmed != C._Bool(false)
result := changeCodexDesktopConnection(shouldConnect, confirmed)
return C._Bool(result.Error == "")
}
//export IsClaudeGatewayConfigured
func IsClaudeGatewayConfigured() C.bool {
return C._Bool(claudeDesktop.UsesOllamaGateway())
}
//export ClaudeGatewayStartFailed
func ClaudeGatewayStartFailed() C.bool {
return C._Bool(claudeGatewayStartFailed())
}
func claudeGatewayStartFailed() bool {
claudeProxyMu.Lock()
defer claudeProxyMu.Unlock()
return claudeProxyErr != nil
}
//export ClaudeGatewayPortConflict
func ClaudeGatewayPortConflict() C.bool {
return C._Bool(claudeGatewayPortConflict())
}
//export ClaudeGatewayErrorMessage
func ClaudeGatewayErrorMessage() *C.char {
claudeProxyMu.Lock()
defer claudeProxyMu.Unlock()
if claudeProxyErr == nil {
return C.CString("")
}
return C.CString(claudeProxyErr.Error())
}
func claudeGatewayPortConflict() bool {
claudeProxyMu.Lock()
defer claudeProxyMu.Unlock()
return claudeProxyFail == claudeProxyFailurePortConflict
}
func getClaudeDesktopConnectionSummary() claudeDesktopStatus {
return claudeDesktopConnectionSummary(hasUsedClaudeDesktopIntegration())
}
@@ -1855,14 +1766,6 @@ func InstallCodexDesktopDiskImage(path *C.cchar_t) C.bool {
return C._Bool(true)
}
func getShowAppsInMenu() bool {
return bool(C.ShowAppsInMenu())
}
func setShowAppsInMenu(visible bool) {
C.SetShowAppsInMenu(C._Bool(visible))
}
func claudeDesktopInstallResultFromCode(code int) claudeDesktopInstallResult {
switch code {
case int(C.ClaudeInstallerOpened):
@@ -1874,21 +1777,6 @@ func claudeDesktopInstallResultFromCode(code int) claudeDesktopInstallResult {
}
}
//export RefreshClaudeProxyMenu
func RefreshClaudeProxyMenu() {
claudeProxyMu.Lock()
proxy := claudeAppProxy
claudeProxyMu.Unlock()
if proxy == nil {
return
}
updateClaudeProxyMenu(proxy.Counts())
}
func updateClaudeProxyMenu(counts proxy.ClaudeDesktopCounts) {
C.updateClaudeProxyMenu(C.ulonglong(counts.Routed))
}
func stopClaudeAppProxy() {
claudeProxyStartMu.Lock()
defer claudeProxyStartMu.Unlock()
-16
View File
@@ -50,25 +50,9 @@ void drag(uintptr_t wndPtr);
void doubleClick(uintptr_t wndPtr);
void handleConnectURL();
bool SetClaudeGatewayInstalled(bool installed, bool restartClaude);
bool HasUsedClaudeDesktopIntegration(void);
bool RestoreClaudeGatewayForShutdown(void);
bool IsClaudeGatewayConfigured(void);
bool IsClaudeDesktopInstalled(void);
bool IsClaudeDesktopRunning(void);
bool IsCodexDesktopInstalled(void);
bool IsCodexDesktopConnected(void);
bool IsCodexDesktopDisconnectPending(void);
bool IsCodexDesktopRunning(void);
unsigned long long CodexDesktopRequestCount(void);
bool SetCodexDesktopConnected(bool connected, bool restartConfirmed);
bool ClaudeGatewayStartFailed(void);
bool ClaudeGatewayPortConflict(void);
char *ClaudeGatewayErrorMessage(void);
int ClaudeGatewayPort(void);
void RefreshClaudeProxyMenu(void);
void updateClaudeProxyMenu(unsigned long long routed);
bool ShowAppsInMenu(void);
void SetShowAppsInMenu(bool visible);
enum ClaudeInstallResult
{
ClaudeInstallCancelled,
+1 -697
View File
@@ -19,8 +19,6 @@ static NSString *const ClaudeDownloadPageURL = @"https://claude.com/download";
static NSString *const ChatGPTDownloadPageURL = @"https://chatgpt.com/download";
static NSString *const ChatGPTDiskImageURL =
@"https://persistent.oaistatic.com/codex-app-prod/Codex.dmg";
static NSString *const ShowAppsInMenuDefaultsKey = @"ShowAppsInMenu";
static NSBundle *OllamaResourceBundle(void);
typedef NS_ENUM(NSInteger, DesktopDownloadKind) {
DesktopDownloadNone,
@@ -56,318 +54,12 @@ static void configureChatGPTRestartAlert(NSAlert *alert,
[alert addButtonWithTitle:@"Restart ChatGPT"];
}
static BOOL shouldShowAppsInMenu(void) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:ShowAppsInMenuDefaultsKey] == nil) {
return YES;
}
return [defaults boolForKey:ShowAppsInMenuDefaultsKey];
}
static NSImage *integrationAppIcon(NSString *appName,
NSString *fallbackSymbolName) {
NSArray<NSString *> *candidates = @[
[NSString stringWithFormat:@"/Applications/%@.app", appName],
[NSHomeDirectory() stringByAppendingPathComponent:
[NSString stringWithFormat:@"Applications/%@.app", appName]],
];
for (NSString *path in candidates) {
if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
continue;
}
NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:path];
if (icon != nil) {
[icon setTemplate:NO];
return icon;
}
}
NSBundle *bundle = OllamaResourceBundle();
NSImage *bundledIcon = [bundle imageForResource:appName.lowercaseString];
if (bundledIcon != nil) {
[bundledIcon setTemplate:[appName isEqualToString:@"ChatGPT"]];
return bundledIcon;
}
return [NSImage imageWithSystemSymbolName:fallbackSymbolName
accessibilityDescription:nil];
}
@interface MenuSwitch : NSButton
@end
@implementation MenuSwitch
- (instancetype)initWithFrame:(NSRect)frameRect {
self = [super initWithFrame:frameRect];
if (self) {
[self setButtonType:NSButtonTypeToggle];
[self setBordered:NO];
[self setTitle:@""];
[self setFocusRingType:NSFocusRingTypeNone];
[self setAccessibilityRole:NSAccessibilityCheckBoxRole];
}
return self;
}
- (NSSize)intrinsicContentSize {
return NSMakeSize(30, 18);
}
- (void)setState:(NSControlStateValue)state {
[super setState:state];
[self setNeedsDisplay:YES];
}
- (void)setEnabled:(BOOL)enabled {
[super setEnabled:enabled];
[self setNeedsDisplay:YES];
}
- (void)drawRect:(NSRect)dirtyRect {
(void)dirtyRect;
NSRect track = NSInsetRect(self.bounds, 0, 1);
NSColor *trackColor = self.state == NSControlStateValueOn
? [NSColor systemBlueColor]
: [NSColor colorWithWhite:0.55 alpha:1];
if (!self.enabled) {
trackColor = [trackColor colorWithAlphaComponent:0.45];
}
[trackColor setFill];
[[NSBezierPath bezierPathWithRoundedRect:track
xRadius:NSHeight(track) / 2
yRadius:NSHeight(track) / 2] fill];
CGFloat knobSize = NSHeight(track) - 4;
CGFloat knobX = self.state == NSControlStateValueOn
? NSMaxX(track) - knobSize - 2
: NSMinX(track) + 2;
NSRect knob = NSMakeRect(knobX,
NSMidY(track) - knobSize / 2,
knobSize,
knobSize);
[[NSColor whiteColor] setFill];
[[NSBezierPath bezierPathWithOvalInRect:knob] fill];
}
@end
@interface IntegrationMenuRow : NSButton
@property(strong, nonatomic) NSView *controlSurface;
@property(strong, nonatomic) NSButton *openButton;
@property(strong, nonatomic) NSTextField *integrationTitleLabel;
@property(strong, nonatomic) NSTextField *integrationStatusLabel;
@property(strong, nonatomic) MenuSwitch *integrationSwitch;
@property(strong, nonatomic) NSLayoutConstraint *titleWithStatusConstraint;
@property(strong, nonatomic) NSLayoutConstraint *titleCenteredConstraint;
@property(strong, nonatomic) NSTrackingArea *hoverTrackingArea;
@property(assign, nonatomic) BOOL pointerInside;
@property(assign, nonatomic) SEL integrationOpenAction;
@property(copy, nonatomic) NSString *activeStatusText;
@property(copy, nonatomic) NSString *inactiveStatusText;
- (instancetype)initWithTitle:(NSString *)title
symbolName:(NSString *)symbolName
target:(id)target
openAction:(SEL)openAction
toggleAction:(SEL)toggleAction;
- (void)setIntegrationActive:(BOOL)active;
- (void)setIntegrationReady:(BOOL)ready;
- (void)setActiveStatusText:(NSString *)status;
- (void)setInactiveStatusText:(NSString *)status;
- (void)resetHover;
@end
@implementation IntegrationMenuRow
- (instancetype)initWithTitle:(NSString *)title
symbolName:(NSString *)symbolName
target:(id)target
openAction:(SEL)openAction
toggleAction:(SEL)toggleAction {
self = [super initWithFrame:NSMakeRect(0, 0, 310, 50)];
if (self) {
[self setButtonType:NSButtonTypeMomentaryChange];
[self setBordered:NO];
[self setTitle:@""];
[self setFocusRingType:NSFocusRingTypeNone];
[self setTarget:target];
[self setAction:openAction];
self.integrationOpenAction = openAction;
[self setAccessibilityLabel:[NSString stringWithFormat:@"Open %@", title]];
[self setAccessibilityRole:NSAccessibilityButtonRole];
self.controlSurface = [[NSView alloc] initWithFrame:NSZeroRect];
[self.controlSurface setWantsLayer:YES];
self.controlSurface.layer.cornerRadius = 13;
[self.controlSurface setTranslatesAutoresizingMaskIntoConstraints:NO];
NSImage *icon = integrationAppIcon(title, symbolName);
self.openButton = [NSButton buttonWithImage:icon
target:target
action:openAction];
[self.openButton setBordered:NO];
[self.openButton setImagePosition:NSImageOnly];
[self.openButton setImageScaling:NSImageScaleProportionallyDown];
[self.openButton setFocusRingType:NSFocusRingTypeNone];
[self.openButton setAccessibilityLabel:[NSString stringWithFormat:@"Open %@", title]];
[self.openButton setTranslatesAutoresizingMaskIntoConstraints:NO];
self.integrationTitleLabel = [NSTextField labelWithString:title];
[self.integrationTitleLabel setFont:[NSFont systemFontOfSize:13 weight:NSFontWeightSemibold]];
[self.integrationTitleLabel setLineBreakMode:NSLineBreakByTruncatingTail];
[self.integrationTitleLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
self.integrationStatusLabel = [NSTextField labelWithString:@""];
[self.integrationStatusLabel setFont:[NSFont systemFontOfSize:11.5]];
[self.integrationStatusLabel setLineBreakMode:NSLineBreakByTruncatingTail];
[self.integrationStatusLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
self.integrationSwitch = [[MenuSwitch alloc] initWithFrame:NSZeroRect];
[self.integrationSwitch setTarget:target];
[self.integrationSwitch setAction:toggleAction];
[self.integrationSwitch setAccessibilityLabel:[NSString stringWithFormat:@"Use Ollama with %@", title]];
[self.integrationSwitch setTranslatesAutoresizingMaskIntoConstraints:NO];
[self addSubview:self.controlSurface];
[self addSubview:self.openButton];
[self addSubview:self.integrationTitleLabel];
[self addSubview:self.integrationStatusLabel];
[self addSubview:self.integrationSwitch];
self.titleWithStatusConstraint =
[self.integrationTitleLabel.bottomAnchor
constraintEqualToAnchor:self.controlSurface.centerYAnchor
constant:-1];
self.titleCenteredConstraint =
[self.integrationTitleLabel.centerYAnchor
constraintEqualToAnchor:self.controlSurface.centerYAnchor];
[NSLayoutConstraint activateConstraints:@[
[self.controlSurface.leadingAnchor constraintEqualToAnchor:self.leadingAnchor constant:7],
[self.controlSurface.trailingAnchor constraintEqualToAnchor:self.trailingAnchor constant:-7],
[self.controlSurface.topAnchor constraintEqualToAnchor:self.topAnchor constant:3],
[self.controlSurface.bottomAnchor constraintEqualToAnchor:self.bottomAnchor constant:-3],
[self.openButton.leadingAnchor constraintEqualToAnchor:self.controlSurface.leadingAnchor constant:9],
[self.openButton.centerYAnchor constraintEqualToAnchor:self.controlSurface.centerYAnchor],
[self.openButton.widthAnchor constraintEqualToConstant:34],
[self.openButton.heightAnchor constraintEqualToConstant:34],
[self.integrationTitleLabel.leadingAnchor constraintEqualToAnchor:self.openButton.trailingAnchor constant:10],
self.titleWithStatusConstraint,
[self.integrationTitleLabel.trailingAnchor constraintLessThanOrEqualToAnchor:self.integrationSwitch.leadingAnchor constant:-12],
[self.integrationStatusLabel.leadingAnchor constraintEqualToAnchor:self.integrationTitleLabel.leadingAnchor],
[self.integrationStatusLabel.topAnchor constraintEqualToAnchor:self.controlSurface.centerYAnchor constant:1],
[self.integrationStatusLabel.trailingAnchor constraintLessThanOrEqualToAnchor:self.integrationSwitch.leadingAnchor constant:-12],
[self.integrationSwitch.trailingAnchor constraintEqualToAnchor:self.controlSurface.trailingAnchor constant:-12],
[self.integrationSwitch.centerYAnchor constraintEqualToAnchor:self.controlSurface.centerYAnchor],
]];
[self setIntegrationActive:NO];
}
return self;
}
- (NSView *)hitTest:(NSPoint)point {
if (!NSPointInRect(point, self.bounds)) {
return nil;
}
if (NSPointInRect(point, self.integrationSwitch.frame)) {
return self.integrationSwitch;
}
if (NSPointInRect(point, self.openButton.frame)) {
return self.openButton;
}
return self;
}
- (void)updateTrackingAreas {
[super updateTrackingAreas];
if (self.hoverTrackingArea != nil) {
[self removeTrackingArea:self.hoverTrackingArea];
}
self.hoverTrackingArea = [[NSTrackingArea alloc]
initWithRect:NSZeroRect
options:NSTrackingMouseEnteredAndExited |
NSTrackingActiveAlways |
NSTrackingInVisibleRect
owner:self
userInfo:nil];
[self addTrackingArea:self.hoverTrackingArea];
}
- (void)mouseEntered:(NSEvent *)event {
(void)event;
self.pointerInside = YES;
[self updateAppearance];
}
- (void)mouseExited:(NSEvent *)event {
(void)event;
self.pointerInside = NO;
[self updateAppearance];
}
- (void)resetHover {
self.pointerInside = NO;
[self updateAppearance];
}
- (void)viewDidChangeEffectiveAppearance {
[super viewDidChangeEffectiveAppearance];
[self updateAppearance];
}
- (void)updateAppearance {
BOOL active = self.integrationSwitch.state == NSControlStateValueOn;
BOOL hovered = self.pointerInside && self.enabled;
NSColor *surfaceColor = hovered
? [[NSColor labelColor] colorWithAlphaComponent:0.08]
: [NSColor clearColor];
self.controlSurface.layer.backgroundColor = surfaceColor.CGColor;
self.integrationTitleLabel.textColor = [NSColor labelColor];
NSString *status = active ? (self.activeStatusText ?: @"Using Ollama")
: (self.inactiveStatusText ?: @"Use Ollama models");
BOOL hasStatus = status.length > 0;
self.titleWithStatusConstraint.active = hasStatus;
self.titleCenteredConstraint.active = !hasStatus;
self.integrationStatusLabel.hidden = !hasStatus;
self.integrationStatusLabel.stringValue = status;
self.integrationStatusLabel.textColor = [NSColor secondaryLabelColor];
[self setAccessibilityValue:status];
}
- (void)setIntegrationActive:(BOOL)active {
self.integrationSwitch.state = active ? NSControlStateValueOn
: NSControlStateValueOff;
[self setIntegrationReady:active];
[self updateAppearance];
}
- (void)setIntegrationReady:(BOOL)ready {
self.action = ready ? self.integrationOpenAction : nil;
self.openButton.enabled = ready;
self.openButton.alphaValue = ready ? 1.0 : 0.45;
}
- (void)setActiveStatusText:(NSString *)status {
_activeStatusText = [status copy];
[self updateAppearance];
}
- (void)setInactiveStatusText:(NSString *)status {
_inactiveStatusText = [status copy];
[self updateAppearance];
}
@end
@interface AppDelegate () <NSWindowDelegate, WKNavigationDelegate, WKUIDelegate, NSMenuDelegate, NSURLSessionDownloadDelegate>
@interface AppDelegate () <NSWindowDelegate, WKNavigationDelegate, WKUIDelegate, NSURLSessionDownloadDelegate>
@property(strong, nonatomic) NSStatusItem *statusItem;
@property(assign, nonatomic) BOOL updateAvailable;
@property(assign, nonatomic) BOOL systemShutdownInProgress;
@property(strong, nonatomic) NSMenuItem *updateAvailableMenuItem;
@property(strong, nonatomic) NSMenuItem *restartMenuItem;
@property(assign, nonatomic) BOOL claudeAppEnabled;
@property(assign, nonatomic) BOOL claudeAppReady;
@property(strong, nonatomic) IntegrationMenuRow *claudeAppRow;
@property(strong, nonatomic) NSMenuItem *claudeMenuItem;
@property(strong, nonatomic) IntegrationMenuRow *codexAppRow;
@property(strong, nonatomic) NSMenuItem *codexMenuItem;
@property(strong, nonatomic) NSMenuItem *claudeMenuSeparatorItem;
@property(strong, nonatomic) NSURLSession *claudeDownloadSession;
@property(strong, nonatomic) NSURLSessionDownloadTask *claudeDownloadTask;
@property(strong, nonatomic) NSAlert *claudeDownloadAlert;
@@ -381,8 +73,6 @@ static NSImage *integrationAppIcon(NSString *appName,
@property(assign, nonatomic) BOOL quitInProgress;
@property(assign, nonatomic) BOOL systemTerminationReplyPending;
@property(strong, nonatomic) NSApplication *systemTerminationApplication;
- (void)openClaudeApp:(id)sender;
- (void)openChatGPTApp:(id)sender;
- (enum ClaudeInstallResult)downloadClaude;
- (enum ClaudeInstallResult)downloadChatGPT;
- (enum ClaudeInstallResult)downloadDesktopApp:(DesktopDownloadKind)kind;
@@ -391,11 +81,6 @@ static NSImage *integrationAppIcon(NSString *appName,
- (void)showClaudeInstallFailure:(NSError *)error;
- (void)showChatGPTDownloadFailure:(NSError *)error;
- (void)showChatGPTInstallFailure:(NSError *)error;
- (void)toggleClaudeAppProxy:(NSButton *)sender;
- (void)refreshClaudeAppState;
- (void)toggleCodexApp:(NSButton *)sender;
- (void)refreshCodexAppState;
- (void)applyShowAppsInMenu:(BOOL)visible;
- (void)requestQuit;
- (void)completeSystemTermination;
@end
@@ -471,41 +156,8 @@ static NSImage *ollamaApplicationIcon(void) {
// Create status item and menu
NSMenu *menu = [[NSMenu alloc] init];
[menu setDelegate:self];
[menu setAutoenablesItems:NO];
self.claudeMenuItem = [[NSMenuItem alloc] initWithTitle:@"Claude"
action:nil
keyEquivalent:@""];
[self.claudeMenuItem setEnabled:YES];
self.claudeAppRow = [[IntegrationMenuRow alloc]
initWithTitle:@"Claude"
symbolName:@"sparkles"
target:self
openAction:@selector(openClaudeApp:)
toggleAction:@selector(toggleClaudeAppProxy:)];
[self.claudeMenuItem setView:self.claudeAppRow];
[menu addItem:self.claudeMenuItem];
[self refreshClaudeAppState];
self.codexMenuItem = [[NSMenuItem alloc] initWithTitle:@"ChatGPT"
action:nil
keyEquivalent:@""];
[self.codexMenuItem setEnabled:YES];
self.codexAppRow = [[IntegrationMenuRow alloc]
initWithTitle:@"ChatGPT"
symbolName:@"bubble.left.and.bubble.right"
target:self
openAction:@selector(openChatGPTApp:)
toggleAction:@selector(toggleCodexApp:)];
[self.codexMenuItem setView:self.codexAppRow];
[menu addItem:self.codexMenuItem];
[self refreshCodexAppState];
self.claudeMenuSeparatorItem = [NSMenuItem separatorItem];
[menu addItem:self.claudeMenuSeparatorItem];
[self applyShowAppsInMenu:shouldShowAppsInMenu()];
NSMenuItem *appsMenuItem =
[[NSMenuItem alloc] initWithTitle:@"Open Ollama"
action:@selector(appsUI)
@@ -684,72 +336,6 @@ static NSImage *ollamaApplicationIcon(void) {
return YES;
}
- (void)menuWillOpen:(NSMenu *)menu {
if (menu != self.statusItem.menu) {
return;
}
[self refreshClaudeAppState];
[self refreshCodexAppState];
}
- (void)refreshClaudeAppState {
BOOL installed = IsClaudeDesktopInstalled();
BOOL startFailed = ClaudeGatewayStartFailed();
BOOL portConflict = startFailed && ClaudeGatewayPortConflict();
BOOL configured = installed && IsClaudeGatewayConfigured();
NSString *failureStatus = portConflict
? [NSString stringWithFormat:@"Port %d is in use", ClaudeGatewayPort()]
: (startFailed ? @"Unable to use Ollama" : nil);
self.claudeAppEnabled = configured;
self.claudeAppReady = configured && !startFailed;
[self.claudeAppRow setActiveStatusText:configured ? failureStatus : nil];
[self.claudeAppRow setInactiveStatusText:configured
? nil
: (!installed ? @"Not installed" : failureStatus)];
[self.claudeAppRow setIntegrationActive:self.claudeAppEnabled];
[self.claudeAppRow setIntegrationReady:self.claudeAppReady];
RefreshClaudeProxyMenu();
[self applyShowAppsInMenu:shouldShowAppsInMenu()];
}
- (void)refreshCodexAppState {
BOOL installed = IsCodexDesktopInstalled();
BOOL connected = IsCodexDesktopConnected();
BOOL disconnectPending = IsCodexDesktopDisconnectPending();
unsigned long long requests = connected ? CodexDesktopRequestCount() : 0;
NSString *activeStatus = requests == 1
? @"1 request this session"
: [NSString stringWithFormat:@"%llu requests this session", requests];
[self.codexAppRow setActiveStatusText:connected
? activeStatus
: nil];
[self.codexAppRow setInactiveStatusText:disconnectPending
? @"Try disconnecting again"
: (installed ? @"Use Ollama models in ChatGPT" : @"Not installed")];
[self.codexAppRow.integrationSwitch setAccessibilityLabel:disconnectPending
? @"Retry disconnecting ChatGPT"
: @"Use Ollama with ChatGPT"];
[self.codexAppRow setIntegrationActive:connected];
[self.codexAppRow setIntegrationReady:installed && connected];
[self applyShowAppsInMenu:shouldShowAppsInMenu()];
}
- (void)applyShowAppsInMenu:(BOOL)visible {
BOOL claudeVisible = visible && HasUsedClaudeDesktopIntegration();
// Keep the installation flow accessible from the menu.
BOOL codexVisible = visible;
[self.claudeMenuItem setHidden:!claudeVisible];
[self.codexMenuItem setHidden:!codexVisible];
[self.claudeMenuSeparatorItem setHidden:!(claudeVisible || codexVisible)];
}
- (void)menuDidClose:(NSMenu *)menu {
if (menu == self.statusItem.menu) {
[self.claudeAppRow resetHover];
[self.codexAppRow resetHover];
}
}
- (void)showUpdateAvailable {
self.updateAvailable = YES;
[self refreshStatusItem];
@@ -773,89 +359,6 @@ static NSImage *ollamaApplicationIcon(void) {
[self uiRequest:@"/"];
}
- (void)openClaudeApp:(id)sender {
(void)sender;
if (!self.claudeAppReady) {
return;
}
[self.statusItem.menu cancelTracking];
NSArray<NSString *> *candidates = @[
@"/Applications/Claude.app",
[NSHomeDirectory() stringByAppendingPathComponent:@"Applications/Claude.app"],
];
for (NSString *path in candidates) {
if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
continue;
}
NSWorkspaceOpenConfiguration *configuration =
[NSWorkspaceOpenConfiguration configuration];
configuration.activates = YES;
configuration.createsNewApplicationInstance = NO;
[[NSWorkspace sharedWorkspace]
openApplicationAtURL:[NSURL fileURLWithPath:path]
configuration:configuration
completionHandler:^(NSRunningApplication *application,
NSError *error) {
(void)application;
if (error != nil) {
appLogInfo([NSString stringWithFormat:
@"Unable to open Claude: %@", error]);
}
}];
return;
}
NSAlert *alert = [[NSAlert alloc] init];
[alert setAlertStyle:NSAlertStyleWarning];
[alert setMessageText:@"Unable to open Claude"];
[alert setInformativeText:@"Install Claude in Applications, then try again."];
[alert runModal];
}
- (void)openChatGPTApp:(id)sender {
(void)sender;
if (!IsCodexDesktopConnected()) {
return;
}
[self.statusItem.menu cancelTracking];
NSArray<NSString *> *candidates = @[
@"/Applications/ChatGPT.app",
[NSHomeDirectory() stringByAppendingPathComponent:@"Applications/ChatGPT.app"],
@"/Applications/Codex.app",
[NSHomeDirectory() stringByAppendingPathComponent:@"Applications/Codex.app"],
];
for (NSString *path in candidates) {
if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
continue;
}
NSWorkspaceOpenConfiguration *configuration =
[NSWorkspaceOpenConfiguration configuration];
configuration.activates = YES;
configuration.createsNewApplicationInstance = NO;
[[NSWorkspace sharedWorkspace]
openApplicationAtURL:[NSURL fileURLWithPath:path]
configuration:configuration
completionHandler:^(NSRunningApplication *application,
NSError *error) {
(void)application;
if (error != nil) {
appLogInfo([NSString stringWithFormat:
@"Unable to open ChatGPT: %@", error]);
}
}];
return;
}
NSAlert *alert = [[NSAlert alloc] init];
[alert setAlertStyle:NSAlertStyleWarning];
[alert setMessageText:@"Unable to open ChatGPT"];
[alert setInformativeText:
@"Install ChatGPT in Applications, then try again."];
[alert runModal];
}
- (void)showClaudeDownloadFailure:(NSError *)error {
appLogInfo([NSString stringWithFormat:@"Unable to download Claude: %@",
error]);
@@ -972,11 +475,7 @@ static NSImage *ollamaApplicationIcon(void) {
return ClaudeInstallFailed;
}
IntegrationMenuRow *row = chatGPT ? self.codexAppRow : self.claudeAppRow;
NSString *appName = chatGPT ? @"ChatGPT" : @"Claude";
[row setInactiveStatusText:
[NSString stringWithFormat:@"Downloading %@…", appName]];
[row.integrationSwitch setEnabled:NO];
self.claudeDownloadAlert = [[NSAlert alloc] init];
[self.claudeDownloadAlert setAlertStyle:NSAlertStyleInformational];
@@ -1149,13 +648,10 @@ didCompleteWithError:(NSError *)error {
- (enum ClaudeInstallResult)finishDesktopDownload {
BOOL cancelled = self.claudeDownloadCancelled;
BOOL chatGPT = self.desktopDownloadKind == DesktopDownloadChatGPT;
IntegrationMenuRow *row = chatGPT ? self.codexAppRow : self.claudeAppRow;
NSString *appName = chatGPT ? @"ChatGPT" : @"Claude";
[self.claudeDownloadProgress stopAnimation:nil];
[self.claudeDownloadAlert.window orderOut:nil];
[row.integrationSwitch setEnabled:YES];
[row setInactiveStatusText:@"Not installed"];
[self.claudeDownloadSession finishTasksAndInvalidate];
self.claudeDownloadTask = nil;
self.claudeDownloadSession = nil;
@@ -1193,11 +689,8 @@ didCompleteWithError:(NSError *)error {
self.desktopDownloadKind = DesktopDownloadNone;
return ClaudeInstallFailed;
}
[row setInactiveStatusText:
[NSString stringWithFormat:@"Installing %@…", appName]];
BOOL installed = NO;
if (chatGPT) {
[row.integrationSwitch setEnabled:NO];
NSAlert *installAlert = [[NSAlert alloc] init];
[installAlert setAlertStyle:NSAlertStyleInformational];
[installAlert setIcon:ollamaApplicationIcon()];
@@ -1230,7 +723,6 @@ didCompleteWithError:(NSError *)error {
installed = backgroundInstalled;
[installProgress stopAnimation:nil];
[installAlert.window orderOut:nil];
[row.integrationSwitch setEnabled:YES];
} else {
installed = InstallClaudeDesktopArchive(
self.claudeDownloadedInstallerURL.fileSystemRepresentation);
@@ -1263,169 +755,9 @@ didCompleteWithError:(NSError *)error {
self.claudeDownloadCancelled = NO;
self.claudeDownloadCompleted = NO;
self.desktopDownloadKind = DesktopDownloadNone;
if (chatGPT) {
[self refreshCodexAppState];
} else {
[self refreshClaudeAppState];
}
return installed ? ClaudeInstallerOpened : ClaudeInstallFailed;
}
- (void)toggleClaudeAppProxy:(NSButton *)sender {
BOOL enabled = sender.state == NSControlStateValueOn;
if (enabled && !IsClaudeDesktopInstalled()) {
[self.claudeAppRow setInactiveStatusText:@"Not installed"];
[self.claudeAppRow setIntegrationActive:NO];
NSAlert *installAlert = [[NSAlert alloc] init];
[installAlert setAlertStyle:NSAlertStyleInformational];
[installAlert setIcon:ollamaApplicationIcon()];
[installAlert setMessageText:@"Claude is not installed"];
[installAlert setInformativeText:
@"Download Claude to add Ollama models to the Claude app."];
[installAlert addButtonWithTitle:@"Download Claude"];
[installAlert addButtonWithTitle:@"Cancel"];
if ([installAlert runModal] == NSAlertFirstButtonReturn) {
if ([self downloadClaude] != ClaudeInstallerOpened) {
return;
}
} else {
return;
}
}
BOOL restartClaude = IsClaudeDesktopRunning();
if (restartClaude) {
NSAlert *restartAlert = [[NSAlert alloc] init];
[restartAlert setAlertStyle:NSAlertStyleWarning];
[restartAlert setIcon:ollamaApplicationIcon()];
[restartAlert setMessageText:enabled
? @"Restart Claude Desktop to use Ollama?"
: @"Restart Claude Desktop to remove Ollama?"];
[restartAlert setInformativeText:enabled
? @"Claude Desktop must restart to use Ollama. Any running task will stop."
: @"Claude Desktop must restart to remove Ollama. Any running task will stop."];
[restartAlert addButtonWithTitle:@"Restart Claude Desktop"];
[restartAlert addButtonWithTitle:@"Cancel"];
if ([restartAlert runModal] != NSAlertFirstButtonReturn) {
[self refreshClaudeAppState];
return;
}
}
[sender setEnabled:NO];
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
BOOL succeeded = SetClaudeGatewayInstalled(enabled, restartClaude);
dispatch_async(dispatch_get_main_queue(), ^{
[sender setEnabled:YES];
if (!succeeded) {
BOOL portConflict = enabled && ClaudeGatewayPortConflict();
char *rawGatewayError = ClaudeGatewayErrorMessage();
NSString *gatewayError = rawGatewayError != NULL && rawGatewayError[0] != '\0'
? [NSString stringWithUTF8String:rawGatewayError]
: nil;
free(rawGatewayError);
[self refreshClaudeAppState];
NSAlert *alert = [[NSAlert alloc] init];
[alert setAlertStyle:NSAlertStyleWarning];
[alert setIcon:ollamaApplicationIcon()];
[alert setMessageText:portConflict
? [NSString stringWithFormat:@"Port %d is already in use", ClaudeGatewayPort()]
: (enabled
? @"Unable to use Ollama with Claude"
: @"Unable to remove Ollama from Claude")];
[alert setInformativeText:portConflict
? [NSString stringWithFormat:@"Change OLLAMA_HOST or quit the app using port %d, then try again.", ClaudeGatewayPort()]
: (gatewayError.length > 0
? gatewayError
: @"Ollama could not update Claude. Check the Ollama log for details.")];
[alert runModal];
return;
}
self.claudeAppEnabled = enabled;
self.claudeAppReady = enabled;
[self.claudeAppRow setActiveStatusText:nil];
[self.claudeAppRow setInactiveStatusText:nil];
[self.claudeAppRow setIntegrationActive:enabled];
[self.claudeAppRow setIntegrationReady:enabled];
if (enabled) {
RefreshClaudeProxyMenu();
[self openClaudeApp:nil];
}
});
});
}
- (void)toggleCodexApp:(NSButton *)sender {
BOOL disconnectPending = IsCodexDesktopDisconnectPending();
BOOL enabled = sender.state == NSControlStateValueOn && !disconnectPending;
if (disconnectPending) {
sender.state = NSControlStateValueOff;
}
if (enabled && !IsCodexDesktopInstalled()) {
[self refreshCodexAppState];
NSAlert *installAlert = [[NSAlert alloc] init];
[installAlert setAlertStyle:NSAlertStyleInformational];
[installAlert setIcon:ollamaApplicationIcon()];
[installAlert setMessageText:@"ChatGPT is not installed"];
[installAlert setInformativeText:
@"Download ChatGPT to add Ollama models to the ChatGPT app."];
[installAlert addButtonWithTitle:@"Download ChatGPT"];
[installAlert addButtonWithTitle:@"Cancel"];
if ([installAlert runModal] == NSAlertFirstButtonReturn) {
if ([self downloadChatGPT] != ClaudeInstallerOpened) {
return;
}
} else {
return;
}
}
BOOL restartChatGPT = IsCodexDesktopRunning();
if (restartChatGPT) {
NSAlert *restartAlert = [[NSAlert alloc] init];
[restartAlert setAlertStyle:NSAlertStyleWarning];
[restartAlert setIcon:ollamaApplicationIcon()];
configureChatGPTRestartAlert(restartAlert, enabled
? ChatGPTRestartActionAddModels
: ChatGPTRestartActionRemoveModels);
[restartAlert addButtonWithTitle:@"Cancel"];
if ([restartAlert runModal] != NSAlertFirstButtonReturn) {
[self refreshCodexAppState];
return;
}
}
[sender setEnabled:NO];
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
BOOL succeeded = SetCodexDesktopConnected(enabled, restartChatGPT);
dispatch_async(dispatch_get_main_queue(), ^{
[sender setEnabled:YES];
[self refreshCodexAppState];
if (!succeeded) {
NSAlert *alert = [[NSAlert alloc] init];
[alert setAlertStyle:NSAlertStyleWarning];
[alert setIcon:ollamaApplicationIcon()];
[alert setMessageText:enabled
? @"Couldn’t connect ChatGPT"
: @"Couldn’t disconnect ChatGPT"];
[alert setInformativeText:@"Please try again."];
if (!enabled && (IsCodexDesktopConnected() || IsCodexDesktopDisconnectPending())) {
[alert addButtonWithTitle:@"Retry"];
[alert addButtonWithTitle:@"Not Now"];
if ([alert runModal] == NSAlertFirstButtonReturn) {
sender.state = NSControlStateValueOff;
[self toggleCodexApp:sender];
}
return;
}
[alert runModal];
return;
}
});
});
}
- (void)appsUI {
[self uiRequest:@"/connect"];
}
@@ -1584,7 +916,6 @@ didCompleteWithError:(NSError *)error {
}
self.quitInProgress = NO;
[self refreshClaudeAppState];
NSAlert *alert = [[NSAlert alloc] init];
[alert setAlertStyle:NSAlertStyleWarning];
[alert setIcon:ollamaApplicationIcon()];
@@ -2306,33 +1637,6 @@ void updateAvailable() {
});
}
void updateClaudeProxyMenu(unsigned long long routed) {
void (^updateMenu)(void) = ^{
NSString *status = routed == 1
? @"1 request this session"
: [NSString stringWithFormat:@"%llu requests this session", routed];
[appDelegate.claudeAppRow setActiveStatusText:status];
};
if ([NSThread isMainThread]) {
updateMenu();
} else {
dispatch_async(dispatch_get_main_queue(), updateMenu);
}
}
bool ShowAppsInMenu(void) {
return shouldShowAppsInMenu();
}
void SetShowAppsInMenu(bool visible) {
[[NSUserDefaults standardUserDefaults]
setBool:visible
forKey:ShowAppsInMenuDefaultsKey];
dispatch_async(dispatch_get_main_queue(), ^{
[appDelegate applyShowAppsInMenu:visible];
});
}
enum ClaudeInstallResult installClaudeDesktop(void) {
__block enum ClaudeInstallResult result = ClaudeInstallFailed;
void (^install)(void) = ^{
+12 -20
View File
@@ -3121,11 +3121,9 @@ func TestClaudeGatewayRejectsOllamaHostPortConflict(t *testing.T) {
if claudeAppProxy != nil {
t.Fatal("Claude gateway started with a conflicting OLLAMA_HOST")
}
if !claudeGatewayStartFailed() {
t.Fatal("expected the port conflict to remain visible to the menu")
}
if !claudeGatewayPortConflict() {
t.Fatal("expected the menu failure to be classified as a port conflict")
status := getClaudeDesktopConnectionSummary()
if !status.StartFailed || !status.PortConflict {
t.Fatalf("Claude status = %+v, want a failed start with a port conflict", status)
}
}
@@ -3140,8 +3138,8 @@ func TestClaudeGatewayPortTracksListenAddress(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if port != "23001" || int(ClaudeGatewayPort()) != 23001 {
t.Fatalf("Claude gateway port = %q/%d, want 23001", port, int(ClaudeGatewayPort()))
if reported := getClaudeDesktopConnectionSummary().GatewayPort; port != "23001" || reported != 23001 {
t.Fatalf("Claude gateway port = %q/%d, want 23001", port, reported)
}
}
@@ -3164,7 +3162,7 @@ func TestClaudeGatewayDoesNotReportPortConflictWithoutClaude(t *testing.T) {
if err := startClaudeAppProxy(); err != nil {
t.Fatalf("startClaudeAppProxy error = %v, want absent Claude to skip the gateway", err)
}
if claudeGatewayStartFailed() || claudeGatewayPortConflict() {
if status := getClaudeDesktopConnectionSummary(); status.StartFailed || status.PortConflict {
t.Fatal("absent Claude exposed a gateway port conflict")
}
}
@@ -3189,22 +3187,16 @@ func TestClaudeGatewayRecoversAfterPortConflict(t *testing.T) {
if err := startClaudeAppProxy(); err == nil {
t.Fatal("startClaudeAppProxy succeeded while another service owned the port")
}
if !claudeGatewayStartFailed() {
t.Fatal("expected the failed start to remain visible to the menu")
}
if !claudeGatewayPortConflict() {
t.Fatal("expected an occupied gateway port to be classified as a conflict")
if status := getClaudeDesktopConnectionSummary(); !status.StartFailed || !status.PortConflict {
t.Fatalf("Claude status = %+v, want a failed start with a port conflict", status)
}
conflict.Close()
if err := startClaudeAppProxy(); err != nil {
t.Fatalf("startClaudeAppProxy did not recover after the port was released: %v", err)
}
if claudeGatewayStartFailed() {
t.Fatal("expected a successful retry to clear the menu failure state")
}
if claudeGatewayPortConflict() {
t.Fatal("expected a successful retry to clear the port conflict state")
if status := getClaudeDesktopConnectionSummary(); status.StartFailed || status.PortConflict {
t.Fatalf("Claude status = %+v, want a successful retry to clear the failure", status)
}
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
@@ -3236,7 +3228,7 @@ func TestClaudeGatewayRejectsSpoofedExistingGateway(t *testing.T) {
if err := startClaudeAppProxy(); err == nil {
t.Fatal("startClaudeAppProxy trusted a listener with a spoofed health response")
}
if claudeAppProxy != nil || !claudeGatewayPortConflict() {
if claudeAppProxy != nil || !getClaudeDesktopConnectionSummary().PortConflict {
t.Fatal("spoofed listener was not reported as a port conflict")
}
}
@@ -3267,7 +3259,7 @@ func TestClaudeGatewayWaitsForPreviousListenerToExit(t *testing.T) {
if err := startClaudeAppProxy(); err != nil {
t.Fatalf("startClaudeAppProxy did not acquire a released handoff port: %v", err)
}
if claudeGatewayStartFailed() || claudeAppProxy == nil {
if getClaudeDesktopConnectionSummary().StartFailed || claudeAppProxy == nil {
t.Fatal("released handoff port did not start the Claude gateway")
}
}
@@ -84,12 +84,4 @@ func bindClaudeDesktop(wv webview.WebView) {
}
return result
})
wv.Bind("getShowAppsInMenu", func() bool {
return getShowAppsInMenu()
})
wv.Bind("setShowAppsInMenu", func(visible bool) {
setShowAppsInMenu(visible)
})
}
@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 320"><path d="m297.06 130.97c7.26-21.79 4.76-45.66-6.85-65.48-17.46-30.4-52.56-46.04-86.84-38.68-15.25-17.18-37.16-26.95-60.13-26.81-35.04-.08-66.13 22.48-76.91 55.82-22.51 4.61-41.94 18.7-53.31 38.67-17.59 30.32-13.58 68.54 9.92 94.54-7.26 21.79-4.76 45.66 6.85 65.48 17.46 30.4 52.56 46.04 86.84 38.68 15.24 17.18 37.16 26.95 60.13 26.8 35.06.09 66.16-22.49 76.94-55.86 22.51-4.61 41.94-18.7 53.31-38.67 17.57-30.32 13.55-68.51-9.94-94.51zm-120.28 168.11c-14.03.02-27.62-4.89-38.39-13.88.49-.26 1.34-.73 1.89-1.07l63.72-36.8c3.26-1.85 5.26-5.32 5.24-9.07v-89.83l26.93 15.55c.29.14.48.42.52.74v74.39c-.04 33.08-26.83 59.9-59.91 59.97zm-128.84-55.03c-7.03-12.14-9.56-26.37-7.15-40.18.47.28 1.3.79 1.89 1.13l63.72 36.8c3.23 1.89 7.23 1.89 10.47 0l77.79-44.92v31.1c.02.32-.13.63-.38.83l-64.41 37.19c-28.69 16.52-65.33 6.7-81.92-21.95zm-16.77-139.09c7-12.16 18.05-21.46 31.21-26.29 0 .55-.03 1.52-.03 2.2v73.61c-.02 3.74 1.98 7.21 5.23 9.06l77.79 44.91-26.93 15.55c-.27.18-.61.21-.91.08l-64.42-37.22c-28.63-16.58-38.45-53.21-21.95-81.89zm221.26 51.49-77.79-44.92 26.93-15.54c.27-.18.61-.21.91-.08l64.42 37.19c28.68 16.57 38.51 53.26 21.94 81.94-7.01 12.14-18.05 21.44-31.2 26.28v-75.81c.03-3.74-1.96-7.2-5.2-9.06zm26.8-40.34c-.47-.29-1.3-.79-1.89-1.13l-63.72-36.8c-3.23-1.89-7.23-1.89-10.47 0l-77.79 44.92v-31.1c-.02-.32.13-.63.38-.83l64.41-37.16c28.69-16.55 65.37-6.7 81.91 22 6.99 12.12 9.52 26.31 7.15 40.1zm-168.51 55.43-26.94-15.55c-.29-.14-.48-.42-.52-.74v-74.39c.02-33.12 26.89-59.96 60.01-59.94 14.01 0 27.57 4.92 38.34 13.88-.49.26-1.33.73-1.89 1.07l-63.72 36.8c-3.26 1.85-5.26 5.31-5.24 9.06l-.04 89.79zm14.63-31.54 34.65-20.01 34.65 20v40.01l-34.65 20-34.65-20z"/></svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated by Pixelmator Pro 3.6.17 -->
<svg width="1200" height="1200" viewBox="0 0 1200 1200" xmlns="http://www.w3.org/2000/svg">
<g id="g314">
<path id="path147" fill="#d97757" stroke="none" d="M 233.959793 800.214905 L 468.644287 668.536987 L 472.590637 657.100647 L 468.644287 650.738403 L 457.208069 650.738403 L 417.986633 648.322144 L 283.892639 644.69812 L 167.597321 639.865845 L 54.926208 633.825623 L 26.577238 627.785339 L 3.3e-05 592.751709 L 2.73832 575.27533 L 26.577238 559.248352 L 60.724873 562.228149 L 136.187973 567.382629 L 249.422867 575.194763 L 331.570496 580.026978 L 453.261841 592.671082 L 472.590637 592.671082 L 475.328857 584.859009 L 468.724915 580.026978 L 463.570557 575.194763 L 346.389313 495.785217 L 219.543671 411.865906 L 153.100723 363.543762 L 117.181267 339.060425 L 99.060455 316.107361 L 91.248367 266.01355 L 123.865784 230.093994 L 167.677887 233.073853 L 178.872513 236.053772 L 223.248367 270.201477 L 318.040283 343.570496 L 441.825592 434.738342 L 459.946411 449.798706 L 467.194672 444.64447 L 468.080597 441.020203 L 459.946411 427.409485 L 392.617493 305.718323 L 320.778564 181.932983 L 288.80542 130.630859 L 280.348999 99.865845 C 277.369171 87.221436 275.194641 76.590698 275.194641 63.624268 L 312.322174 13.20813 L 332.8591 6.604126 L 382.389313 13.20813 L 403.248352 31.328979 L 434.013519 101.71814 L 483.865753 212.537048 L 561.181274 363.221497 L 583.812134 407.919434 L 595.892639 449.315491 L 600.40271 461.959839 L 608.214783 461.959839 L 608.214783 454.711609 L 614.577271 369.825623 L 626.335632 265.61084 L 637.771851 131.516846 L 641.718201 93.745117 L 660.402832 48.483276 L 697.530334 24.000122 L 726.52356 37.852417 L 750.362549 72 L 747.060486 94.067139 L 732.886047 186.201416 L 705.100708 330.52356 L 686.979919 427.167847 L 697.530334 427.167847 L 709.61084 415.087341 L 758.496704 350.174561 L 840.644348 247.490051 L 876.885925 206.738342 L 919.167847 161.71814 L 946.308838 140.29541 L 997.61084 140.29541 L 1035.38269 196.429626 L 1018.469849 254.416199 L 965.637634 321.422852 L 921.825562 378.201538 L 859.006714 462.765259 L 819.785278 530.41626 L 823.409424 535.812073 L 832.75177 534.92627 L 974.657776 504.724915 L 1051.328979 490.872559 L 1142.818848 475.167786 L 1184.214844 494.496582 L 1188.724854 514.147644 L 1172.456421 554.335693 L 1074.604126 578.496765 L 959.838989 601.449829 L 788.939636 641.879272 L 786.845764 643.409485 L 789.261841 646.389343 L 866.255127 653.637634 L 899.194702 655.409424 L 979.812134 655.409424 L 1129.932861 666.604187 L 1169.154419 692.537109 L 1192.671265 724.268677 L 1188.724854 748.429688 L 1128.322144 779.194641 L 1046.818848 759.865845 L 856.590759 714.604126 L 791.355774 698.335754 L 782.335693 698.335754 L 782.335693 703.731567 L 836.69812 756.885986 L 936.322205 846.845581 L 1061.073975 962.81897 L 1067.436279 991.490112 L 1051.409424 1014.120911 L 1034.496704 1011.704712 L 924.885986 929.234924 L 882.604126 892.107544 L 786.845764 811.48999 L 780.483276 811.48999 L 780.483276 819.946289 L 802.550415 852.241699 L 919.087341 1027.409424 L 925.127625 1081.127686 L 916.671204 1098.604126 L 886.469849 1109.154419 L 853.288696 1103.114136 L 785.073914 1007.355835 L 714.684631 899.516785 L 657.906067 802.872498 L 650.979858 806.81897 L 617.476624 1167.704834 L 601.771851 1186.147705 L 565.530212 1200 L 535.328857 1177.046997 L 519.302124 1139.919556 L 535.328857 1066.550537 L 554.657776 970.792053 L 570.362488 894.68457 L 584.536926 800.134277 L 592.993347 768.724976 L 592.429626 766.630859 L 585.503479 767.516968 L 514.22821 865.369263 L 405.825531 1011.865906 L 320.053711 1103.677979 L 299.516815 1111.812256 L 263.919525 1093.369263 L 267.221497 1060.429688 L 287.114136 1031.114136 L 405.825531 880.107361 L 477.422913 786.52356 L 523.651062 732.483276 L 523.328918 724.671265 L 520.590698 724.671265 L 205.288605 929.395935 L 149.154434 936.644409 L 124.993355 914.01355 L 127.973183 876.885986 L 139.409409 864.80542 L 234.201385 799.570435 L 233.879227 799.8927 Z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 4.0 KiB

@@ -112,7 +112,7 @@ describe("Onboarding", () => {
expect(authenticationTimeoutAction(true, true)).toBe("ignore");
});
it("detects when the menu bar already reached the requested Claude state", () => {
it("detects when Claude already matches the requested connection state", () => {
const status = {
supported: true,
installed: true,
+2 -3
View File
@@ -866,9 +866,8 @@ export function ConnectAppsScreen({
}
setClaudeStatus(status);
// The menu-bar control may have reached this target since the app last
// refreshed. Sync the row without repeating the profile change or
// restarting Claude, while preserving first-use completion behavior.
// Claude's profile can change between refreshes. If it already matches
// the requested state, finish the UI flow without restarting Claude.
if (isClaudeConnectionComplete(enabling, status)) {
claudeRestartConfirmed.current = false;
const completionError = enabling
@@ -10,7 +10,6 @@ const mocks = vi.hoisted(() => ({
resetChatGPTModels: vi.fn(),
updateSettings: vi.fn(),
updateCloudSetting: vi.fn(),
setShowAppsInMenu: vi.fn(),
refetchUser: vi.fn(),
disconnectUser: vi.fn(),
isWindows: false,
@@ -169,7 +168,6 @@ describe("Settings reset interactions", () => {
disabled: false,
source: "none",
});
mocks.setShowAppsInMenu.mockResolvedValue(undefined);
mocks.resetChatGPTModels.mockResolvedValue(true);
mocks.disconnectUser.mockResolvedValue(undefined);
@@ -178,8 +176,6 @@ describe("Settings reset interactions", () => {
removeEventListener: vi.fn(),
setTimeout: globalThis.setTimeout.bind(globalThis),
clearTimeout: globalThis.clearTimeout.bind(globalThis),
getShowAppsInMenu: vi.fn().mockResolvedValue(true),
setShowAppsInMenu: mocks.setShowAppsInMenu,
open: vi.fn(),
confirm: vi.fn(() => true),
location: { reload: vi.fn() },
+3 -33
View File
@@ -22,7 +22,6 @@ describe("Settings defaults", () => {
const settingsUpdate = deferred();
const updateSettings = vi.fn(() => settingsUpdate.promise);
const updateCloud = vi.fn().mockResolvedValue(undefined);
const updateShowAppsInMenu = vi.fn().mockResolvedValue(undefined);
const resetChatGPTModels = vi.fn().mockResolvedValue(true);
let resolveClaudeReset!: (succeeded: boolean) => void;
const claudeReset = new Promise<boolean>((resolve) => {
@@ -34,21 +33,18 @@ describe("Settings defaults", () => {
const reset = applySettingsDefaults({
updateSettings,
updateCloud,
updateShowAppsInMenu,
resetChatGPTModels,
resetClaudeMappings,
currentSettings: currentSettings({
Expose: true,
Models: "/custom/models",
}),
currentShowAppsInMenu: false,
cloudSource: "config",
onSaved,
});
await vi.waitFor(() => expect(updateSettings).toHaveBeenCalledOnce());
expect(updateCloud).toHaveBeenCalledWith(true);
expect(updateShowAppsInMenu).not.toHaveBeenCalled();
expect(resetChatGPTModels).not.toHaveBeenCalled();
expect(resetClaudeMappings).not.toHaveBeenCalled();
expect(onSaved).not.toHaveBeenCalled();
@@ -62,7 +58,6 @@ describe("Settings defaults", () => {
expect(onSaved).not.toHaveBeenCalled();
settingsUpdate.resolve();
await vi.waitFor(() => expect(resetClaudeMappings).toHaveBeenCalledOnce());
expect(updateShowAppsInMenu).toHaveBeenCalledWith(true);
expect(resetChatGPTModels).toHaveBeenCalledOnce();
expect(onSaved).not.toHaveBeenCalled();
@@ -74,9 +69,6 @@ describe("Settings defaults", () => {
updateSettings.mock.invocationCallOrder[0],
);
expect(updateSettings.mock.invocationCallOrder[0]).toBeLessThan(
updateShowAppsInMenu.mock.invocationCallOrder[0],
);
expect(updateShowAppsInMenu.mock.invocationCallOrder[0]).toBeLessThan(
resetChatGPTModels.mock.invocationCallOrder[0],
);
expect(resetChatGPTModels.mock.invocationCallOrder[0]).toBeLessThan(
@@ -89,22 +81,18 @@ describe("Settings defaults", () => {
it("preserves an environment-only Cloud override", async () => {
const updateCloud = vi.fn().mockResolvedValue(undefined);
const updateShowAppsInMenu = vi.fn().mockResolvedValue(undefined);
await applySettingsDefaults({
updateSettings: vi.fn().mockResolvedValue(undefined),
updateCloud,
updateShowAppsInMenu,
resetChatGPTModels: vi.fn().mockResolvedValue(true),
resetClaudeMappings: vi.fn().mockResolvedValue(true),
currentSettings: currentSettings(),
currentShowAppsInMenu: true,
cloudSource: "env",
onSaved: vi.fn(),
});
expect(updateCloud).not.toHaveBeenCalled();
expect(updateShowAppsInMenu).toHaveBeenCalledWith(true);
});
it("clears the persisted Cloud override when the source is both", async () => {
@@ -117,11 +105,9 @@ describe("Settings defaults", () => {
await applySettingsDefaults({
updateSettings: vi.fn().mockResolvedValue(undefined),
updateCloud,
updateShowAppsInMenu: vi.fn().mockResolvedValue(undefined),
resetChatGPTModels: vi.fn().mockResolvedValue(true),
resetClaudeMappings: vi.fn().mockResolvedValue(true),
currentSettings: currentSettings(),
currentShowAppsInMenu: true,
cloudSource: "both",
onSaved: vi.fn(),
});
@@ -139,11 +125,9 @@ describe("Settings defaults", () => {
await applySettingsDefaults({
updateSettings: vi.fn().mockResolvedValue(undefined),
updateCloud,
updateShowAppsInMenu: vi.fn().mockResolvedValue(undefined),
resetChatGPTModels: vi.fn().mockResolvedValue(true),
resetClaudeMappings: vi.fn().mockResolvedValue(true),
currentSettings: currentSettings(),
currentShowAppsInMenu: true,
cloudSource: "none",
onSaved: vi.fn(),
});
@@ -153,7 +137,6 @@ describe("Settings defaults", () => {
it("restores Cloud and leaves Claude untouched when settings fail", async () => {
const updateCloud = vi.fn().mockResolvedValue(undefined);
const updateShowAppsInMenu = vi.fn().mockResolvedValue(undefined);
const resetChatGPTModels = vi.fn().mockResolvedValue(true);
const resetClaudeMappings = vi.fn().mockResolvedValue(true);
const onSaved = vi.fn();
@@ -162,14 +145,12 @@ describe("Settings defaults", () => {
applySettingsDefaults({
updateSettings: vi.fn().mockRejectedValue(new Error("restart failed")),
updateCloud,
updateShowAppsInMenu,
resetChatGPTModels,
resetClaudeMappings,
currentSettings: currentSettings({
Expose: true,
Models: "/custom/models",
}),
currentShowAppsInMenu: false,
cloudSource: "config",
onSaved,
}),
@@ -178,29 +159,26 @@ describe("Settings defaults", () => {
expect(updateCloud.mock.calls).toEqual([[true], [false]]);
expect(resetChatGPTModels).not.toHaveBeenCalled();
expect(resetClaudeMappings).not.toHaveBeenCalled();
expect(updateShowAppsInMenu).not.toHaveBeenCalled();
expect(onSaved).not.toHaveBeenCalled();
});
it("does not continue when the Cloud reset fails", async () => {
const updateShowAppsInMenu = vi.fn().mockResolvedValue(undefined);
const updateSettings = vi.fn().mockResolvedValue(undefined);
const onSaved = vi.fn();
await expect(
applySettingsDefaults({
updateSettings: vi.fn().mockResolvedValue(undefined),
updateSettings,
updateCloud: vi.fn().mockRejectedValue(new Error("cloud failed")),
updateShowAppsInMenu,
resetChatGPTModels: vi.fn().mockResolvedValue(true),
resetClaudeMappings: vi.fn().mockResolvedValue(true),
currentSettings: currentSettings(),
currentShowAppsInMenu: true,
cloudSource: "config",
onSaved,
}),
).rejects.toThrow("cloud failed");
expect(updateShowAppsInMenu).not.toHaveBeenCalled();
expect(updateSettings).not.toHaveBeenCalled();
expect(onSaved).not.toHaveBeenCalled();
});
@@ -208,7 +186,6 @@ describe("Settings defaults", () => {
const onSaved = vi.fn();
const updateSettings = vi.fn().mockResolvedValue(undefined);
const updateCloud = vi.fn().mockResolvedValue(undefined);
const updateShowAppsInMenu = vi.fn().mockResolvedValue(undefined);
const previousSettings = currentSettings({
Expose: true,
Models: "/custom/models",
@@ -218,11 +195,9 @@ describe("Settings defaults", () => {
applySettingsDefaults({
updateSettings,
updateCloud,
updateShowAppsInMenu,
resetChatGPTModels: vi.fn().mockResolvedValue(true),
resetClaudeMappings: vi.fn().mockResolvedValue(false),
currentSettings: previousSettings,
currentShowAppsInMenu: false,
cloudSource: "config",
onSaved,
}),
@@ -231,7 +206,6 @@ describe("Settings defaults", () => {
expect(updateCloud.mock.calls).toEqual([[true], [false]]);
expect(updateSettings).toHaveBeenCalledTimes(2);
expect(updateSettings.mock.calls[1][0]).toBe(previousSettings);
expect(updateShowAppsInMenu.mock.calls).toEqual([[true], [false]]);
expect(onSaved).not.toHaveBeenCalled();
});
@@ -239,7 +213,6 @@ describe("Settings defaults", () => {
const onSaved = vi.fn();
const updateSettings = vi.fn().mockResolvedValue(undefined);
const updateCloud = vi.fn().mockResolvedValue(undefined);
const updateShowAppsInMenu = vi.fn().mockResolvedValue(undefined);
const resetClaudeMappings = vi.fn().mockResolvedValue(true);
const previousSettings = currentSettings({ Expose: true });
@@ -247,11 +220,9 @@ describe("Settings defaults", () => {
applySettingsDefaults({
updateSettings,
updateCloud,
updateShowAppsInMenu,
resetChatGPTModels: vi.fn().mockResolvedValue(false),
resetClaudeMappings,
currentSettings: previousSettings,
currentShowAppsInMenu: false,
cloudSource: "config",
onSaved,
}),
@@ -260,7 +231,6 @@ describe("Settings defaults", () => {
expect(resetClaudeMappings).not.toHaveBeenCalled();
expect(updateCloud.mock.calls).toEqual([[true], [false]]);
expect(updateSettings.mock.calls[1][0]).toBe(previousSettings);
expect(updateShowAppsInMenu.mock.calls).toEqual([[true], [false]]);
expect(onSaved).not.toHaveBeenCalled();
});
});
-66
View File
@@ -23,7 +23,6 @@ import {
CogIcon,
ArrowDownTrayIcon,
ArrowPathIcon,
Squares2X2Icon,
} from "@heroicons/react/20/solid";
import { Settings as SettingsType } from "@/gotypes";
import { isWindowsPlatform } from "@/lib/platform";
@@ -59,11 +58,9 @@ function AnimatedDots() {
interface SettingsDefaultsActions {
updateSettings: (settings: SettingsType) => Promise<unknown>;
updateCloud: (enabled: boolean) => Promise<unknown>;
updateShowAppsInMenu: (visible: boolean) => Promise<unknown>;
resetChatGPTModels: () => Promise<boolean>;
resetClaudeMappings: () => Promise<boolean>;
currentSettings: SettingsType;
currentShowAppsInMenu: boolean;
cloudSource: CloudStatusSource;
onSaved: () => void;
}
@@ -79,11 +76,9 @@ const savedConfirmationDuration = 3000;
export async function applySettingsDefaults({
updateSettings,
updateCloud,
updateShowAppsInMenu,
resetChatGPTModels,
resetClaudeMappings,
currentSettings,
currentShowAppsInMenu,
cloudSource,
onSaved,
}: SettingsDefaultsActions): Promise<void> {
@@ -109,9 +104,6 @@ export async function applySettingsDefaults({
);
rollbacks.push(() => updateSettings(currentSettings));
await updateShowAppsInMenu(true);
rollbacks.push(() => updateShowAppsInMenu(currentShowAppsInMenu));
// Reset app-specific model settings only after the rest of the page has
// succeeded, because those native profile changes cannot be rolled back
// with the settings API.
@@ -143,8 +135,6 @@ export default function Settings() {
const queryClient = useQueryClient();
const [showSaved, setShowSaved] = useState(false);
const [restartMessage, setRestartMessage] = useState(false);
const [showAppsInMenu, setShowAppsInMenuState] = useState(true);
const [showAppsInMenuPending, setShowAppsInMenuPending] = useState(false);
const [resettingToDefaults, setResettingToDefaults] = useState(false);
const [resetError, setResetError] = useState<string | null>(null);
const [hasClaudeDraftChanges, setHasClaudeDraftChanges] = useState(false);
@@ -278,15 +268,6 @@ export default function Settings() {
return updateCloudMutation.mutateAsync({ enabled, requestId });
};
useEffect(() => {
window
.getShowAppsInMenu?.()
.then(setShowAppsInMenuState)
.catch((error) =>
console.error("Failed to load menu app visibility:", error),
);
}, []);
useEffect(() => {
const handleFocus = () => {
if (isAwaitingConnection && pollingInterval) {
@@ -354,28 +335,6 @@ export default function Settings() {
[settings, showSavedConfirmation, updateSettingsMutation],
);
const updateShowAppsInMenuVisibility = async (checked: boolean) => {
const previous = showAppsInMenu;
setShowAppsInMenuState(checked);
setShowAppsInMenuPending(true);
try {
await window.setShowAppsInMenu?.(checked);
} catch (error) {
setShowAppsInMenuState(previous);
throw error;
} finally {
setShowAppsInMenuPending(false);
}
};
const handleShowAppsInMenu = (checked: boolean) => {
void updateShowAppsInMenuVisibility(checked)
.then(showSavedConfirmation)
.catch((error) =>
console.error("Failed to update menu app visibility:", error),
);
};
const handleCloudUpdate = (enabled: boolean) => {
void requestCloudUpdate(enabled)
.then(showSavedConfirmation)
@@ -405,13 +364,11 @@ export default function Settings() {
updateSettings: (defaultSettings) =>
updateSettingsMutation.mutateAsync(defaultSettings),
updateCloud: requestCloudUpdate,
updateShowAppsInMenu: updateShowAppsInMenuVisibility,
resetChatGPTModels: async () =>
(await codexModelsSettingsRef.current?.resetToDefaults()) ?? true,
resetClaudeMappings: async () =>
(await claudeModelsSettingsRef.current?.resetToDefaults()) ?? true,
currentSettings: settings,
currentShowAppsInMenu: showAppsInMenu,
cloudSource,
onSaved: showSavedConfirmation,
});
@@ -629,29 +586,6 @@ export default function Settings() {
</div>
</Field>
{!isWindows && (
<Field>
<div className="flex items-start justify-between gap-4">
<div className="flex flex-1 items-start space-x-3">
<Squares2X2Icon className="mt-1 h-5 w-5 flex-shrink-0 text-black dark:text-neutral-100" />
<div>
<Label>Show apps in menu</Label>
<Description>
Show connected apps at the top of the Ollama menu.
</Description>
</div>
</div>
<div className="flex-shrink-0">
<Switch
checked={showAppsInMenu}
disabled={showAppsInMenuPending}
onChange={handleShowAppsInMenu}
/>
</div>
</div>
</Field>
)}
{/* Auto Update */}
<Field>
<div className="flex items-start justify-between gap-4">
-2
View File
@@ -153,8 +153,6 @@ declare global {
) => Promise<CodexDesktopModelsSettingsResult>;
resetCodexDesktopModels?: () => Promise<CodexDesktopModelsSettingsResult>;
installClaudeDesktop?: () => Promise<ClaudeDesktopInstallResult>;
getShowAppsInMenu?: () => Promise<boolean>;
setShowAppsInMenu?: (visible: boolean) => Promise<void>;
applyClaudeDesktopMappings?: (
mappings: Record<string, string>,
restartConfirmed: boolean,
+1 -7
View File
@@ -53,7 +53,6 @@ type ClaudeDesktopConfig struct {
Model string
Models []ClaudeDesktopModel
Logger *slog.Logger
OnCountsChanged func(ClaudeDesktopCounts)
RefreshModels func(context.Context, []ClaudeDesktopModel) ([]ClaudeDesktopModel, error)
ResolveAccessState func(context.Context) (ClaudeDesktopAccessState, error)
ListLocalModels func(context.Context) ([]string, error)
@@ -82,7 +81,6 @@ type ClaudeDesktop struct {
modelsMu sync.RWMutex
models []ClaudeDesktopModel
modelsGeneration uint64
onCountsChanged func(ClaudeDesktopCounts)
refreshModels func(context.Context, []ClaudeDesktopModel) ([]ClaudeDesktopModel, error)
resolveAccessState func(context.Context) (ClaudeDesktopAccessState, error)
listLocalModels func(context.Context) ([]string, error)
@@ -135,7 +133,6 @@ func NewClaudeDesktop(config ClaudeDesktopConfig) (*ClaudeDesktop, error) {
model: config.Model,
models: SelectClaudeDesktopModels(config.Models, nil),
modelsGeneration: 1,
onCountsChanged: config.OnCountsChanged,
refreshModels: config.RefreshModels,
resolveAccessState: config.ResolveAccessState,
listLocalModels: config.ListLocalModels,
@@ -373,10 +370,7 @@ func (p *ClaudeDesktop) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Ollama gateway unavailable", http.StatusBadGateway)
return
}
counts := ClaudeDesktopCounts{Routed: p.routed.Add(1)}
if p.onCountsChanged != nil {
p.onCountsChanged(counts)
}
p.routed.Add(1)
p.ollamaProxy.ServeHTTP(w, r)
}