Skip to content

🤖 refactor: auto-cleanup#3589

Open
mux-bot[bot] wants to merge 9 commits into
mainfrom
auto-cleanup
Open

🤖 refactor: auto-cleanup#3589
mux-bot[bot] wants to merge 9 commits into
mainfrom
auto-cleanup

Conversation

@mux-bot

@mux-bot mux-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Long-lived auto-cleanup PR maintained by the Auto-Cleanup Agent. Each pass lands at most one extremely low-risk, behavior-preserving cleanup drawn from recently merged main activity, then advances the checkpoint below. The prior long-lived PR (#3559) merged into main; this is its successor.

Auto-cleanup checkpoint: 5dae4a3

This pass

Considered the one new main commit since the previous checkpoint — #3602 (fix: keep optimistic goal visible during streaming). That change adds WorkspaceGoalService.getPendingGoalSnapshot and a WorkspaceService.overlayPendingGoal choke-point overlay so mid-stream goal sets stay visible; the streaming/activity-emit overlay is intricate concurrency-adjacent surface (higher regression risk), so the cleanup was drawn from a small, self-contained duplicated construction in the same WorkspaceGoalService file.

Landed one behavior-preserving cleanup in workspaceGoalService.ts: the three private session-file path accessors (getFilePath / getHistoryFilePath / getBoardFilePath) each open-coded the identical assert(workspaceId.trim().length > 0, "WorkspaceGoalService requires non-empty workspaceId") guard plus path.join(this.config.getSessionDir(workspaceId), <FILE_CONST>). All three now delegate to a single resolveSessionFilePath(workspaceId, fileName) helper. Behavior-preserving: the accessor signatures and their callers are unchanged, and the assert message and join logic are identical at every site.

Branch contents (net diff against main)

Cleanups carried by this PR (not yet merged)
  • workspaceGoalService.ts — dedupe session file path resolution. 🤖 fix: keep optimistic goal visible during streaming #3602's goal-visibility fix touches this file; the three private accessors getFilePath / getHistoryFilePath / getBoardFilePath each open-coded the same assert(...non-empty workspaceId) guard and path.join(getSessionDir(...), <FILE_CONST>). All three now delegate to a single resolveSessionFilePath(workspaceId, fileName) helper. Behavior-preserving (identical guard + join; accessor names and callers unchanged).
  • task.ts — dedupe plan-agent explore-only error. The plan-agent restriction error In the plan agent you may only spawn agentId: "explore" tasks. was open-coded twice (the workspace-turn guard and the per-launch agent-id guard). Both now reference a single module-level PLAN_AGENT_EXPLORE_ONLY_ERROR constant. Behavior-preserving (identical string output).
  • task_await.ts — dedupe workspace-turn error fallback. 🤖 feat: add workspace turn task handles #3600's new workspace-turn await paths open-coded the fallback error message "Workspace turn failed" three times (<record>.error ?? "Workspace turn failed"). All three now reference a single module-level WORKSPACE_TURN_DEFAULT_ERROR constant. Behavior-preserving (identical string output).
  • goalToolUtils.tsx / SetGoalToolCall.tsx — dedupe turn-count pluralization. 🤖 feat: add agent-facing goal setting #3595's new goal toolcards open-coded `${n} turn${n === 1 ? "" : "s"}` in both formatGoalTurns and the set_goal toolcard's formatOptionalTurnCap. Both now call a shared pluralizeTurns(count) helper. Behavior-preserving (identical string output).
  • heartbeat.ts — dedupe heartbeat tool success result construction. 🤖 feat: add workspace heartbeat tool #3596's new heartbeat tool open-coded the same { success: true, action, configured, settings, summary } success object three times (get / set / unset), each re-calling summarize({ action, settings }). All three now route through a single buildSuccessResult(action, settings) helper that derives configured from settings. Behavior-preserving: the per-branch configured values (settings != null, false, true) all equal settings != null given the non-null Ok payload type for set.
  • taskService.ts — dedupe startup recovery candidate listing. 🤖 fix: prevent workflow task recovery after interrupts #3594's TaskService.initialize open-coded the awaiting_report / running candidate filters twice (initial computation and post-interrupt refresh). Both call sites now reuse a single listStartupRecoveryCandidates(sourceConfig) closure returning { awaitingReportTasks, runningTasks }, matching the existing listQueuedTasks pattern. Behavior-preserving.
  • ChatPane.tsx — dedupe send-queued-immediately in-flight guard clear. 🤖 fix: send queued message with empty Enter #3592 introduced sendQueuedImmediatelyInFlightRef to block duplicate send-now attempts; releasing that guard ("clear it only if it still points at this attempt") was open-coded twice — once after a failed interrupt result and once in the catch arm. Both call sites now invoke a single callback-local closure clearInFlightGuardIfCurrent(). Behavior-preserving: the failed-result site's combined !interruptResult.success && ref === id becomes if (!interruptResult.success) clearInFlightGuardIfCurrent() (logically identical); the catch site is a verbatim substitution.
  • WorkflowRunner.ts — dedupe parallelAgents child-failure abort handling into a single batch-local closure applyChildFailureToBatch(error), shared by the per-run task closure and the bulk-create path.
  • ChatInput/index.tsx — dedupe edit-mode attachment toast string "Attachments cannot be added while editing a message." into a single module-level constant EDIT_MODE_ATTACHMENT_ERROR_MESSAGE, replacing three inline copies across the add-attachment / paste / drop guards.
Prior passes (landed via #3559, merged)
  • Replaced an inline terminal-status check in WorkflowService.interruptRunOnAbort with the isTerminalWorkflowRunStatus helper.
  • Deduplicated the workspaceId-only metadata JSON Schema repeated by three id-targeted host actions in workspaceHostActions.ts into WORKSPACE_ID_ONLY_INPUT_SCHEMA.
  • Extracted a shared BlockedBadge component in WorkflowDefinitionToolCall.tsx.
  • Deduplicated the repeated argsSchema.properties must be an object error string in workflowArgs.ts.
  • Deduplicated mocked-module specifier strings in useModelsFromSettings.test.ts.
  • Removed a redundant toggleWorkflowExpanded wrapper in WorkflowRunToolCall.tsx.
  • Deduplicated SAVE_AUTOMATION_ERROR_MESSAGE / REMOVE_AUTOMATION_ERROR_MESSAGE in AutomationModal.tsx.
  • Replaced a duplicated "wfr_" literal in WorkflowRunner.ts with isWorkflowRunTaskId().

Validation

  • make static-check — ESLint, both tsgo typecheck configs, and Prettier all pass on the rebased tree. The only failing step is fmt-shell-check, which requires shfmt (not installed in this environment); no shell scripts were touched, so CI (which has shfmt) is unaffected.
  • bun test src/node/services/workspaceGoalService.test.ts — 131 pass, 0 fail (covers the goal service file whose path accessors this pass deduped).

Generated with mux • Model: anthropic:claude-opus-4-8 • Thinking: xhigh

@mux-bot

mux-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@mux-bot mux-bot Bot force-pushed the auto-cleanup branch from 56eb58c to be3ec5b Compare June 18, 2026 09:33
@mux-bot

mux-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Behavior-preserving dedup: extracted the duplicated child-failure abort handling in WorkflowRunner.parallelAgents into a single batch-local applyChildFailureToBatch closure. No control flow changed; bun test WorkflowRunner.test.ts passes (71/0).

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@mux-bot mux-bot Bot force-pushed the auto-cleanup branch 3 times, most recently from 6d9c760 to da799d5 Compare June 18, 2026 20:52
@mux-bot

mux-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@mux-bot mux-bot Bot force-pushed the auto-cleanup branch from da799d5 to e7de27b Compare June 18, 2026 21:02
@mux-bot

mux-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

⚠️ Auto-fixup: CI failure appears to be a flaky test, not caused by the cleanup commits — no code pushed.

Failed job: Test / Unit (run 27788620602)

Failing tests: src/browser/hooks/useChatTranscriptFullWidth.test.tsx (4 cases)

  • uses the cached preference until backend config resolves
  • ignores stale config fetches after a newer subscription refresh
  • accepts a newer backend refresh after a backend-driven cache update
  • caches backend config for the next mount

Root cause: Each failure is a waitFor(() => expect(getConfigMock).toHaveBeenCalledTimes(1)) that times out at ~1000ms with Received number of calls: 0 — the hook's async config-fetch effect did not fire within the window. This occurred only in the coverage-instrumented full-suite run (bun test --coverage --max-concurrency=1), where instrumentation overhead and accumulated process state slow effect scheduling. Classic timing flake.

Why it's unrelated to this PR: the cleanup only touches ChatPane.tsx, ChatInput/index.tsx, taskService.ts, and WorkflowRunner.ts — none of which touch useChatTranscriptFullWidth or its dependencies (API context, usePersistedState, storage constants). The test file itself is unchanged by this branch (last modified in #3350).

Local verification: the suite passes consistently — 8/8 across 5 consecutive runs on this branch.

Recommendation: re-run the failed CI job. No automated fix is warranted since modifying the unrelated test would exceed the cleanup scope. If this test proves persistently flaky under coverage, consider hardening it separately (e.g., a higher waitFor timeout).

@mux-bot

mux-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

⚠️ Auto-fixup could not resolve CI failure: the Test / Unit failure is a pre-existing flaky test, not caused by this cleanup PR. No code was pushed.

Failing tests (src/browser/hooks/useChatTranscriptFullWidth.test.tsx):

  • uses the cached preference until backend config resolves
  • ignores stale config fetches after a newer subscription refresh
  • accepts a newer backend refresh after a backend-driven cache update
  • caches backend config for the next mount

Why this is a flake, not a regression:

  • All four failures are waitFor(...) timeouts at ~1000–1004 ms (the default 1 s timeout), e.g. expect(getConfigMock).toHaveBeenCalledTimes(1) → received 0. getConfigMock is invoked from a React effect inside the hook; under heavy CI parallelism (this job ran 9256 tests across 655 files) the effect/promise occasionally doesn't settle within 1 s.
  • This PR (auto-cleanup) only touches ChatPane.tsx, ChatInput/index.tsx, taskService.ts, and WorkflowRunner.ts. It does not modify useChatTranscriptFullWidth (hook or test) nor any of its imports.
  • Ran the test locally 5/5 times after bun install — all green (8 pass, 0 fail each run).

(The emitWorkflowRunActivity is not a function lines in the log are caught/logged noise from router.test.ts, which still passes — not the failure source.)

Recommendation: re-run the Test / Unit job. If it keeps flaking, the test should be hardened (e.g. bump the waitFor timeout or await the effect deterministically) in a separate change — out of scope for auto-fixup.

@mux-bot mux-bot Bot force-pushed the auto-cleanup branch from e7de27b to 7efa56e Compare June 19, 2026 13:12
@mux-bot

mux-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

This pass adds one behavior-preserving cleanup: heartbeat.ts now routes its get / set / unset success returns through a single buildSuccessResult(action, settings) helper instead of re-assembling the identical { success: true, action, configured, settings, summary } object three times. configured is derived as settings != null, which matches each prior branch (get: already settings != null; unset: nullfalse; set: non-null Ok payload → true). Checkpoint advanced to c89f5e1.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@mux-bot mux-bot Bot force-pushed the auto-cleanup branch from 7efa56e to dfafa92 Compare June 19, 2026 16:53
@mux-bot

mux-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

This pass extracts a shared pluralizeTurns(count) helper in goalToolUtils.tsx and reuses it in formatGoalTurns and SetGoalToolCall.tsx's formatOptionalTurnCap, deduping the ${n} turn${n === 1 ? "" : "s"} pluralization introduced by #3595. Behavior-preserving (identical string output); checkpoint advanced to 4bac642.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@mux-bot mux-bot Bot force-pushed the auto-cleanup branch from dfafa92 to e6b5f65 Compare June 19, 2026 20:37
@mux-bot

mux-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Periodic auto-cleanup pass: rebased onto latest origin/main and landed one behavior-preserving dedupe in task_await.ts — the "Workspace turn failed" fallback (open-coded 3×) now references a single WORKSPACE_TURN_DEFAULT_ERROR constant. Checkpoint advanced to c263729.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@mux-bot

mux-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

⚠️ Auto-fixup could not resolve CI failure: the failing job (Test / Windows, run 27847382625) is a flaky/environmental failure, not a regression from this branch.

Root cause: All 15 Windows failures originate in test scaffolding createTempGitRepo() (tests/ipc/helpers.ts:591), where git init fails with no stderr (Command failed: git init) — including across both retries. This affects tests/ipc/runtime/executeBash.test.ts and tests/ipc/runtime/backgroundBashDirect.test.ts.

Why this is not caused by the cleanup commit:

  • The 8 changed files are all unrelated frontend chat/tools + backend task/heartbeat/workflow code; none touch git, runtime, executeBash, backgroundBash, or test helpers.
  • Failure is Windows-only — Unit, Integration, E2E (linux/macOS), Storybook, and all Build jobs passed.
  • Recent runs of the same Test / Windows job (including on main) pass cleanly; only this run hit the git init flake.

Action: No code pushed (the fix: circuit-breaker is intentionally not triggered). Recommend re-running the Test / Windows job. Manual intervention only needed if the git init flake recurs.

@mux-bot

mux-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

⚠️ Auto-fixup could not resolve CI failure: classified as a flaky/environmental Windows failure, not caused by the cleanup commit — no code pushed.

Failed job: Test / Windows (run 27847382625)
Failed suite: tests/ipc/runtime/backgroundBashDirect.test.ts (7 failed)

Root cause (environmental):

  • All failures occur in test setup, not in any assertion under test:
    • Failed to create workspace: Command failed with exit code 3221225794
    • Command failed: git init
  • 3221225794 = 0xC0000142 (STATUS_DLL_INIT_FAILED) — a well-known transient Windows process-initialization failure that surfaces when spawning processes (here, git) under load on the runner. The log also reports A worker process has failed to exit gracefully and has been force exited, a classic resource-exhaustion symptom.

Why this is not caused by the cleanup commit:

  • This PR only touches frontend chat/goal/workflow UI and backend task/heartbeat/workflow service files. None touch workspace creation, git init, PTY, or process spawning.
  • The failing suite imports none of the refactored modules.
  • The most plausibly-related change (src/node/services/tools/task_await.ts) is a trivial dedupe that extracts an error-string constant (WORKSPACE_TURN_DEFAULT_ERROR) with no behavioral effect.

Recommendation: Re-run the Test / Windows job. If it recurs across unrelated PRs, the backgroundBashDirect workspace-setup path may need hardening/retry on Windows (0xC0000142). Manual intervention / a re-run is needed; no fix was pushed.


Generated with mux • Model: anthropic:claude-opus-4-8 • Thinking: xhigh • Cost: $0.00

@mux-bot mux-bot Bot force-pushed the auto-cleanup branch from e6b5f65 to 0fab59f Compare June 22, 2026 10:04
@mux-bot

mux-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Auto-cleanup pass: rebased onto latest origin/main and landed one behavior-preserving dedupe in src/node/services/tools/task.ts — the plan-agent restriction error string was open-coded in two guards and now references a single module-level PLAN_AGENT_EXPLORE_ONLY_ERROR constant. Checkpoint advanced to 9dcfc83 (#3576).

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

mux-bot Bot added 3 commits June 22, 2026 13:48
Extract the thrice-repeated "Attachments cannot be added while editing a
message." toast string into a module-level EDIT_MODE_ATTACHMENT_ERROR_MESSAGE
const so the three guards surface identical copy and cannot drift.
Behavior-preserving.
mux-bot Bot added 6 commits June 22, 2026 13:48
…itialize

Extract the awaiting_report/running candidate filters used by the startup
inactive-workflow-owner recovery pass into a single listStartupRecoveryCandidates
closure, mirroring the existing listQueuedTasks pattern, so the initial computation
and the post-interrupt refresh reuse the exact same status filters.

Behavior-preserving cleanup of #3594.
The 'In the plan agent you may only spawn agentId: "explore" tasks.' error
string was open-coded twice in task.ts — once in the workspace-turn guard and
once in the per-launch agent-id guard. Both now reference a single module-level
PLAN_AGENT_EXPLORE_ONLY_ERROR constant. Behavior-preserving (identical string).
@mux-bot mux-bot Bot force-pushed the auto-cleanup branch from 0fab59f to a0a14eb Compare June 22, 2026 13:55
@mux-bot

mux-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

This pass: deduped the three private session-file path accessors in workspaceGoalService.ts (getFilePath / getHistoryFilePath / getBoardFilePath) — each open-coded the same non-empty workspaceId assert + path.join(getSessionDir(...), <FILE_CONST>) — into a single private resolveSessionFilePath(workspaceId, fileName) helper. Behavior-preserving: accessor names/signatures and all callers unchanged; identical assert message and join at every site. Checkpoint advanced to 5dae4a3.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants