Skip to content

feat(update-dialog): Slack sign-in button with background polling - #130

Merged
StephenTangCook merged 11 commits into
mainfrom
claude/slack-signin-poll
Jul 1, 2026
Merged

feat(update-dialog): Slack sign-in button with background polling#130
StephenTangCook merged 11 commits into
mainfrom
claude/slack-signin-poll

Conversation

@StephenTangCook

Copy link
Copy Markdown
Contributor

What

Under the "Connect your Slack account to edit your own messages" prompt in the update dialog (user-token path only), surface a real Sign in with Slack button.

  • Opens the OAuth URL in a new tab (window.open, guarded by the existing isSafeHref).
  • Background-polls loadSendAsUserStatus every 2.5s so the dialog unlocks itself the moment sign-in completes, rather than relying solely on the existing window-focus refresh.
  • Shows a spinner ("Waiting for Slack…") and disables the button while polling.
  • Retry cap: 24 polls (~1 min), then stops. Interval is cleared on success, dialog close, and unmount.

Tests

Added test/update-dialog-signin.test.tsx:

  • Opens OAuth and unlocks once the status flips to connected.
  • Stops polling after the retry cap when sign-in never completes.

Full suite: 361 passing. Typecheck + biome clean.

Notes

  • Scoped to the update dialog only. send-dialog.tsx has the same "Sign in with Slack" link but still relies on focus-refresh — can mirror this there if wanted.

🤖 Generated with Claude Code

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
block-kitchen 949f8c5 Commit Preview URL

Branch Preview URL
Jul 01 2026, 07:27 PM

@StephenTangCook
StephenTangCook force-pushed the claude/slack-signin-poll branch from 8b818ce to 37e9d53 Compare July 1, 2026 18:22
StephenTangCook and others added 5 commits July 1, 2026 11:34
Under the "Connect your Slack account to edit your own messages" prompt,
surface a real "Sign in with Slack" button (user-token path only). It opens
the OAuth URL in a new tab and background-polls loadSendAsUserStatus every
2.5s so the dialog unlocks itself the moment sign-in completes, instead of
relying solely on the window-focus refresh.

Shows a spinner while polling, disables the button meanwhile, and caps at
24 polls (~1 min). The interval is cleared on success, dialog close, and
unmount.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…tton

Both SendDialog and UpdateDialog duplicated the same user-token plumbing
(status state, ref-to-latest loader, refresh, window-focus refresh). Pull it
into a single useSlackSignIn hook alongside a SlackSignInButton component in
slack-sign-in.tsx, and consume it from both dialogs.

Also gives SendDialog the same background OAuth polling + spinner that
UpdateDialog had: its "Sign in with Slack" affordance is now the shared button
that opens the OAuth tab and polls until the token appears (capped ~1 min).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Restructure each recent-message row into the Slack message layout: a small
square avatar (message iconUrl when it's a safe image, else an initial
square), the author name with the You/Bot badge beside it, then the date
with the (timestamp) in parens, then the message snippet in regular
foreground text. The snippet prefers the host's `label`, falling back to the
first header/section text or a block count.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Clicking a recent-message preview now selects it (highlighted, aria-pressed)
instead of loading immediately; the footer "Load message" button performs the
load. Selection and the pasted link are mutually exclusive — typing a link
clears the selection and vice versa — and the button enables when either is
present.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace the two-block sampleBlocks() with a realistic multi-block message
(header, byline context, formatted body with image accessory, code snippet,
action row, footer) and give each seed a descriptive title, so the editor and
previews have something substantial to render.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@StephenTangCook
StephenTangCook force-pushed the claude/slack-signin-poll branch from 37e9d53 to 5f962d8 Compare July 1, 2026 18:34
StephenTangCook and others added 6 commits July 1, 2026 11:39
Point the demo's mock oauthUrl at a new public/mock-oauth.html page that sets
a localStorage flag, and have loadSendAsUserStatus poll that flag. Now the full
loop works end to end: uncheck "User can edit their own messages", open the Send
or Edit dialog, click "Sign in with Slack" (the mock page opens and "completes"
sign-in), and the dialog's background poll unlocks it. Clearing the flag on
mount and when the box is re-unchecked keeps the flow repeatable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The "Open as a new message instead" button only makes sense when the
not-editable verdict carries blocks to carry over. A no-match verdict has
none, so there is nothing to open. Gate the button on blocks being present, so
a "No message matched that link." result shows only its reason. Also trim the
demo's no-match reason to just that sentence.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The selected recent-message row used a non-inset ring, which the list's
overflow-y-auto clipped at the corners. Switch the selected state (and the
focus ring) to inset rings and pair a primary border with a 1px inset ring for
a clean, uniform outline that renders fully inside the scroll area.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Reframe the edit-mode entry as "find an existing message": the dialog title
becomes "Find an existing message", the footer confirm button and the toolbar
entry button (loadButtonLabel default) become "Find message". Updates the docs,
story, tests, and demo copy to match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Let the not-editable LoadResult verdict carry an optional oauthUrl. When the
host returns it (e.g. the user pasted their own message but has no user token),
the find dialog renders the shared "Sign in with Slack" button: it opens the
OAuth tab and re-checks the load on an interval (capped ~1 min), advancing into
edit mode once the host reports the message editable.

The demo's onLoadMessage now gates the user's own messages up front — returning
that verdict with the mock oauthUrl when there's no token — so pasting a
self-message link offers the sign-in link instead of loading a message that
can't be updated without re-auth.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Float a copy button in the top-right corner of the Block Kit JSON code pane.
Clicking it writes the current JSON to the clipboard and swaps the icon to a
checkmark for ~2s. Clipboard failures (insecure context / denied) are a no-op.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@StephenTangCook
StephenTangCook merged commit cf2bb4b into main Jul 1, 2026
13 checks passed
@StephenTangCook
StephenTangCook deleted the claude/slack-signin-poll branch July 1, 2026 19:35
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.

1 participant