🤖 refactor: auto-cleanup#3606
Open
mux-bot[bot] wants to merge 4 commits into
Open
Conversation
Contributor
Author
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
e035f24 to
893fadc
Compare
Contributor
Author
|
@codex review This pass adds one behavior-preserving cleanup: in |
893fadc to
2d77a10
Compare
Contributor
Author
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
#3605 introduced two near-identical guard blocks that background registered foreground waits when a tool-end message is already queued (one in the workspace-turn wait path, one in the task-await path). Extract a single private helper backgroundForegroundWaitIfQueued() shared by both sites. Behavior-preserving: the helper folds in the requestingWorkspaceId truthiness guard, which is always true at the workspace-turn site (asserted non-empty) and already implied by shouldBackgroundOnQueuedMessage at the task-await site.
The skill:// prefix is already named by SKILL_SCRIPT_PATH_PREFIX and used for parsing; reuse it in the two canonical-path builders instead of re-spelling the literal, so the prefix cannot drift. Behavior-preserving: the constant value is identical to the literal it replaces.
Dedupe the identical inline argument object declared by WorkflowTaskServiceLike.create and createMany into a named WorkflowTaskCreateArgs interface so the agent-task creation shape has a single source of truth. PR #3611 just added onRefusal to both copies, demonstrating the drift risk. Behavior-preserving: pure type-level refactor, no runtime change.
The 'mux.taskHandleId' workspace tag is written in taskService (node) and read in TaskToolCall (browser); the literal was duplicated across the node/browser boundary. Extract the three workspace-turn task tag keys into a shared @/constants/workspaceTags module so the cross-layer contract has a single source of truth. Pure constant substitution: values are byte-identical, so no behavior changes.
2d77a10 to
8e48d9e
Compare
Contributor
Author
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
mainactivity, then advances the checkpoint below.Auto-cleanup checkpoint: 25d1d25
This PR currently contains four accumulated cleanups against
main:src/node/services/taskService.ts— dedupe queued-message foreground backgrounding into a private helper.src/node/services/workflows/workflowScriptResolver.ts— reuse theSKILL_SCRIPT_PATH_PREFIXconstant for canonical-path construction.src/node/services/workflows/WorkflowTaskServiceAdapter.ts— extract the duplicated agent-task creation arg shape into a sharedWorkflowTaskCreateArgstype.src/constants/workspaceTags.ts(new) — centralize the workspace-turn task tag keys, removing the cross-layer"mux.taskHandleId"string duplication.This pass
Considered the nine new commits on
mainsince the prior checkpoint:fix: queue busy workspace turn follow-ups)fix: recover stale workspace turn handles)refactor: remove workflow-smoke built-in skill)refactor: remove workflow agentType option)fix: hide archived task_list entries by default)fix: mark built-in workflow skills)fix: remove skill pill from slash suggestions)fix: link workspace task cards)ci: cache Playwright browsers on macOS)The workspace-turn task tag key
"mux.taskHandleId"is written byTaskService.createWorkspaceTurn(node, #3617/#3619) and read byfindWorkspaceForTaskTargetinTaskToolCall.tsx(browser, #3613) — the same magic string duplicated across the node/browser boundary. That cross-layer contract was an exact AGENTS.md "centralize magic constants undersrc/constants/" case: a silent rename on either side would break workspace-task card linking with no compile-time signal.Landed one behavior-preserving dedup: extracted the three workspace-turn task tag keys (
handle,ownerWorkspaceId,turn) into a new@/constants/workspaceTagsmodule and referencedWORKSPACE_TURN_TASK_TAGSfrom both the node write site and the browser read site. The grouped keys are written together as a cohesive tag schema, so centralizing all three keeps the source single and self-documenting.Behavior-preserving:
taskService.test.tsassertions intentionally keep the raw"mux.taskHandleId"/"mux.taskOwnerWorkspaceId"literals so they continue to pin the exact on-disk key values and would catch any accidental constant drift.Prior pass — WorkflowTaskServiceAdapter WorkflowTaskCreateArgs type
WorkflowTaskServiceLike(inWorkflowTaskServiceAdapter.ts) declared the agent-task creation argument object twice — once inline increate(args: { ... })and again insidecreateMany?(args: Array<{ ... }>)— as byte-identical 10-field shapes (including a nestedworkflowTaskobject). #3611 added theonRefusalfield to both copies, which is exactly the drift risk this duplication invites. Extracted a namedWorkflowTaskCreateArgsinterface and referenced it from bothcreateandcreateMany, giving the agent-task creation shape a single source of truth. Behavior-preserving: structurally identical interface, signatures unchanged.Prior pass — workflowScriptResolver SKILL_SCRIPT_PATH_PREFIX reuse
In
workflowScriptResolver.ts, theskill://prefix is named by the module-level constantSKILL_SCRIPT_PATH_PREFIXand used when parsing incomingskill://paths, but the two canonical-path builders re-spelled the literal`skill://${...}`instead of reusing the constant. Both builders now interpolate${SKILL_SCRIPT_PATH_PREFIX}so the prefix has a single source of truth. Behavior-preserving:SKILL_SCRIPT_PATH_PREFIXis exactly"skill://", so the interpolation is byte-identical.Prior pass — taskService queued-message dedup
Considered #3605 (
fix: background foreground waits for prequeued messages), which open-coded the same queued-message guard at twoTaskServicewait-registration sites (waitForWorkspaceTurnand the task-await path). Both sites now delegate to a single private helperbackgroundForegroundWaitIfQueued(shouldBackgroundOnQueuedMessage, requestingWorkspaceId)placed next tobackgroundForegroundWaitsForWorkspace. Behavior-preserving: the helper folds in therequestingWorkspaceIdtruthiness guard (always true at the workspace-turn site; a verbatim match at the task-await site), and the pushed call is unchanged.Validation
make static-checkpasses locally for the touched code: ESLint, both TypeScript configs (tsconfig+tsconfig.main.json), and Prettier are green. The only non-passing step isfmt-shell-check, which fails solely because theshfmtbinary is not installed in this environment; no shell files are touched by any change.bun test src/node/services/taskService.test.ts src/browser/features/Tools/TaskToolCall.test.tsx(230 tests), including theTaskToolCall"labels workspace tasks and opens their created workspace" test that exercises themux.taskHandleIdtag round-trip across the node/browser boundary.Risks
Minimal. All changes are pure local extractions / constant reuse; no logic, types, or call semantics change. The latest pass replaces duplicated magic strings with byte-identical shared constants and has no runtime effect.
Generated with
mux• Model:anthropic:claude-opus-4-8• Thinking:xhigh