Skip to content

refactor: consolidate formatDuration to single source in time-format.ts#1853

Open
iyoda wants to merge 2 commits intocode-yeongyu:devfrom
iyoda:refactor/pr2-consolidate-format-duration
Open

refactor: consolidate formatDuration to single source in time-format.ts#1853
iyoda wants to merge 2 commits intocode-yeongyu:devfrom
iyoda:refactor/pr2-consolidate-format-duration

Conversation

@iyoda
Copy link
Contributor

@iyoda iyoda commented Feb 15, 2026

Summary

Consolidate 4 identical formatDuration implementations down to 1 canonical source at src/shared/time-format.ts.

Changes

  • Deleted: src/features/background-agent/format-duration.ts
  • Deleted: src/features/background-agent/duration-formatter.ts
  • Deleted: src/tools/delegate-task/time-formatter.ts
  • Updated 5 consumers to import from shared/time-format

Net: -41 lines removed

Verification

  • bun run typecheck
  • bun test ✅ (2693 pass, 0 fail)
  • bun run build

PR Stack

This is PR 2 of 9 in the code deduplication refactor series. Depends on #1852.

# PR Description
0 #1852 Delete dead code in modules/
2 This PR Consolidate formatDuration (4→1)
3 (next) Consolidate getMessageDir (7→1)
4 Unify fuzzyMatchModel
5 Add json-cache utility
6 Apply json-cache to consumers
7 Add ensure-directory utility
8 Apply ensure-directory to production
9 Consolidate ToolContextWithMetadata

Summary by cubic

Consolidates all duration formatting into a single utility at src/tools/background-task/time-format.ts and deletes dead background-task modules to reduce duplication and maintenance.

  • Refactors
    • Standardized on formatDuration from src/tools/background-task/time-format.ts; removed duplicates in background-agent and delegate-task; updated 6 call sites (including re-exports).
    • Removed unused files under src/tools/background-task/modules/: background-cancel.ts, background-output.ts, background-task.ts, formatters.ts, message-processing.ts, utils.ts.

Written for commit 7f9c969. Summary will update on new commits.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 19 files

Confidence score: 2/5

  • High risk due to a concrete install/build failure: package.json adds a self-dependency (oh-my-opencode), which creates a circular dependency and will break installation.
  • Because this is a clear, high-severity issue (9/10) with certain impact, it significantly lowers merge safety.
  • Pay close attention to package.json - remove the invalid self-dependency to avoid build failures.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="package.json">

<violation number="1" location="package.json:65">
P0: Invalid self-dependency 'oh-my-opencode' added to dependencies. The package cannot depend on itself - this creates a circular dependency and will cause installation/build failures. This appears to be an accidental inclusion unrelated to the PR's formatDuration refactoring.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

package.json Outdated
Copy link

@cubic-dev-ai cubic-dev-ai bot Feb 15, 2026

Choose a reason for hiding this comment

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

P0: Invalid self-dependency 'oh-my-opencode' added to dependencies. The package cannot depend on itself - this creates a circular dependency and will cause installation/build failures. This appears to be an accidental inclusion unrelated to the PR's formatDuration refactoring.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At package.json, line 65:

<comment>Invalid self-dependency 'oh-my-opencode' added to dependencies. The package cannot depend on itself - this creates a circular dependency and will cause installation/build failures. This appears to be an accidental inclusion unrelated to the PR's formatDuration refactoring.</comment>

<file context>
@@ -62,6 +62,7 @@
     "detect-libc": "^2.0.0",
     "js-yaml": "^4.1.1",
     "jsonc-parser": "^3.3.1",
+    "oh-my-opencode": "^3.5.5",
     "picocolors": "^1.1.1",
     "picomatch": "^4.0.2",
</file context>
Fix with Cubic

@iyoda iyoda force-pushed the refactor/pr2-consolidate-format-duration branch from 0dc8f9a to 7f9c969 Compare February 15, 2026 08:52
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.

1 participant

Comments