MCPcopy
hub / github.com/SurgeDM/Surge / InitialRootModel

Function InitialRootModel

internal/tui/model.go:263–515  ·  view source on GitHub ↗
(serverPort int, currentVersion string, service core.DownloadService, orchestrator *processing.LifecycleManager, noResume bool, currentCommit ...string)

Source from the content-addressed store, hash-verified

261}
262
263func InitialRootModel(serverPort int, currentVersion string, service core.DownloadService, orchestrator *processing.LifecycleManager, noResume bool, currentCommit ...string) RootModel {
264 initialDarkBackground := true
265 if !IsTestMode {
266 initialDarkBackground = lipgloss.HasDarkBackground(os.Stdin, os.Stdout)
267 }
268 commitValue := "unknown"
269 if len(currentCommit) > 0 {
270 if trimmed := strings.TrimSpace(currentCommit[0]); trimmed != "" {
271 commitValue = trimmed
272 }
273 }
274
275 // Initialize inputs
276 urlInput := textinput.New()
277 urlInput.Placeholder = "https://example.com/file.zip"
278 urlInput.Focus()
279 urlInput.SetWidth(InputWidth)
280 urlInput.Prompt = ""
281
282 pathInput := textinput.New()
283 pathInput.Placeholder = "."
284 pathInput.SetWidth(InputWidth)
285 pathInput.Prompt = ""
286 pathInput.SetValue(".")
287
288 filenameInput := textinput.New()
289 filenameInput.Placeholder = "(auto-detect)"
290 filenameInput.SetWidth(InputWidth)
291 filenameInput.Prompt = ""
292
293 mirrorsInput := textinput.New()
294 mirrorsInput.Placeholder = "http://mirror1.com, http://mirror2.com"
295 mirrorsInput.SetWidth(InputWidth)
296 mirrorsInput.Prompt = ""
297
298 pwd, _ := os.Getwd()
299
300 // Initialize file picker for directory selection - default to Downloads folder
301 homeDir, _ := os.UserHomeDir()
302 downloadsDir := filepath.Join(homeDir, "Downloads")
303 fp := filepicker.New()
304 fp.CurrentDirectory = downloadsDir
305 fp.DirAllowed = true
306 fp.FileAllowed = false
307 fp.ShowHidden = false
308 fp.ShowSize = true
309 fp.ShowPermissions = true
310 fp.SetHeight(FilePickerHeight)
311 applyFilepickerTheme(&fp)
312
313 // Load settings for auto resume
314 settings, errSettings := config.LoadSettings()
315 if settings == nil {
316 settings = config.DefaultSettings()
317 }
318 if errSettings != nil {
319 settings.StartupWarnings = append(settings.StartupWarnings, fmt.Sprintf("Failed to load settings: %v", errSettings))
320 }

Calls 15

refreshThemeCachesMethod · 0.95
LoadSettingsFunction · 0.92
DefaultSettingsFunction · 0.92
LoadKeyMapFunction · 0.92
DefaultKeyMapFunction · 0.92
GetKeyMapConfigPathFunction · 0.92
LightGrayFunction · 0.92
GrayFunction · 0.92
PinkFunction · 0.92
applyFilepickerThemeFunction · 0.85
applyColorModeForThemeFunction · 0.85
NewDownloadModelFunction · 0.85