Fix idle timer review issues

This commit is contained in:
2026-05-15 11:18:03 +01:00
parent 2b9e1ed77c
commit 543c7cc59a
9 changed files with 417 additions and 35 deletions

View File

@@ -178,6 +178,11 @@ type SpawnSpec struct {
// or is closed. They must be attached before the PTY starts so a
// fast-exiting child cannot outrun cleanup registration.
CleanupPaths []string
// IdleDetection is the resolved per-preset idle classifier config.
// Must be installed before the child is published to s.children so
// the classifier goroutine never observes a nil/default config for
// a preset that overrides it.
IdleDetection *resolvedIdleDetection
}
// Spawn creates a new entry and starts its PTY. For Kind = command the
@@ -208,6 +213,12 @@ func (s *Session) Spawn(spec SpawnSpec, cols, rows uint16) (*Child, error) {
for _, path := range spec.CleanupPaths {
c.AddCleanupPath(path)
}
// Install idle-detection BEFORE publishing to s.children — otherwise
// the classifier goroutine could read c.idleDetection while the
// launcher is still racing to set it.
if spec.IdleDetection != nil {
c.setIdleDetection(spec.IdleDetection)
}
runID, err := c.startPTY(cols, rows)
if err != nil {
c.cleanupOwnedPaths()