clawwork-ai / clawwork-ai/ClawWork

[Cleanup] Group GatewayDispatcherDeps fields by concern

Open
#234 1 comment 0 reactions 0 assignees View on GitHub
area/core area/gateway kind/cleanup
Dominant language
TypeScript
Stars
532
Forks
75
Avg merge
5h 31m
Merged PRs (30d)
1

Description

## What problem are you trying to solve?

The `GatewayDispatcherDeps` interface has grown to 31 fields. While each field is a real dependency, the flat list makes construction verbose and signals the dispatcher may be doing too much. Grouping by concern would improve readability and make it easier to identify future decomposition opportunities.

## Where

`packages/core/src/services/gateway-dispatcher.ts` — the `GatewayDispatcherDeps` interface (around lines 72-132).

## What needs to be done

1. Open `packages/core/src/services/gateway-dispatcher.ts`
2. Find the `GatewayDispatcherDeps` interface
3. Group the fields into sub-interfaces by concern. Suggested grouping:

```ts
interface StoreDeps {
getTaskStore: () => TaskStore;
getMessageStore: () => MessageStore;
getActiveTaskId: () => string | null;
markUnread: (taskId: string) => void;
}

interface GatewayStatusDeps {
setGatewayStatusByGateway: ...;
setGatewayVersion: ...;
setGatewayReconnectInfo: ...;
setDefaultGatewayId: ...;
setGatewayInfoMap: ...;
setGatewaysLoaded: ...;
getGatewayInfoMap: ...;
}

interface CatalogDeps {
setModelCatalogForGateway: ...;
setAgentCatalogForGateway: ...;
setToolsCatalogForGateway: ...;
setSkillsStatusForGateway: ...;
}
```

4. Compose the main interface: `interface GatewayDispatcherDeps extends StoreDeps, GatewayStatusDeps, CatalogDeps { ... remaining fields }`
5. Update the construction site(s) that build this deps object
6. Run `pnpm check` to verify nothing breaks

## Why does this matter?

A 31-field flat interface is hard to scan and construct. Grouping by concern makes dependencies self-documenting and eases future refactoring if the dispatcher is decomposed.

## Primary area

Task execution

Contributor guide

Open the contributing guide

Research direction

Start in packages/core/src/services/gateway-dispatcher.ts at the GatewayDispatcherDeps interface around lines 72-132. Group its fields into concern-based sub-interfaces, compose the main interface, and locate the construction sites that build the dependency object. Run pnpm check; done means the dependencies are grouped without breaking type checking.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.