feat(v0.6): platform-override stderr warning on launch paths
Closes the half-feature surfaced during Phase 1 review: doctor now
shows that persistent session_mode is overridden to direct on native
Windows, but the launch-time entry paths were silently downgrading
without telling the user. This commit adds the one-line warning
specified by the user, gated to the four entry commands where the
downgrade actually has an effect.
cmd/persistent.go:
- New package-level const platformOverrideWarning carries the exact
spec-mandated text so tests don't have to retype the copy.
- New helper emitPlatformOverrideWarningIfNeeded(alwaysPersistent).
Loads the resolver, reads SessionMode(), and emits the warning to
stderr when:
1. the call site is NOT AlwaysPersistent (attach has no
direct-mode fallback and continues to refuse on native
Windows via preflightPersistentEntry), AND
2. the resolver's value resolved through PlatformOverride.
Doctor and info do not call this helper — they render source
attribution themselves and an extra stderr line from a diagnostic
command would be noise. "Once per invocation" is provided
implicitly by the call site running at most once per ctask
command; no warn-once subsystem.
cmd/entry.go:
- defaultRunWorkspaceEntry calls the helper at the top, before any
launch work. This covers all four entry paths (new / resume / last
/ open) since they all funnel through runWorkspaceEntry. attach
also routes here but sets AlwaysPersistent=true, so the helper
short-circuits.
cmd/platform_warning_test.go (5 cases):
- TestPlatformOverrideWarningEmittedOnLaunch — simulated native
Windows + config session_mode: persistent + AlwaysPersistent=false
→ warning text appears on stderr.
- TestPlatformOverrideWarningNotEmittedWhenDirect — config
session_mode: direct → no warning even on simulated Windows.
- TestPlatformOverrideWarningNotEmittedWithoutConfig — builtin
default (direct) → no warning.
- TestPlatformOverrideWarningNotEmittedOnNonWindows — persistent
config but isNativeWindows() returns false → no warning.
- TestPlatformOverrideWarningSkippedForAlwaysPersistent — attach's
AlwaysPersistent=true gate prevents emission. attach's actual
refusal contract on native Windows is already covered by
TestPreflightRefusesNativeWindows in persistent_test.go.
Validation: `go test ./... -count=1`, `go vet ./...`, `go build`,
and `just build-linux` all clean.
This commit is contained in:
@@ -63,6 +63,13 @@ func dispatchPersistent(hasTmuxSession bool, leaseState session.LeaseState) disp
|
||||
}
|
||||
|
||||
func defaultRunWorkspaceEntry(opts WorkspaceEntryOptions) error {
|
||||
// v0.6: if the resolver downgraded a configured persistent mode to
|
||||
// direct via the native-Windows platform override, surface the fact
|
||||
// to the user once before any launch work happens. attach
|
||||
// (AlwaysPersistent=true) is excluded — it has no direct-mode
|
||||
// fallback and refuses on native Windows via preflightPersistentEntry.
|
||||
emitPlatformOverrideWarningIfNeeded(opts.AlwaysPersistent)
|
||||
|
||||
mode := config.ResolveSessionMode()
|
||||
persistent := opts.AlwaysPersistent || (mode == "persistent" && !opts.Direct)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user