Slack: fix missing directory helper import#49930
Conversation
Greptile SummaryThis PR fixes a runtime
Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/slack/src/channel.ts
Line: 24-27
Comment:
**Alternative: import from existing `runtime-api.js` re-export**
`runtime-api.ts` already re-exports both `listSlackDirectoryPeersFromConfig` and `listSlackDirectoryGroupsFromConfig` from `./directory-config.js` (lines 12–15 in `runtime-api.ts`). Adding these two names to the existing `runtime-api.js` import block in `channel.ts` (which already imports several sibling utilities from there) would consolidate imports and avoid introducing a new import source for a file that is otherwise accessed through `runtime-api`.
```suggestion
import {
buildComputedAccountStatusSnapshot,
DEFAULT_ACCOUNT_ID,
listSlackDirectoryGroupsFromConfig,
listSlackDirectoryPeersFromConfig,
looksLikeSlackTargetId,
normalizeSlackMessagingTarget,
PAIRING_APPROVED_MESSAGE,
projectCredentialSnapshotFields,
resolveConfiguredFromRequiredCredentialStatuses,
type ChannelPlugin,
type OpenClawConfig,
} from "./runtime-api.js";
```
(and remove the separate `./directory-config.js` import block)
This is purely a style suggestion — the current direct import is functionally correct.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: extensions/slack/src/channel.test.ts
Line: 174-194
Comment:
**`listGroups` has no regression coverage**
The PR description mentions that both `directory.listPeers` and `directory.listGroups` threw at runtime due to the missing import. The new test only exercises `listPeers`. A parallel test for `listGroups` (using `channels` keys instead of `dms` keys) would close the regression gap for the second fixed path and guard against the same issue re-appearing for groups.
```suggestion
it("lists configured groups without throwing a ReferenceError", async () => {
const listGroups = slackPlugin.directory?.listGroups;
expect(listGroups).toBeDefined();
await expect(
listGroups!({
cfg: {
channels: {
slack: {
channels: {
"C456": {},
},
},
},
},
runtime: undefined,
}),
).resolves.toBeDefined();
});
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: "Slack: import direct..." |
| import { | ||
| listSlackDirectoryGroupsFromConfig, | ||
| listSlackDirectoryPeersFromConfig, | ||
| } from "./directory-config.js"; |
There was a problem hiding this comment.
Alternative: import from existing
runtime-api.js re-export
runtime-api.ts already re-exports both listSlackDirectoryPeersFromConfig and listSlackDirectoryGroupsFromConfig from ./directory-config.js (lines 12–15 in runtime-api.ts). Adding these two names to the existing runtime-api.js import block in channel.ts (which already imports several sibling utilities from there) would consolidate imports and avoid introducing a new import source for a file that is otherwise accessed through runtime-api.
| import { | |
| listSlackDirectoryGroupsFromConfig, | |
| listSlackDirectoryPeersFromConfig, | |
| } from "./directory-config.js"; | |
| import { | |
| buildComputedAccountStatusSnapshot, | |
| DEFAULT_ACCOUNT_ID, | |
| listSlackDirectoryGroupsFromConfig, | |
| listSlackDirectoryPeersFromConfig, | |
| looksLikeSlackTargetId, | |
| normalizeSlackMessagingTarget, | |
| PAIRING_APPROVED_MESSAGE, | |
| projectCredentialSnapshotFields, | |
| resolveConfiguredFromRequiredCredentialStatuses, | |
| type ChannelPlugin, | |
| type OpenClawConfig, | |
| } from "./runtime-api.js"; |
(and remove the separate ./directory-config.js import block)
This is purely a style suggestion — the current direct import is functionally correct.
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/slack/src/channel.ts
Line: 24-27
Comment:
**Alternative: import from existing `runtime-api.js` re-export**
`runtime-api.ts` already re-exports both `listSlackDirectoryPeersFromConfig` and `listSlackDirectoryGroupsFromConfig` from `./directory-config.js` (lines 12–15 in `runtime-api.ts`). Adding these two names to the existing `runtime-api.js` import block in `channel.ts` (which already imports several sibling utilities from there) would consolidate imports and avoid introducing a new import source for a file that is otherwise accessed through `runtime-api`.
```suggestion
import {
buildComputedAccountStatusSnapshot,
DEFAULT_ACCOUNT_ID,
listSlackDirectoryGroupsFromConfig,
listSlackDirectoryPeersFromConfig,
looksLikeSlackTargetId,
normalizeSlackMessagingTarget,
PAIRING_APPROVED_MESSAGE,
projectCredentialSnapshotFields,
resolveConfiguredFromRequiredCredentialStatuses,
type ChannelPlugin,
type OpenClawConfig,
} from "./runtime-api.js";
```
(and remove the separate `./directory-config.js` import block)
This is purely a style suggestion — the current direct import is functionally correct.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| describe("slackPlugin directory", () => { | ||
| it("lists configured peers without throwing a ReferenceError", async () => { | ||
| const listPeers = slackPlugin.directory?.listPeers; | ||
| expect(listPeers).toBeDefined(); | ||
|
|
||
| await expect( | ||
| listPeers!({ | ||
| cfg: { | ||
| channels: { | ||
| slack: { | ||
| dms: { | ||
| U123: {}, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| runtime: undefined, | ||
| }), | ||
| ).resolves.toEqual([{ id: "user:u123", kind: "user" }]); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
listGroups has no regression coverage
The PR description mentions that both directory.listPeers and directory.listGroups threw at runtime due to the missing import. The new test only exercises listPeers. A parallel test for listGroups (using channels keys instead of dms keys) would close the regression gap for the second fixed path and guard against the same issue re-appearing for groups.
| describe("slackPlugin directory", () => { | |
| it("lists configured peers without throwing a ReferenceError", async () => { | |
| const listPeers = slackPlugin.directory?.listPeers; | |
| expect(listPeers).toBeDefined(); | |
| await expect( | |
| listPeers!({ | |
| cfg: { | |
| channels: { | |
| slack: { | |
| dms: { | |
| U123: {}, | |
| }, | |
| }, | |
| }, | |
| }, | |
| runtime: undefined, | |
| }), | |
| ).resolves.toEqual([{ id: "user:u123", kind: "user" }]); | |
| }); | |
| }); | |
| it("lists configured groups without throwing a ReferenceError", async () => { | |
| const listGroups = slackPlugin.directory?.listGroups; | |
| expect(listGroups).toBeDefined(); | |
| await expect( | |
| listGroups!({ | |
| cfg: { | |
| channels: { | |
| slack: { | |
| channels: { | |
| "C456": {}, | |
| }, | |
| }, | |
| }, | |
| }, | |
| runtime: undefined, | |
| }), | |
| ).resolves.toBeDefined(); | |
| }); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/slack/src/channel.test.ts
Line: 174-194
Comment:
**`listGroups` has no regression coverage**
The PR description mentions that both `directory.listPeers` and `directory.listGroups` threw at runtime due to the missing import. The new test only exercises `listPeers`. A parallel test for `listGroups` (using `channels` keys instead of `dms` keys) would close the regression gap for the second fixed path and guard against the same issue re-appearing for groups.
```suggestion
it("lists configured groups without throwing a ReferenceError", async () => {
const listGroups = slackPlugin.directory?.listGroups;
expect(listGroups).toBeDefined();
await expect(
listGroups!({
cfg: {
channels: {
slack: {
channels: {
"C456": {},
},
},
},
},
runtime: undefined,
}),
).resolves.toBeDefined();
});
```
How can I resolve this? If you propose a fix, please make it concise.import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
import the config-backed Slack directory helpers into the Slack channel plugin so directory.listPeers and directory.listGroups no longer throw at runtime, and add a regression test covering configured DM peer listing
Summary
directory.listPeersanddirectory.listGroupsdo not throw at runtimeslackPlugin.directory.listPeersagainst configured Slack DMsValidation
pnpm test -- extensions/slack/src/channel.test.tsNotes