Skip to content

slack-leave-devopsinc: leave PagerDuty incident channels on demand (CLI + Spotlight app) - #57

Closed
kriswill wants to merge 3 commits into
mainfrom
claude/eager-albattani-ugsvje
Closed

kriswill wants to merge 3 commits into
mainfrom
claude/eager-albattani-ugsvje

Conversation

@kriswill

@kriswill kriswill commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

Replaces the keystroke-driven leave-devopsinc.applescript with a Slack Web API tool you can launch from Spotlight. It finds the channels by itself, so you don't type channel numbers, Slack doesn't need focus, and no Accessibility permission is required.

  • pkgs/slack-leave-devopsinc.{sh,nix}: a writeShellApplication (curl, jq). It pages through users.conversations (public and private channels, archived ones excluded), keeps names matching devopsinc-<digits> with N ≥ 1000 (the same guard as the original script), and calls conversations.leave on each. If one channel fails (e.g. last_member), it reports that and carries on; exit status is 1 at the end. curl --retry 5 waits out 429s using Retry-After. Flags: -n/--dry-run, --notify.
  • Token: a Slack user token (xoxp-…) from $SLACK_LEAVE_TOKEN, or else the login Keychain item slack-leave-devopsinc. It is passed to curl via printf | curl --config -, the same way cbissue does it, so it never appears in argv.
  • Spotlight: the same derivation ships Applications/Leave devopsinc Channels.app. It's an LSUIElement bundle (no Dock icon) whose executable is a makeBinaryWrapper that runs the CLI with --notify, so the result shows up as a macOS notification.
  • modules/darwin/slack-leave-devopsinc.nix: universal (all Macs). It uses environment.systemPackages because nix-darwin only copies systemPackages apps into /Applications/Nix Apps, which Spotlight indexes.
  • Wired through modules/packages.nix (aarch64-darwin guard) and overlays/ + modules/overlays.nix.
  • Knowledge bundle: package and module catalog docs, a decision record (decisions/slack-leave-devopsinc-api.md), and log entries. okf validate passes with 0 errors and 0 warnings.

One-time setup (per Mac)

  1. In your workspace, create a Slack app at api.slack.com/apps and add the User Token Scopes channels:read, groups:read, channels:write, groups:write. Install it (or "Request to Install" if the workspace needs admin approval) and copy the User OAuth Token (xoxp-…).
  2. security add-generic-password -U -a "$USER" -s slack-leave-devopsinc -w (paste the token at the prompt).
  3. Rebuild, then run slack-leave-devopsinc -n for a dry run, or open Spotlight and run "Leave devopsinc Channels".

Test plan

  • ShellCheck 0.11 clean, both standalone and through writeShellApplication's build-time check
  • Built the derivation against the locked nixpkgs (x86_64-linux with the platform check relaxed). Bundle layout, Info.plist, binary wrapper (--notify) and the bin/ link all look right.
  • Mocked Slack API (fake curl, security and osascript): pagination via cursor; filtering skips devopsinc-999, devopsinc-abc, devopsinc-1500-old and general; a last_member failure is reported and the other leaves still go through (exit 1); missing_scope names the scope it needs; no-matches exits 0; a missing token and a curl transport failure both fail cleanly; notifications fire only with --notify, with the message passed as an argv item.
  • Checked scopes, error codes and limit against Slack's OpenAPI spec. users.conversations is sent as GET (-G), as the spec lists it.
  • nixfmt / statix / deadnix clean on the new files
  • CI darwin-k build (the first real darwin build of the package) and nixos-nebula: green
  • On a Mac (k): Slack app created from a manifest with the four user scopes and installed after admin approval; token stored in the Keychain; nrs rebuild put the CLI on PATH and the app in /Applications/Nix Apps
  • Live run: -n listed 43 devopsinc-N channels (1473 to 1520) and nothing else; the real run left all 43 with no failures; a dry run afterwards reports none left
  • Spotlight launch of "Leave devopsinc Channels" (nothing left to leave yet; try it on the next incident channel)

https://claude.ai/code/session_01PZ3r25VNh276wrx6Z1GwRS

Summary by CodeRabbit

  • New Features
    • Added a macOS tool, available from Spotlight, to find and leave eligible devopsinc-1000 and higher Slack channels.
    • Supports a dry run, uses a Slack token from the login Keychain or an environment variable, and reports results with macOS notifications.
    • Added setup and usage documentation.

claude added 3 commits October 2, 2026 17:19
New darwin package + universal module. The CLI finds every Slack
channel named devopsinc-N (N >= 1000) that you're in, via
users.conversations, and leaves each one with conversations.leave. This
replaces the AppleScript that drove Slack.app's Cmd+K switcher, which
needed channel numbers by hand, a focused Slack window and Accessibility
permission.

- pkgs/slack-leave-devopsinc.{sh,nix}: writeShellApplication (curl, jq).
  It reads a Slack user token from $SLACK_LEAVE_TOKEN or the login
  Keychain item "slack-leave-devopsinc". curl --retry handles 429s. The
  package also ships "Leave devopsinc Channels.app", an LSUIElement
  bundle whose executable is a makeBinaryWrapper around the CLI with
  --notify, which reports the result as a macOS notification.
- modules/darwin/slack-leave-devopsinc.nix: adds the package to
  environment.systemPackages on all Macs. Only systemPackages apps are
  copied into /Applications/Nix Apps, where Spotlight indexes them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PZ3r25VNh276wrx6Z1GwRS
Package and module catalog docs; a decision record covering why the
PagerDuty incident channels are left via the Slack Web API (Keychain user
token, Spotlight .app with a binary-wrapper executable, systemPackages for
/Applications/Nix Apps) rather than the keystroke-driven AppleScript; log
entries in the packages/modules/decisions bundles; regenerated indexes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PZ3r25VNh276wrx6Z1GwRS
Resolves the knowledge/modules/log.md conflict: both sides added
2026-10-02 entries; kept main's two noctalia/nh updates and this
branch's slack-leave-devopsinc creation under the same date heading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PZ3r25VNh276wrx6Z1GwRS
@kriswill
kriswill marked this pull request as ready for review October 5, 2026 17:00
@coderabbitai

coderabbitai Bot commented Oct 5, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0cd4bb23-ec9e-44b6-9078-d2b411cfb8cf
📥 Commits

Reviewing files that changed from the base of the PR and between 0c46c88 and 96f10ab.

📒 Files selected for processing (15)
  • knowledge/decisions/index.md
  • knowledge/decisions/log.md
  • knowledge/decisions/slack-leave-devopsinc-api.md
  • knowledge/modules/index.md
  • knowledge/modules/log.md
  • knowledge/modules/slack-leave-devopsinc.md
  • knowledge/packages/index.md
  • knowledge/packages/log.md
  • knowledge/packages/slack-leave-devopsinc.md
  • modules/darwin/slack-leave-devopsinc.nix
  • modules/overlays.nix
  • modules/packages.nix
  • overlays/slack-leave-devopsinc.nix
  • pkgs/slack-leave-devopsinc.nix
  • pkgs/slack-leave-devopsinc.sh
 __________________________________________
< Dollars to donuts, you didn't test this. >
 ------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@kriswill

kriswill commented Oct 5, 2026

Copy link
Copy Markdown
Owner Author

Landed on main as 3c4635e and 4d7a775.

@kriswill kriswill closed this Oct 5, 2026
@kriswill
kriswill deleted the claude/eager-albattani-ugsvje branch October 5, 2026 17:02
kriswill added a commit that referenced this pull request Oct 11, 2026
flake update pulled snowglobe-factory b50cb59 -> eb2429a1, whose debloat
series broke `nrs`:

- nix-tools profile deleted (b0a0d97b): inline its packages (nurl,
  nix-prefetch-git, deadnix, nixpkgs-hammering, statix, nix-init, nix-update,
  nixpkgs-review, nixfmt) in the host config, beside the hardware-tools inline.
- neovim no longer force-enabled, vim now on by default (dd10b7e0): pin
  programs.vim.enable = false in modules/nixos/neovim.nix so the vim -> nvim
  alias doesn't collide.
- bat, ripgrep, lazygit, yazi, jq, zip, brightnessctl and nix-index-database/
  comma flipped off (1f9de238) and the nix-index-database input dropped; the
  stow zsh/git/nvim/Hyprland configs call them by name. New
  modules/nixos/user-packages.nix (NixOS twin of the darwin one) re-enables
  them and imports a new nix-index-database flake input for the prebuilt
  command-not-found db + comma-with-db.

nixpkgs also bumped diffnav to 0.13.0, whose bubbletint theming replaced the
`Foreground(lipgloss.White)` the footer-pill postPatch targeted. The patch is
obsolete (bubbletint's kanagawabones keeps ANSI 8 dark), so drop
overlays/diffnav.nix and set ui.theme: kanagawabones in home/diffnav.

knowledge: catalog/log entries, user-packages doc now Dual Module, diffnav
overlay doc removed, nix-output-monitor overlay stub scaffolded.

nvd diff /run/booted-system -> new (ruby3.4-* and library dedup elided):

    Version changes:
    [U*]  #1  1password                       8.12.36 -> 8.12.38
    [U.]  #2  7zz                             26.02, 26.02-lib -> 26.04, 26.04-lib
    [U.]  #8  aquamarine                      0.15.1+date=2026-09-17_f31c47a -> 0.15.1+date=2026-10-03_52ea11f, 0.15.1+date=2026-10-03_52ea11f-dev
    [U*]  #14  bash-language-server            5.6.0 -> 5.8.1
    [U*]  #18  biome                           2.5.14 -> 2.5.15
    [U.]  #24  cgif                            0.5.3 -> 0.5.4
    [U.]  #25  chafa                           1.18.2, 1.18.2-bin -> 1.18.3, 1.18.3-bin
    [U.]  #26  chromium                        154.0.8037.92, 154.0.8037.92-sandbox -> 155.0.8059.39, 155.0.8059.39-sandbox
    [U*]  #39  delta                           0.19.2 -> 0.20.1
    [U*]  #40  determinate-nix                 3.23.0 x2, 3.23.0-doc, 3.23.0-man -> 3.23.1 x2, 3.23.1-doc, 3.23.1-man
    [U*]  #49  determinate-nixd                3.23.0 -> 3.23.1
    [U*]  #50  diffnav                         0.12.0 -> 0.13.0
    [U*]  #51  discord                         1.0.159, 1.0.159-bwrap, 1.0.159-fhsenv-profile, 1.0.159-fhsenv-rootfs, 1.0.159-init -> 1.0.160, 1.0.160-bwrap, 1.0.160-fhsenv-profile, 1.0.160-fhsenv-rootfs, 1.0.160-init
    [U.]  #56  egl-wayland                     1.1.22 x2 -> 1.1.23 x2
    [U.]  #57  electron                        43.6.0 -> 43.7.7
    [U.]  #063  fastfetch                       2.68.1 -> 2.69.0
    [U*]  #080  git-lfs                         3.7.1 -> 3.8.0
    [U.]  #096  gumbo                           0.13.2 -> 0.14.1
    [U*]  #099  hwinfo                          25.5, 25.5-bin, 25.5-lib -> 26.0, 26.0-bin, 26.0-lib
    [U.]  #100  hyprgraphics                    0.5.1+date=2026-08-11_7c895c4 -> 0.5.1+date=2026-10-03_80c7d00, 0.5.1+date=2026-10-03_80c7d00-dev
    [U*]  #101  hyprland                        0.56.0+date=2026-10-01_586c01e, 0.56.0+date=2026-10-01_586c01e-man -> 0.56.0+date=2026-10-09_663b29b, 0.56.0+date=2026-10-09_663b29b-man
    [U.]  #105  initrd-linux                    7.2.8 -> 7.2.9
    [U*]  #112  kitty                           0.49.1-terminfo -> 0.49.2-terminfo
    [U*]  #116  lazygit                         0.65.1 -> 0.66.0
    [U.]  #181  libqalculate                    5.12.0 -> 5.13.1
    [U.]  #189  libslirp                        4.9.3 -> 4.9.5
    [U*]  #206  libvirt                         12.7.0 -> 12.8.0
    [U.]  #212  libwmf                          0.2.15 -> 0.2.16
    [U.]  #243  linux                           7.2.8, 7.2.8-modules x2 -> 7.2.9, 7.2.9-modules x2
    [U*]  #249  ly                              1.4.1 -> 1.5.0
    [U.]  #256  mesa                            26.2.3 x2 -> 26.2.4 x2
    [U*]  #258  metasploit-framework            6.5.3 -> 6.5.6
    [U.]  #270  nixos-system-nebula             26.11.20261001.c59305b -> 26.11.20261010.6510408
    [U*]  #271  nixpkgs-hammering               0-unstable-2026-08-10 -> 0-unstable-2026-10-04
    [U.]  #272  noto-fonts                      2026.09.01 -> 2026.10.01
    [U.]  #274  nvidia-open                     595.104.02-7.2.8 -> 595.104.02-7.2.9
    [U.]  #279  opensnitch_ebpf                 1.8.0-7.2.8 -> 1.8.0-7.2.9
    [U.]  #294  python3.14-libvirt-python       12.7.0 -> 12.8.0
    [U*]  #337  rumdl                           0.2.77 -> 0.2.78
    [U*]  #338  rust-analyzer                   2026-09-21 -> 2026-09-28
    [U.]  #342  sdl12-compat                    1.2.76 x2 -> 1.2.78 x2
    [D.]  #360  tauri-asset-gst-plugin          0.1.0 -> 0.0.1
    [U.]  #362  tcpdump                         4.99.6 -> 4.99.7
    [U*]  #363  thunderbird                     156.0.1 -> 157.0.1
    [U*]  #367  tor                             0.4.9.13 -> 0.4.9.14
    [U.]  #376  vips                            8.18.6 -> 8.18.7
    [U*]  #380  wdisplays                       1.1.3 -> 1.3.0
    [U.]  #381  webkitgtk                       2.54.0+abi=4.1 -> 2.54.1+abi=4.1
    [U*]  #385  xdg-desktop-portal-hyprland     1.4.1+date=2026-08-29_ba31964 -> 1.4.1+date=2026-09-22_e87ae78
    [U*]  #389  xwayland                        24.1.13 x2 -> 24.1.14 x2
    [U.]  #391  yq-go                           4.53.3 -> 4.54.1
    Added packages:
    [A.]  #1  51-astro-mixamp-priority.conf              <none>
    [A.]  #2  login.pam                                  <none>
    Removed packages:
    [R-]  #1  SwayNotificationCenter        0.12.6
    [R.]  #2  etc-direnv-direnvrc           <none>
    [R.]  #3  etc-direnv-lib-zz-user.sh     <none>
    [R.]  #4  granite                       7.8.1
    [R.]  #5  gvfs                          1.60.3
    [R.]  #6  libcdio-paranoia              2.0.2
    [R.]  #7  libnfs                        6.0.2
    [R.]  #8  libshumate                    1.6.3
    [R.]  #14  unit-swaync.service           <none>
    [R.]  #15  yash                          2.61
    Closure size: 3456 -> 3144 (364 paths added, 676 paths removed, delta -312, disk usage -1.2GiB).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants