feat(brain): add /brain Slack-first onboarding entry#1310
Conversation
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.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
supermemory-mcp | a8ed5af | Jul 19 2026, 07:07 AM |
Deploying with
|
| 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 |
How to use the Graphite Merge QueueAdd 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.
|
Claude finished @MaheshtheDev's task in 1m 32s —— View job Review Complete
Result: No issues found — this PR is ready to ship. All previously flagged concerns from earlier reviews have been addressed in the latest commits:
Score: 10/10 |
There was a problem hiding this comment.
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
startedRefpattern 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 usesevents, notstatus, so it's unaffected. - URL cleanup: The
?slack=connectedparams are properly stripped viahistory.replaceStateto prevent issues on refresh. - SlackHandoff: Uses the standard
slack://opendeep 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
There was a problem hiding this comment.
💡 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".
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.
There was a problem hiding this comment.
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_TAGinstead of a workspace-derived tag, ensuring Company Brain queries find the right space - ✅ Retry race condition: The retry button now increments
attemptstate to trigger the effect instead of callingrun()directly, eliminating the race where both could execute simultaneously - ✅ Failed restart handling: The retry logic properly checks
res.okand transitions toexhaustedstate if the restart request fails, preventing the "Retrying research…" message from displaying indefinitely
The implementation is clean:
startedRefguard is set beforerun()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
doneanderrorterminal states - URL params are properly cleaned up via
history.replaceState
Score: 10/10
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.
There was a problem hiding this comment.
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_TAGatbrain/page.tsx:69, ensuring Company Brain queries find the right space - Retry race condition: The retry button increments
attemptstate (page.tsx:119) to trigger the effect instead of callingrun()directly — thestartedRefguard 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 toexhaustedstate if the restart request fails - Polling termination:
use-research-status.tscorrectly stops polling on bothdoneanderrorterminal 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

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.