Skip to content

refactor: package code organization wave 9#2274

Open
gsxdsm wants to merge 2 commits into
mainfrom
feature/code-organization-wave9
Open

refactor: package code organization wave 9#2274
gsxdsm wants to merge 2 commits into
mainfrom
feature/code-organization-wave9

Conversation

@gsxdsm

@gsxdsm gsxdsm commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Wave 9 of package code organization (plan: docs/plans/2026-07-14-001-refactor-package-code-organization-plan.md), after #2252.

Peels

New module Parent
app/api/global-and-pi-settings.ts legacy.ts
app/api/task-content.ts legacy.ts (attachments/logs/comments/docs/artifacts)
types/messages.ts types.ts
merger-diff-volume-gate helpers merger.ts

Public paths stay stable via re-exports.

LOC

  • legacy.ts ~10561 → ~10269
  • types.ts ~6998 → ~6937
  • merger.ts ~11223 → ~11208

Test plan

  • core/engine/dashboard typecheck (app)
  • eslint on peeled modules
  • api-tasks + memory/agent-log focused tests
  • CI merge gate

Summary by CodeRabbit

  • New Features
    • Added dashboard API endpoints for global and project-scoped settings, PI configuration, notification testing, and PI package install/reinstall.
    • Added task content APIs covering attachments, agent logs, session files, task comments, task documents, artifacts, and project markdown files.
    • Added structured messaging contracts and participant/message normalization.
    • Added diff-volume gate settings resolution and formatted findings output.
  • Refactor
    • Organized messaging and dashboard API surface into dedicated modules via re-exports.
    • Removed a deprecated verification-output alias.

Behavior-preserving package organization after #2252:
- app/api/global-and-pi-settings.ts and task-content.ts from legacy.ts
- types/messages.ts (ParticipantType + Message contracts)
- merger-diff-volume-gate: resolveDiffVolumeGateSettings + formatFindings
Ratchet legacy/types/merger line-count ceilings downward.
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 43338d10-d83e-41b5-811c-478062d86007

📥 Commits

Reviewing files that changed from the base of the PR and between 776e90b and 49a3fd9.

📒 Files selected for processing (3)
  • packages/dashboard/app/api/global-and-pi-settings.ts
  • packages/dashboard/app/api/legacy.ts
  • packages/dashboard/app/api/task-content.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/dashboard/app/api/global-and-pi-settings.ts
  • packages/dashboard/app/api/task-content.ts

📝 Walkthrough

Walkthrough

The PR modularizes core message contracts, adds dashboard clients for settings and task content, preserves legacy API exports, and extracts diff-volume gate utilities from the merger module.

Changes

Core message contracts

Layer / File(s) Summary
Message contract module
packages/core/src/types/messages.ts
Defines participant normalization, message metadata, persistence, creation, and filtering contracts.
Message contract re-exports
packages/core/src/types.ts
Keeps existing message exports available through the core types barrel.

Dashboard API modules

Layer / File(s) Summary
Settings and PI API clients
packages/dashboard/app/api/global-and-pi-settings.ts
Adds typed helpers for settings, PI extensions, notifications, PI configuration, and package operations.
Task-content API clients
packages/dashboard/app/api/task-content.ts
Adds typed attachment, log, comment, document, artifact, and markdown-file API helpers.
Legacy API compatibility
packages/dashboard/app/api/legacy.ts
Re-exports the extracted APIs and preserves legacy artifact type access and function names.

Engine diff-volume utilities

Layer / File(s) Summary
Diff-volume gate utilities
packages/engine/src/merger-diff-volume-gate.ts
Defines normalized gate settings and formatted diff-volume findings.
Merger utility wiring
packages/engine/src/merger.ts
Re-exports the extracted utilities, removes local implementations and the deprecated alias.
Line-count baselines
scripts/line-count-baseline.json
Updates stored baselines for the reorganized files.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • Runfusion/Fusion#2139: Both changes modularize message exports from packages/core/src/types.ts into dedicated type modules.

Suggested reviewers: automata-intelligentsia, plarson

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is related to the refactor, but it is too generic to convey the main code changes in this PR. Use a more specific title such as "refactor package APIs: move settings, task content, messages, and merger helpers".
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/code-organization-wave9

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR reorganizes several large package modules while preserving their public paths. The main changes are:

  • Moves messaging contracts into a dedicated core module.
  • Moves dashboard settings and task-content APIs into focused modules.
  • Moves diff-volume gate helpers out of the merger module.
  • Restores the legacy markdown-file options type export.

Confidence Score: 5/5

This looks safe to merge.

  • The missing legacy type export is restored.
  • The related task-content exports remain available through the stable module.
  • No blocking issue remains in the updated fix path.

Important Files Changed

Filename Overview
packages/dashboard/app/api/legacy.ts Re-exports the extracted dashboard APIs and restores the missing markdown-file options type.
packages/dashboard/app/api/task-content.ts Contains the extracted attachment, log, comment, document, and artifact client APIs.
packages/dashboard/app/api/global-and-pi-settings.ts Contains the extracted global settings, notification, and Pi package client APIs.
packages/core/src/types.ts Preserves messaging exports through the existing core types module.
packages/core/src/types/messages.ts Contains the extracted messaging types and participant normalization logic.
packages/engine/src/merger-diff-volume-gate.ts Now owns diff-volume settings normalization and finding formatting.
packages/engine/src/merger.ts Uses and re-exports the extracted diff-volume helpers.

Reviews (2): Last reviewed commit: "Address PR review feedback (#2274)" | Re-trigger Greptile

Comment thread packages/dashboard/app/api/legacy.ts

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/dashboard/app/api/global-and-pi-settings.ts`:
- Around line 53-62: Update testNotification so the explicitly selected
providerId is applied after spreading config in the request body. This prevents
config.providerId from overriding the function argument while preserving all
other configuration fields.

In `@packages/dashboard/app/api/task-content.ts`:
- Around line 34-36: Update deleteAttachment and the affected key-based API
methods in packages/dashboard/app/api/task-content.ts at lines 34-36, 129-131,
133-135, 254-269, and 271-275 to wrap each user-defined filename or key path
segment with encodeURIComponent before constructing the URL; apply the same
encoding consistently at all five sites.
- Around line 29-31: Update the upload response handling around the JSON parsing
in the task-content request to safely handle non-JSON error responses: catch
parse failures, preserve the HTTP failure status, and throw an error using the
parsed API message when available or an HTTP-status-based fallback otherwise.
Follow the existing pattern used by fetchAgentLogsWithMeta.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 406e5db1-b6a4-401c-b53b-271c75ce79c4

📥 Commits

Reviewing files that changed from the base of the PR and between 065890c and 776e90b.

📒 Files selected for processing (8)
  • packages/core/src/types.ts
  • packages/core/src/types/messages.ts
  • packages/dashboard/app/api/global-and-pi-settings.ts
  • packages/dashboard/app/api/legacy.ts
  • packages/dashboard/app/api/task-content.ts
  • packages/engine/src/merger-diff-volume-gate.ts
  • packages/engine/src/merger.ts
  • scripts/line-count-baseline.json

Comment thread packages/dashboard/app/api/global-and-pi-settings.ts
Comment thread packages/dashboard/app/api/task-content.ts Outdated
Comment thread packages/dashboard/app/api/task-content.ts
- Re-export FetchProjectMarkdownFilesOptions from legacy API barrel
- Pin providerId last in testNotification so config cannot override it
- Safely parse non-JSON upload error bodies with HTTP status fallback
- encodeURIComponent for attachment filename and document key path segments
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