Skip to content

feat(brain): add /brain Slack-first onboarding entry#1310

Open
MaheshtheDev wants to merge 4 commits into
mainfrom
mahesh/eng-1057-company-slack-onboarding-v2
Open

feat(brain): add /brain Slack-first onboarding entry#1310
MaheshtheDev wants to merge 4 commits into
mainfrom
mahesh/eng-1057-company-slack-onboarding-v2

Conversation

@MaheshtheDev

Copy link
Copy Markdown
Member

New /brain route creates the org straight from signup and redirects into the Slack install, so onboarding has no domain-confirmation step. Returning from OAuth shows an Open Slack handoff instead of a toast.

Also models the terminal research error state: polling stops, the UI retries once, and the docked header no longer gates Continue on research finishing.

New /brain route creates the org straight from signup and redirects into the Slack install, so onboarding has no domain-confirmation step. Returning from OAuth shows an Open Slack handoff instead of a toast.

Also models the terminal research error state: polling stops, the UI retries once, and the docked header no longer gates Continue on research finishing.
@linear-code

linear-code Bot commented Jul 18, 2026

Copy link
Copy Markdown

ENG-1057

@cloudflare-workers-and-pages

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

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

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

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
supermemory-mcp a8ed5af Jul 19 2026, 07:07 AM

@cloudflare-workers-and-pages

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

Copy link
Copy Markdown

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
supermemory-app a8ed5af Commit Preview URL

Branch Preview URL
Jul 19 2026, 07:08 AM

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add the label Main to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Drops comments that restated the code and compresses the rest.
@MaheshtheDev
MaheshtheDev marked this pull request as ready for review July 18, 2026 21:02
@claude

claude Bot commented Jul 18, 2026

Copy link
Copy Markdown

Claude finished @MaheshtheDev's task in 1m 32s —— View job


Review Complete

  • Fetch PR diff and existing review comments
  • Analyze changed files for bugs, security issues, and logic errors
  • Review boundary code not in the diff
  • Submit review with findings

Result: No issues found — this PR is ready to ship.

All previously flagged concerns from earlier reviews have been addressed in the latest commits:

  • Container tag now uses SHARED_TEAM_BRAIN_TAG
  • Retry logic uses attempt state to prevent race conditions
  • Failed restart requests properly transition to exhausted state

Score: 10/10

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview: Adds a Slack-first /brain onboarding flow that auto-creates the org on signup and redirects to Slack install, plus models the terminal research error state with a one-shot retry.

Issues found: None — this looks good to ship.

The implementation is solid:

  • brain/page.tsx: The flow correctly handles both existing-org and new-org cases. The startedRef pattern prevents double execution in StrictMode/effects. Error states are surfaced to the user with a retry button.
  • Retry logic (company-brain-onboarding.tsx): The ref-based state machine (idle → started → rerunning → exhausted) is a clean way to prevent infinite retries while keeping the effect dependency-free on the stage value.
  • Error status (use-research-status.ts): Adding "error" as a terminal status correctly stops polling. The other consumer (research-action-rail.tsx) only uses events, not status, so it's unaffected.
  • URL cleanup: The ?slack=connected params are properly stripped via history.replaceState to prevent issues on refresh.
  • SlackHandoff: Uses the standard slack://open deep link with a sensible browser fallback.

The decision to ungated the "Continue" button from research completion is a good UX call — users shouldn't be blocked if the backend research hits a terminal error.

Score: 10/10

Comment thread apps/web/app/(app)/brain/page.tsx Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8b66995516

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/web/app/(app)/brain/page.tsx Outdated
Comment thread apps/web/app/(app)/brain/page.tsx Outdated
Comment thread apps/web/components/onboarding-brain/company-brain-onboarding.tsx Outdated
@polylane

polylane Bot commented Jul 18, 2026

Copy link
Copy Markdown

Note

Production impact unlikely.

Latest commit (a8ed5af) is a pure refactor: destructures email from user, narrows run()'s deps. No behavior or production-resource changes; all backend calls remain the same additive paths.


view-investigation review-in-polylane disable-pr-reviews

Polylane analysed a8ed5af for production impact.

Records SHARED_TEAM_BRAIN_TAG instead of a workspace slug, so Slack ingestion writes where the Company Brain UI actually reads.

Makes the effect the sole caller of the entry flow so a dep change mid-retry can't create a second org, and treats a failed research restart as exhausted instead of showing "Retrying research…" forever.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview: Adds a Slack-first /brain onboarding flow that auto-creates the org on signup and redirects to Slack install, plus models the terminal research error state with a one-shot retry.

Issues found: None — the latest commit (c94e5ce) has addressed all previously flagged concerns:

  • Container tag: Now correctly uses SHARED_TEAM_BRAIN_TAG instead of a workspace-derived tag, ensuring Company Brain queries find the right space
  • Retry race condition: The retry button now increments attempt state to trigger the effect instead of calling run() directly, eliminating the race where both could execute simultaneously
  • Failed restart handling: The retry logic properly checks res.ok and transitions to exhausted state if the restart request fails, preventing the "Retrying research…" message from displaying indefinitely

The implementation is clean:

  • startedRef guard is set before run() executes, so dependency changes mid-flight can't kick off duplicate org creation
  • The ref-based state machine (idle → started → rerunning → exhausted) handles retry transitions correctly
  • Polling stops on both done and error terminal states
  • URL params are properly cleaned up via history.replaceState

Score: 10/10

Comment thread apps/web/app/(app)/brain/page.tsx
Destructures email per the repo style rule, which lets run() depend on the primitive instead of the user object so it stays stable across auth refetches.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview: Adds a Slack-first /brain onboarding flow that auto-creates the org on signup and redirects to Slack install, plus models the terminal research error state with a one-shot retry.

Issues found: None — this looks good to ship.

The latest commit (a8ed5af) has all previously flagged concerns addressed:

  • Container tag: Correctly uses SHARED_TEAM_BRAIN_TAG at brain/page.tsx:69, ensuring Company Brain queries find the right space
  • Retry race condition: The retry button increments attempt state (page.tsx:119) to trigger the effect instead of calling run() directly — the startedRef guard is set before execution, so dependency changes mid-flight can't spawn duplicate org creation
  • Failed restart handling: The retry logic checks res.ok (company-brain-onboarding.tsx:148-152) and properly transitions to exhausted state if the restart request fails
  • Polling termination: use-research-status.ts correctly stops polling on both done and error terminal states

The state machine (idle → started → rerunning → exhausted) handles all transitions correctly, URL params are cleaned up via history.replaceState, and the SlackHandoff component uses standard deep linking with a sensible browser fallback.

Score: 10/10

Comment thread apps/web/components/onboarding-brain/company-brain-onboarding.tsx
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