mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 13:05:14 +03:00
fix(tui): add a blank row under the OAuth dialog title (#62929)
This commit is contained in:
committed by
GitHub
Unverified
parent
a17fab50a1
commit
9cb8e65dc0
@@ -766,7 +766,6 @@ function OAuthAuto(props: {
|
||||
>
|
||||
<DialogPrompt
|
||||
title={props.title}
|
||||
subtitle={props.attempt.instructions}
|
||||
placeholder="Redirect URL"
|
||||
onConfirm={paste}
|
||||
actions={[
|
||||
@@ -779,9 +778,7 @@ function OAuthAuto(props: {
|
||||
]}
|
||||
description={() => (
|
||||
<box gap={1}>
|
||||
<Show when={!newDesigns()}>
|
||||
<text fg={theme.text.muted}>{props.attempt.instructions}</text>
|
||||
</Show>
|
||||
<text fg={theme.text.muted}>{props.attempt.instructions}</text>
|
||||
<Link href={props.attempt.url} fg={theme.markdown.link} />
|
||||
<text fg={theme.text.muted}>
|
||||
Waiting for authorization… Press enter to open the link. If the browser can't reach this machine, paste
|
||||
@@ -807,7 +804,6 @@ function OAuthCode(props: {
|
||||
const client = useClient()
|
||||
const toast = useToast()
|
||||
const theme = useTheme().surface("dialog")
|
||||
const newDesigns = useNewDesigns()
|
||||
const [error, setError] = createSignal<string>()
|
||||
let settled = false
|
||||
|
||||
@@ -823,7 +819,6 @@ function OAuthCode(props: {
|
||||
return (
|
||||
<DialogPrompt
|
||||
title={props.title}
|
||||
subtitle={props.attempt.instructions}
|
||||
placeholder="Authorization code"
|
||||
onConfirm={(code) => {
|
||||
if (!code) return
|
||||
@@ -842,9 +837,7 @@ function OAuthCode(props: {
|
||||
}}
|
||||
description={() => (
|
||||
<box gap={1}>
|
||||
<Show when={!newDesigns()}>
|
||||
<text fg={theme.text.muted}>{props.attempt.instructions}</text>
|
||||
</Show>
|
||||
<text fg={theme.text.muted}>{props.attempt.instructions}</text>
|
||||
<Link href={props.attempt.url} fg={theme.markdown.link} />
|
||||
<Show when={error()}>{(value) => <text fg={theme.text.feedback.error.base}>{value()}</text>}</Show>
|
||||
</box>
|
||||
|
||||
@@ -486,3 +486,103 @@ async function renderIntegration(activeLocation?: LocationRef, form?: FormFields
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
test("leaves a blank row between the OAuth title and its instructions under new designs", async () => {
|
||||
await using fixture = await renderOAuth({ paste: true, newDesigns: true })
|
||||
const frame = await fixture.app.waitForFrame((frame) => frame.includes("Redirect URL"))
|
||||
const lines = frame.split("\n")
|
||||
const title = lines.findIndex((line) => line.includes("opensend") && line.includes("esc"))
|
||||
|
||||
expect(lines[title + 1]?.trim()).toBe("")
|
||||
expect(lines[title + 2]).toContain("Authorize opensend in your browser.")
|
||||
})
|
||||
|
||||
test("keeps the OAuth paste prompt layout without new designs", async () => {
|
||||
await using fixture = await renderOAuth({ paste: true, newDesigns: false })
|
||||
const frame = await fixture.app.waitForFrame((frame) => frame.includes("Redirect URL"))
|
||||
const lines = frame.split("\n")
|
||||
const title = lines.findIndex((line) => line.includes("opensend") && line.includes("esc"))
|
||||
|
||||
expect(lines[title + 1]?.trim()).toBe("")
|
||||
expect(lines[title + 2]).toContain("Authorize opensend in your browser.")
|
||||
expect(frame.split("Authorize opensend in your browser.").length).toBe(2)
|
||||
})
|
||||
|
||||
async function renderOAuth(input: { paste?: true; newDesigns: boolean }) {
|
||||
const calls = createFetch(async (url, request) => {
|
||||
const directory = decodeURIComponent(request.headers.get("x-opencode-directory") ?? process.cwd())
|
||||
const location = { directory, project: { id: "proj_test", directory, canonical: directory } }
|
||||
if (url.pathname === "/api/integration")
|
||||
return json({
|
||||
location,
|
||||
data: [
|
||||
{
|
||||
id: "opensend",
|
||||
name: "opensend",
|
||||
methods: [{ type: "oauth", id: "mcp", label: "opensend" }],
|
||||
connections: [],
|
||||
metadata: { source: "mcp" },
|
||||
},
|
||||
],
|
||||
})
|
||||
if (request.method === "POST" && url.pathname === "/api/integration/opensend/connect/oauth")
|
||||
return json({
|
||||
location,
|
||||
data: {
|
||||
attemptID: "att_test",
|
||||
url: "https://opensend.example.com/api/auth/oauth2/authorize?response_type=code",
|
||||
instructions: "Authorize opensend in your browser. This window will close automatically.",
|
||||
mode: "auto",
|
||||
...(input.paste ? { paste: true } : {}),
|
||||
time: { created: Date.now(), expires: Date.now() + 60_000 },
|
||||
},
|
||||
})
|
||||
if (request.method === "DELETE" && url.pathname === "/api/integration/opensend/connect/oauth/att_test")
|
||||
return new Response(null, { status: 204 })
|
||||
if (url.pathname === "/api/integration/opensend/connect/oauth/att_test")
|
||||
return json({ location, data: { status: "pending" } })
|
||||
return undefined
|
||||
})
|
||||
|
||||
function Probe() {
|
||||
const data = useData()
|
||||
const dialog = useDialog()
|
||||
onMount(() => {
|
||||
void data.location.integration
|
||||
.sync()
|
||||
.then(() => dialog.replace(() => <DialogIntegration integrationID="opensend" autoConnect />))
|
||||
})
|
||||
return null
|
||||
}
|
||||
|
||||
const app = await testRender(
|
||||
() => (
|
||||
<TestTuiContexts>
|
||||
<ConfigProvider config={createTuiResolvedConfig({ experimental: { "new-designs": input.newDesigns } })}>
|
||||
<Keymap.Provider>
|
||||
<ToastProvider>
|
||||
<ClientProvider api={createApi(calls.fetch)}>
|
||||
<DataProvider directory={process.cwd()}>
|
||||
<LocationProvider>
|
||||
<ThemeProvider mode="dark" source={emptyThemeSource}>
|
||||
<DialogProvider>
|
||||
<Probe />
|
||||
</DialogProvider>
|
||||
</ThemeProvider>
|
||||
</LocationProvider>
|
||||
</DataProvider>
|
||||
</ClientProvider>
|
||||
</ToastProvider>
|
||||
</Keymap.Provider>
|
||||
</ConfigProvider>
|
||||
</TestTuiContexts>
|
||||
),
|
||||
{ width: 100, height: 30, kittyKeyboard: true },
|
||||
)
|
||||
app.renderer.start()
|
||||
|
||||
return {
|
||||
app,
|
||||
[Symbol.asyncDispose]: async () => app.renderer.destroy(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user