Delete service channels from the catalog, attached or not - #1143
Merged
Conversation
Deleting a channel forwarded to detach, so the channel stayed in the shared catalog while the TUI reported it "deleted and withdrawn". And because the channel editor only opened for channels attached to the current service, an available catalog row could not be deleted at all — `d` was a no-op on exactly the rows a user would want to clean up. delete_channel now removes the channel from the catalog: it errors when the channel is not in the catalog, refuses a channel attached to another service (naming the owner), and otherwise detaches from this service before dropping the catalog entry. Both the service definition and the catalog are persisted; the dispatch still withdraws the endpoint. In the TUI, `d` arms the delete confirmation for an unattached channel as well, with a prompt and result note that say "catalog" instead of claiming a withdrawal that never happened. Channels owned by another service are still refused, now with an explanatory note rather than silence.
…e-unattached # Conflicts: # crates/cli/src/app.rs
…e-unattached # Conflicts: # crates/cli/src/app/service_dialog.rs # crates/cli/src/ui.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two things were wrong with channel deletion:
delete_channelforwarded straight todetach_channel, which removes the channel from the service definition but leaves it in the shared catalog. The TUI then reported "Channel `x` deleted and withdrawn." while the channel was still sitting there as an available row.open_edit_service_channelreturnedfalseunless the channel was attached to the current service, sod(and the editor'sC-d) was a silent no-op on exactly the available rows a user would want to clean up.Change
Daemon (
crates/daemon/src/service.rs).delete_channelnow owns its semantics instead of delegating:channel \x` not found in catalog`;channel \x` is attached to service `owner`; delete it from there` (deletion must not steal another service's channel);Both the service definition and the catalog are persisted. The
SERVICE_CHANNEL_DELETEdispatch is unchanged, so deletion still withdraws the endpoint.TUI (
crates/cli/src/app/service_dialog.rs,ui.rs).don the channel list arms the delete confirmation for an unattached catalog row too. Editing is still restricted to channels attached to this service — the delete path is the only one that admits an unattached row. Channels owned by another service are refused with an explanatory note instead of silence. The confirm prompt and the result note say "catalog" for an unattached channel rather than claiming a withdrawal that never happened, and the existingrefresh_servicesre-reads the catalog so the row disappears. The edit-mode footer now mentionsd delete channel.The diff is deliberately localized to deletion — no changes to field indices, the field list, or channel-list navigation.
Tests
cargo test -p construct-daemon --lib— 530 passed. Newdeleting_a_channel_removes_it_from_the_catalogcovers all four branches;service_put_preserves_channels_and_channel_crud_rotates_credentialsnow also asserts the catalog is empty after delete;channel_catalog_migrates_and_controls_exclusive_attachmentswas asserting the old "delete leaves it in the catalog, detached" behavior and now callsdetach_channelfor that step, which is what it was actually testing.cargo test -p construct-cli— 1318 passed. Newunattached_catalog_channels_can_be_deleted_but_owned_ones_cannot.No spec file added (a sibling branch is adding one in this area).