An open-source, faster Devin alternative
TypeScript
Computer: keep a failed Slack install on the page
Slack U06H7D98X408ce66fc6a8f6
diff --git a/web/src/managed-agents/Computer.test.tsx b/web/src/managed-agents/Computer.test.tsxindex 466be8d3..2d59eb49 100644--- a/web/src/managed-agents/Computer.test.tsx+++ b/web/src/managed-agents/Computer.test.tsx@@ -291,6 +291,36 @@ describe('Computer page', () => {expect(location()).toBe('/computer')})+ it('keeps a failed Slack install on the page until dismissed', async () => {+ computerApi.getComputer.mockResolvedValue(provisioning)++ render('/computer?slack=error&reason=oauth_failed')+ await settle(() => location() === '/computer', 'clean URL')+ await settle(+ () =>+ container.querySelector(+ 'section[aria-labelledby="slack-install-failed-title"]',+ ) !== null,+ 'install-failed panel',+ )+ const panel = container.querySelector(+ 'section[aria-labelledby="slack-install-failed-title"]',+ )!+ expect(panel.getAttribute('role')).toBe('alert')+ expect(panel.textContent).toContain('Slack is not connected')+ expect(panel.textContent).toContain(+ "Slack didn't confirm the install. Try again.",+ )+ expect(panel.textContent).toContain('Try again')++ act(() =>+ (+ panel.querySelector('button[aria-label="Dismiss"]') as HTMLButtonElement+ ).click(),+ )+ expect(container.textContent).not.toContain('Slack is not connected')+ })+it('asks for a teammate when nobody could be messaged', async () => {computerApi.getComputer.mockResolvedValue(provisioning)diff --git a/web/src/managed-agents/Computer.tsx b/web/src/managed-agents/Computer.tsxindex 36377781..407fdee8 100644--- a/web/src/managed-agents/Computer.tsx+++ b/web/src/managed-agents/Computer.tsx@@ -22,6 +22,7 @@ import {Send,Sparkles,Terminal,+ TriangleAlert,Unplug,UsersRound,X,@@ -74,6 +75,7 @@ import {slackReturnFromSearch,splitSessions,type ChecklistStep,+ type SlackReturn,} from './computer-state'export default function ComputerPage() {@@ -123,15 +125,17 @@ function ComputerPageContent() {}, [missingAfterInstall, createNow])// Slack's install redirect lands here with ?slack=connected|error. A- // workspace that is another organization's gets a panel, not a toast: the- // person is welcome, they just need an invite. The redirect is a full page- // load, so the panel's state is read once, from the URL it arrived with;- // the effect below then cleans the URL.- const [alreadyLinked, setAlreadyLinked] = useState(() => {+ // failed install gets a panel that stays until dismissed, not a toast that+ // is gone before anyone reads it; a workspace that is another+ // organization's gets its own panel: the person is welcome, they just need+ // an invite. The redirect is a full page load, so the panel's state is read+ // once, from the URL it arrived with; the effect below then cleans the URL.+ const [slackProblem, setSlackProblem] = useState<Exclude<+ SlackReturn,+ { kind: 'connected' } | null+ > | null>(() => {const slackReturn = slackReturnFromSearch(searchParams)- return slackReturn?.kind === 'already_linked'- ? { notified: slackReturn.notified }- : null+ return slackReturn?.kind === 'connected' ? null : slackReturn})const handledSlackReturn = useRef<string | null>(null)useEffect(() => {@@ -142,8 +146,6 @@ function ComputerPageContent() {handledSlackReturn.current = keyif (slackReturn.kind === 'connected') {notifySuccess('Slack is connected.', START_SESSION_COPY)- } else if (slackReturn.kind === 'error') {- notifyError("Couldn't connect Slack.", new Error(slackReturn.message))}void queryClient.invalidateQueries({ queryKey: computerQueryKey })const next = new URLSearchParams(searchParams)@@ -179,19 +181,27 @@ function ComputerPageContent() {const { live, recent } = splitSessions(sessions.data ?? [])const sessionsLoading = hasComputer && sessions.isLoadingconst createError = create.isError ? create.error : null- const alreadyLinkedPanel = alreadyLinked ? (- <AlreadyLinked- notified={alreadyLinked.notified}- status={status.data}- onDismiss={() => setAlreadyLinked(null)}- />- ) : null+ const dismissSlackProblem = () => setSlackProblem(null)+ const slackProblemPanel =+ slackProblem?.kind === 'already_linked' ? (+ <AlreadyLinked+ notified={slackProblem.notified}+ status={status.data}+ onDismiss={dismissSlackProblem}+ />+ ) : slackProblem?.kind === 'error' ? (+ <SlackInstallFailed+ message={slackProblem.message}+ status={status.data}+ onDismiss={dismissSlackProblem}+ />+ ) : null// Once it is in Slack and knows the code, the page is about the work.if (computerIsOnboarded(status.data)) {return (<div className="mx-auto max-w-5xl space-y-8">- {alreadyLinkedPanel}+ {slackProblemPanel}<CompactHeaderstatus={status.data}liveCount={live.length}@@ -224,7 +234,7 @@ function ComputerPageContent() {return (<div className="mx-auto max-w-5xl space-y-6">- {alreadyLinkedPanel}+ {slackProblemPanel}<Herostatus={status.data}createError={createError}@@ -692,6 +702,53 @@ function AlreadyLinked({)}+function SlackInstallFailed({+ message,+ status,+ onDismiss,+}: {+ message: string+ status: ComputerStatus+ onDismiss: () => void+}) {+ return (+ <section+ role="alert"+ aria-labelledby="slack-install-failed-title"+ className="border-destructive/40 bg-destructive/5 relative rounded-2xl border px-8 py-6 sm:px-10"+ >+ <Button+ variant="ghost"+ size="icon"+ className="text-muted-foreground absolute top-3 right-3"+ aria-label="Dismiss"+ onClick={onDismiss}+ >+ <X className="size-4" aria-hidden />+ </Button>+ <div className="flex gap-5">+ <div className="bg-destructive/15 text-destructive flex size-11 shrink-0 items-center justify-center rounded-full">+ <TriangleAlert className="size-5" aria-hidden />+ </div>+ <div className="max-w-2xl min-w-0 pr-8">+ <h2+ id="slack-install-failed-title"+ className="text-lg font-semibold tracking-tight"+ >+ Slack is not connected+ </h2>+ <p className="text-muted-foreground mt-1 text-balance">{message}</p>+ {status.slack.installed ? null : (+ <div className="mt-4">+ <SlackInstallButton label="Try again" />+ </div>+ )}+ </div>+ </div>+ </section>+ )+}+const REASONS = [{icon: MessagesSquare,diff --git a/web/src/managed-agents/computer-state.ts b/web/src/managed-agents/computer-state.tsindex dff75a14..fb72c409 100644--- a/web/src/managed-agents/computer-state.ts+++ b/web/src/managed-agents/computer-state.ts@@ -184,6 +184,13 @@ const SLACK_RETURN_REASONS = new Map<string, string>([['cancelled', 'The Slack install was cancelled.'],['invalid_state', 'The install link expired. Start the install again.'],['state_expired', 'The install link expired. Start the install again.'],+ ['oauth_failed', "Slack didn't confirm the install. Try again."],+ ['slack_error', 'Slack stopped the install. Try again.'],+ [+ 'enterprise_install_unsupported',+ 'Enterprise Grid installs are not supported yet. Install it into a single workspace.',+ ],+ ['not_configured', 'Slack is not available right now. Try again later.'],])/** Reasons that mean the workspace is already another organization's. */