refactor: consolidate duplicate utility functions#851
Merged
simple-agent-manager[bot] merged 1 commit intomainfrom Apr 30, 2026
Merged
refactor: consolidate duplicate utility functions#851simple-agent-manager[bot] merged 1 commit intomainfrom
simple-agent-manager[bot] merged 1 commit intomainfrom
Conversation
Eliminate three categories of code duplication: **API: parsePositiveInt consolidation (4 files)** - Remove `parseIntSafe` from cached-commands.ts and trial/events.ts - Remove `parseIntOrDefault` from file-library-config.ts and attachment-upload.ts - All now import the canonical `parsePositiveInt` from lib/route-helpers.ts **Frontend: time formatting consolidation (5 files)** - Create shared `time-utils.ts` with `formatRelativeTime`, `timeAgo`, `formatDuration` - Remove duplicate `formatRelativeTime` from ActivityFeed.tsx and ChatSessionList.tsx - Remove duplicate `timeAgo` from TriggerCard.tsx and library/types.tsx - Re-export from chat-session-utils.ts for backwards compatibility **Frontend: file download consolidation (nodes.ts)** - Extract shared `downloadFile` helper from 3 nearly-identical functions - `downloadNodeEvents`, `downloadNodeMetrics`, `downloadNodeDebugPackage` now delegate Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
e6c3909 to
3fdeb20
Compare
|
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
Eliminates three categories of code duplication identified by the code smell analysis:
parsePositiveIntconsolidation — 4 duplicate implementations (parseIntSafe,parseIntOrDefault) across routes and services now import the canonical version fromlib/route-helpers.tsformatRelativeTime/timeAgoimplementations replaced by a sharedlib/time-utils.tsmodulenodes.tsnow delegate to a shareddownloadFilehelperNet result: -54 lines (105 added, 159 removed), zero behavioral changes.
Test plan
pnpm typecheck— all 16 packages passpnpm lint— 0 errorspnpm --filter api test— 4192 tests passpnpm --filter web test— 2001 tests passpnpm build— all packages build successfullyStaging Verification
Agent Preflight (Required)
Classification
External References
N/A — internal refactor only
Codebase Impact Analysis
Pure refactor: consolidating duplicate utility functions into shared modules. No new behavior, no API changes, no UI changes. All existing tests pass unchanged.
Documentation & Specs
N/A — no public surface or documentation changes
Constitution & Risk Check
N/A — no new hardcoded values, no behavioral changes
Specialist Review Evidence
Generated with Claude Code