@@ -14,6 +14,7 @@ import (
1414 "net/http"
1515 "os"
1616 "os/exec"
17+ "path/filepath"
1718 "runtime"
1819 "strings"
1920 "time"
@@ -66,6 +67,7 @@ type ServerInterface interface {
6667 // Config management for file watching
6768 ReloadConfiguration () error
6869 GetConfigPath () string
70+ GetLogDir () string
6971}
7072
7173// App represents the system tray application
@@ -321,7 +323,8 @@ func (a *App) onReady() {
321323
322324 // --- Other Menu Items ---
323325 updateItem := systray .AddMenuItem ("Check for Updates..." , "Check for a new version of the proxy" )
324- openConfigItem := systray .AddMenuItem ("Open Config" , "Open the configuration file" )
326+ openConfigItem := systray .AddMenuItem ("Open config dir" , "Open the configuration directory" )
327+ openLogsItem := systray .AddMenuItem ("Open logs dir" , "Open the logs directory" )
325328 systray .AddSeparator ()
326329
327330 // --- Autostart Menu Item (macOS only) ---
@@ -351,7 +354,9 @@ func (a *App) onReady() {
351354 case <- updateItem .ClickedCh :
352355 go a .checkForUpdates ()
353356 case <- openConfigItem .ClickedCh :
354- a .openConfig ()
357+ a .openConfigDir ()
358+ case <- openLogsItem .ClickedCh :
359+ a .openLogsDir ()
355360 case <- quitItem .ClickedCh :
356361 a .logger .Info ("Quit item clicked, shutting down" )
357362 if a .shutdown != nil {
@@ -927,28 +932,52 @@ func (a *App) applyTarGzUpdate(body io.Reader) error {
927932 return fmt .Errorf ("no mcpproxy binary found in tar.gz archive" )
928933}
929934
930- // openConfig opens the configuration file in the default editor
931- func (a * App ) openConfig () {
935+ // openConfigDir opens the directory containing the configuration file
936+ func (a * App ) openConfigDir () {
932937 if a .configPath == "" {
933938 a .logger .Warn ("Config path is not set, cannot open" )
934939 return
935940 }
936941
942+ configDir := filepath .Dir (a .configPath )
943+ a .openDirectory (configDir , "config directory" )
944+ }
945+
946+ // openLogsDir opens the logs directory
947+ func (a * App ) openLogsDir () {
948+ if a .server == nil {
949+ a .logger .Warn ("Server interface not available, cannot open logs directory" )
950+ return
951+ }
952+
953+ logDir := a .server .GetLogDir ()
954+ if logDir == "" {
955+ a .logger .Warn ("Log directory path is not set, cannot open" )
956+ return
957+ }
958+
959+ a .openDirectory (logDir , "logs directory" )
960+ }
961+
962+ // openDirectory opens a directory using the OS-specific file manager
963+ func (a * App ) openDirectory (dirPath , dirType string ) {
937964 var cmd * exec.Cmd
938965 switch runtime .GOOS {
939966 case "darwin" :
940- cmd = exec .Command ("open" , a . configPath )
967+ cmd = exec .Command ("open" , dirPath )
941968 case "linux" :
942- cmd = exec .Command ("xdg-open" , a . configPath )
969+ cmd = exec .Command ("xdg-open" , dirPath )
943970 case "windows" :
944- cmd = exec .Command ("cmd " , "/C" , "start" , a . configPath )
971+ cmd = exec .Command ("explorer " , dirPath )
945972 default :
946- a .logger .Warn ("Unsupported OS for opening config file " , zap .String ("os" , runtime .GOOS ))
973+ a .logger .Warn ("Unsupported OS for opening directory " , zap .String ("os" , runtime .GOOS ))
947974 return
948975 }
949976
950977 if err := cmd .Run (); err != nil {
951- a .logger .Error ("Failed to open config file" , zap .Error (err ))
978+ a .logger .Error ("Failed to open directory" , zap .Error (err ), zap .String ("dir_type" , dirType ), zap .String ("path" , dirPath ))
979+ } else {
980+ a .logger .Info ("Successfully opened directory" , zap .String ("dir_type" , dirType ), zap .String ("path" , dirPath ))
952981 }
953982}
954983
0 commit comments