Skip to content

refactor(board): simplify app and controller internals - #3817

Merged
dgageot merged 3 commits into
docker:mainfrom
dgageot:simplify-board
Jul 24, 2026
Merged

refactor(board): simplify app and controller internals#3817
dgageot merged 3 commits into
docker:mainfrom
dgageot:simplify-board

Conversation

@dgageot

@dgageot dgageot commented Jul 24, 2026

Copy link
Copy Markdown
Member

The pkg/board package had several repeated patterns that made the code harder to follow and introduced subtle maintenance hazards. Column lookup was duplicated across four methods using identical slices.IndexFunc calls, stored-project access was guarded by the same if a.config.Board != nil block in four places, and the per-card controller state was split across three parallel maps under the same mutex, which could drift out of sync.

This PR introduces two small private helpers in app.gocolumnIndexLocked and projectsLocked — to centralize those repeated patterns, and consolidates the three per-card maps in controller.go (expectTurn, launchFailures, launchErrors) into a single map[string]*cardState. The forget() method now drops one entry instead of three, eliminating the map-drift risk entirely.

All changes are strictly behavior-preserving refactors with no functional modifications.

@dgageot
dgageot requested a review from a team as a code owner July 24, 2026 06:05

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

This is a clean, behavior-preserving refactor. The two new helpers (columnIndexLocked and projectsLocked) correctly centralize repeated patterns without altering semantics. The consolidation of three per-card maps into a single map[string]*cardState simplifies forget() and eliminates map-drift risk without introducing any correctness issues.

Key equivalences verified:

  • AddProject reorder: when Board == nil, projectsLocked() returns nil; the duplicate loop over nil is a no-op — same outcome as iterating an empty Projects slice.
  • setExpectTurn(false): now creates a *cardState entry instead of deleting; turnExpected correctly returns false via the s != nil && s.expectTurn check.
  • resetLaunchFailures: setting to 0 vs deleting is functionally identical since callers only care whether the count is non-zero.
  • setLaunchError(nil): entry persists with a nil error; LaunchError() correctly returns nil either way.

@aheritier aheritier added area/core Core agent runtime, session management kind/refactor PR refactors code without behavior change labels Jul 24, 2026
@dgageot
dgageot merged commit e16c121 into docker:main Jul 24, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Core agent runtime, session management kind/refactor PR refactors code without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants