Repository navigation
fix: stop treating unjoined public channels as private - #102
Conversation
The private-channel check only knew about the channels you've joined, so a thread in a public channel you hadn't joined failed with "This thread belongs to a private channel" and needed --include-private-channels. When a channel isn't one you've joined, the check now looks for it among the workspace's public channels before failing. Joined channels work as before with no extra call, and joined private channels still need the flag. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
| const isPublic = | ||
| joined.get(channelId) ?? | ||
| // getChannels only returns joined channels, so an unjoined one could still be public. | ||
| (await getWorkspacePublicChannelIds(workspaceId)).has(channelId) |
There was a problem hiding this comment.
Why the workspace's public channels and not getChannel for just this one: channels/getone is the call with the per-user rate limit (see #94), and thread view already makes one for the channel name. The public channel list has no limit but is much bigger, since it carries every public channel's members: about 0.3s extra on an unjoined channel in a quick timing (1.31s against 0.98s for a joined one). It's only fetched when the channel isn't one you've joined, once per run. It also comes back empty for guests, so it can only be a fallback, not a replacement for the joined list.
doistbot
left a comment
There was a problem hiding this comment.
This PR fixes the visibility check so unjoined public channels no longer get misreported as private — joined channels short-circuit with no extra API call, joined private channels still require the flag, and the new workspace public-channel fallback is cached with tests covering the new paths.
Few things worth tightening:
- For
tdc channel threads <name>resolving to an unjoined public channel, the fallback refetchesworkspaces.getPublicChannelsright afterresolveChannelRefalready fetched the same list to resolve the name — doubling the heaviest call on exactly the path this PR enables. SinceshowChannelThreadsalready has the resolvedChannelwith itspublicflag, passing that known value intoassertChannelIsPublic(or sharing the public-channel cache) would avoid the duplicate fetch.
| const isPublic = | ||
| joined.get(channelId) ?? | ||
| // getChannels only returns joined channels, so an unjoined one could still be public. | ||
| (await getWorkspacePublicChannelIds(workspaceId)).has(channelId) |
There was a problem hiding this comment.
For
tdc channel threads <name> resolving to an unjoined public channel, this fallback fetches workspaces.getPublicChannels again right after resolveChannelRef in src/lib/refs.ts has already fetched the same list to resolve the name (channels.getChannels is also fetched by both paths). That doubles the heaviest call on the exact path this PR enables — the list the PR otherwise treats as expensive. showChannelThreads already has the resolved Channel with its public flag, so pass that known value into assertChannelIsPublic (or otherwise share the public-channel cache) to avoid the duplicate fetch.
There was a problem hiding this comment.
Addressed in 3d6924d, and in thread create too.
channel threads and thread create already have the channel they resolved, so the private-channel check now takes its public flag instead of looking it up. For an unjoined channel resolved by name, the lookup was fetching the workspace's public channels a second time. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
@doistbot /review |
doistbot
left a comment
There was a problem hiding this comment.
This PR fixes the private-channel guard so unjoined public channels work with tdc thread view, channel threads, and related thread commands, falling back to the workspace's public-channel list when a channel isn't in your joined set — joined private channels still require --include-private-channels.
Few things worth tightening:
- In
viewThread, the unconditionalgetChannel(thread.channelId)fetch for the channel name happens after the guard, so unjoined public channels trigger both the workspace-wide public-channel list (with members) and the channel lookup. Reorder so the existinggetChannelresult feeds the guard viachannel.public, avoiding the extra workspace-wide call entirely.
| return ( | ||
| joined.get(channelId) ?? | ||
| // getChannels only returns joined channels, so an unjoined one could still be public. | ||
| (await getWorkspacePublicChannelIds(workspaceId)).has(channelId) |
There was a problem hiding this comment.
Reuse thread view's existing channel lookup.
viewThread calls this guard before unconditionally fetching client.channels.getChannel(thread.channelId) for the channel name. For an unjoined public channel, it therefore downloads the workspace-wide public-channel list, including channel members, even though the subsequent channel lookup supplies the same visibility flag. Move that existing lookup before the guard and pass channel.public; this avoids the new workspace-wide request without adding another rate-limited getChannel call.
There was a problem hiding this comment.
Not changing this one. Thread view's channel lookup is the rate-limited call, and #94 is making a 429 there show the thread without the channel name instead of failing. If the private-channel check relied on that lookup, those views would fail again. The list call only runs for channels you haven't joined, about 0.3s there. Once #94 is in, the lookup could feed the check, with the list as the fallback on a 429.
|
🎉 This PR is included in version 3.9.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Lets
tdc thread view,channel threadsand the other thread commands read public channels you haven't joined, without--include-private-channels.Fixes #61
Why: the private-channel check only knew about the channels you've joined, so it reported every other channel as private, public ones included. Agents pass that message on as fact, and the only way round it was
--include-private-channels, which switches the check off for private channels too.What changes: when a channel isn't one you've joined, the check now looks for it among the workspace's public channels before failing. It's option 2 from @lmjabreu's write-up, except it checks the workspace's list rather than the channel itself (the reason is in a comment on the line). Channels you've joined work as before, with no extra call, and joined private channels still need the flag.
Testing: three new tests. The two that cover an unjoined public channel fail on
mainwith "This thread belongs to a private channel". Against a public channel I haven't joined:A joined private channel still fails without the flag.
npm test(1192 tests),type-checkandlint:checkpass.Not addressed:
tdc inboxandsearch. They filter on the same list of joined channels, so a thread from a public channel you haven't joined is still left out unless you pass the flag. The same fallback would work there, but this PR sticks to the check from the issue.🤖 Generated with Claude Code