MCPcopy Index your code
hub / github.com/coder/coder / extractMagicSessionType

Function extractMagicSessionType

agent/agentssh/agentssh.go:339–364  ·  view source on GitHub ↗
(env []string)

Source from the content-addressed store, hash-verified

337}
338
339func extractMagicSessionType(env []string) (magicType MagicSessionType, rawType string, filteredEnv []string) {
340 for _, kv := range env {
341 if !strings.HasPrefix(kv, MagicSessionTypeEnvironmentVariable) {
342 continue
343 }
344
345 rawType = strings.TrimPrefix(kv, MagicSessionTypeEnvironmentVariable+"=")
346 // Keep going, we'll use the last instance of the env.
347 }
348
349 // Always force lowercase checking to be case-insensitive.
350 switch MagicSessionType(strings.ToLower(rawType)) {
351 case MagicSessionTypeVSCode:
352 magicType = MagicSessionTypeVSCode
353 case MagicSessionTypeJetBrains:
354 magicType = MagicSessionTypeJetBrains
355 case "", MagicSessionTypeSSH:
356 magicType = MagicSessionTypeSSH
357 default:
358 magicType = MagicSessionTypeUnknown
359 }
360
361 return magicType, rawType, slices.DeleteFunc(env, func(kv string) bool {
362 return strings.HasPrefix(kv, MagicSessionTypeEnvironmentVariable+"=")
363 })
364}
365
366// sessionCloseTracker is a wrapper around Session that tracks the exit code.
367type sessionCloseTracker struct {

Callers 1

sessionHandlerMethod · 0.85

Calls 1

MagicSessionTypeTypeAlias · 0.85

Tested by

no test coverage detected