chenhg5/cc-connect · warning

e.i18n.T(MsgDirNotSupported)

Error message

e.i18n.T(MsgDirNotSupported)

What it means

Returned when the /dir (working-directory) command is used with an agent that does not implement the optional WorkDirSwitcher capability interface. The engine checks capability with a type assertion and refuses rather than crashing.

Source

Thrown at core/engine.go:13340

	}

	return cb.Build(), nil
}

// dirCardTruncPath shortens absolute paths for card list rows.
func dirCardTruncPath(absPath string) string {
	r := []rune(absPath)
	if len(r) <= 56 {
		return absPath
	}
	return string(r[:53]) + "…"
}

func (e *Engine) renderDirCard(sessionKey string, page int) (*Card, error) {
	agent, _ := e.sessionContextForKey(sessionKey)
	switcher, ok := agent.(WorkDirSwitcher)
	if !ok {
		return nil, fmt.Errorf("%s", e.i18n.T(MsgDirNotSupported))
	}
	currentDir := switcher.GetWorkDir()
	var history []string
	if e.dirHistory != nil {
		history = e.dirHistory.List(e.name)
	}
	total := len(history)
	totalPages := 1
	if total > 0 {
		totalPages = (total + dirCardPageSize - 1) / dirCardPageSize
	}
	if page < 1 {
		page = 1
	}
	if page > totalPages {
		page = totalPages
	}
	start := (page - 1) * dirCardPageSize

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Switch to an agent that implements WorkDirSwitcher before using the dir command.
  2. Check capability first via `if sw, ok := agent.(WorkDirSwitcher); ok` in any custom command wiring.
  3. Hide or disable the /dir command in the UI/config for agents lacking the capability.

Example fix

// before
switcher, ok := agent.(WorkDirSwitcher)
if !ok { return nil, fmt.Errorf("%s", e.i18n.T(MsgDirNotSupported)) }
// after (caller-side pre-check)
if _, ok := agent.(WorkDirSwitcher); !ok {
    return e.simpleCard(e.i18n.T(MsgDirNotSupported), "orange", "") // graceful card instead of error
}
Defensive patterns

Strategy: type-guard

Validate before calling

_, supported := agent.(WorkDirSwitcher); if !supported { /* hide /dir command for this agent */ }

Type guard

if switcher, ok := agent.(WorkDirSwitcher); ok { dir = switcher.GetWorkDir() }

Try / catch

card, err := e.renderDirCard(key, page)
if err != nil && strings.Contains(err.Error(), e.i18n.T(MsgDirNotSupported)) {
    return e.simpleCard(e.i18n.T(MsgDirNotSupported), "orange", ""), nil // graceful fallback card
}

Prevention

When it happens

Trigger: Invoking the directory-switch command while the current agent (e.g. one lacking workdir support) fails the `agent.(WorkDirSwitcher)` assertion in renderDirCard.

Common situations: User switches to an agent that doesn't support changing working directories and then runs /dir; config assigns a minimal agent implementation to a session where dir features are expected.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/51246694b27ce9d5. Report an issue: GitHub.