Consolidate small duplicate helpers without changing behavior
Proposal
At v0.4.49 (fa868a3630ffa0951fa029eba207a8728c1c1e06), several small paths implement the same operation independently. Consider the following independent refactors, each with its existing behavior and tests preserved. The line counts are rough net production-line estimates, including any new helper; they are not measured deletions or targets for removing tests.
| Candidate | Files | Estimated net lines saved | Behavior to preserve |
|---|---|---|---|
| Share the trimmed event-field helper | crates/cccc-web/src/im_runtime/discord_outbound.rs, feishu_outbound.rs, slack_outbound.rs, telegram_outbound.rs, and dingtalk_streaming.rs |
20–28 | Preserve string extraction, defaulting, trimming, and each caller's handling of an empty result. |
| Centralize runtime wire names | crates/cccc-core/src/runtime_mcp.rs, crates/cccc-runtime/src/command.rs, and an appropriate shared contracts module |
18–24 | Preserve every enum-to-wire-name mapping and avoid introducing a runtime-to-core dependency cycle. |
| Share the capability tooltip wrapper | web/src/components/capabilities/CapabilityCenterWorkspace.tsx and CapabilitySourcesView.tsx |
12–18 | Preserve forwarded tooltip reference props, focus, keyboard interaction, and rendering. |
| Reuse the actor display-name map | web/src/components/SearchModal.tsx, web/src/components/modals/InboxModal.tsx, and web/src/hooks/useActorDisplayName.ts |
10–16 | Preserve each caller's fallback for unknown or missing names; do not implicitly adopt special-recipient-token behavior. |
Suggested split and validation
- Extract the event-field operation into the existing IM common area. Cover missing, non-string, whitespace-only, and ordinary strings, and retain provider-specific tests.
- Move only the runtime-name mapping into a dependency-safe shared location. Check every supported runtime name and serialization compatibility.
- Extract the tooltip wrapper beside the capability views. Exercise focus and tooltip reference behavior in both views.
- Reuse the actor-name map in the two consumers, with regression coverage for each existing fallback and special-token handling.
Each step can be reviewed and merged independently; keep the current tests and add comparisons where coverage is missing. The goal is less duplicated maintenance, not a change in supported behavior. Estimates may change once the implementation and test coverage are assessed.
Coordination
None of the files listed above changed between v0.4.47 and v0.4.49. When this was written, we had no open upstream PRs. The runtime-name step touches the same runtime contract as the DeepSeek timeout fix (#184, now merged), so it should keep that behaviour unchanged. We'll recheck open PRs before implementing anything, to avoid duplicated work.
Thanks for checking these. All four are real duplicates. The duplication is a maintenance issue rather than evidence of a behavior bug, so we don’t currently plan to prioritize them for the next release. Small PRs are welcome, one candidate each, with current behavior and tests kept:
- Runtime names are the most useful one: a single name source on ActorRuntime in contracts, used by both callers.
- The actor name map in the two modals: keep each caller’s fallback, and don’t switch to getRecipientDisplayName, which treats selectors and Chet differently.
- The IM field helper can go in the existing IM common area.
- The tooltip wrapper is the smallest, so it can wait until that area changes. Please check open PRs first, as you said. We can only decide on each one once we’ve seen the diff and tests.
Closing: three of the four candidates are now consolidated on main (the shared trimmed stream-event helper for IM outbound, ActorRuntime::wire_name for runtime names, and the shared display-name map). The remaining tooltip wrapper is too small to be worth its own change. Thanks.