summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFrank <[email protected]>2025-10-10 21:21:55 -0400
committerFrank <[email protected]>2025-10-10 21:21:55 -0400
commitc7dfbbeed0e7b5a7421b4b0d8c115a24f5ba7534 (patch)
tree4c3b1bc79686c8d448de45f7aea4569c4f5b1a1c
parentb946fd21b18184a61a2d62e073a18a0850866801 (diff)
downloadopencode-c7dfbbeed0e7b5a7421b4b0d8c115a24f5ba7534.tar.gz
opencode-c7dfbbeed0e7b5a7421b4b0d8c115a24f5ba7534.zip
wip: zen
-rw-r--r--packages/console/core/src/user.ts20
-rw-r--r--packages/console/mail/emails/components.tsx4
-rw-r--r--packages/console/mail/emails/templates/InviteEmail.tsx60
-rw-r--r--packages/console/mail/emails/templates/static/logo.pngbin0 -> 1726 bytes
4 files changed, 51 insertions, 33 deletions
diff --git a/packages/console/core/src/user.ts b/packages/console/core/src/user.ts
index 63877150e..40d74f93d 100644
--- a/packages/console/core/src/user.ts
+++ b/packages/console/core/src/user.ts
@@ -11,6 +11,7 @@ import { Account } from "./account"
import { AccountTable } from "./schema/account.sql"
import { Key } from "./key"
import { KeyTable } from "./schema/key.sql"
+import { WorkspaceTable } from "./schema/workspace.sql"
export namespace User {
const assertNotSelf = (id: string) => {
@@ -115,6 +116,21 @@ export namespace User {
// send email, ignore errors
try {
+ const emailInfo = await Database.use((tx) =>
+ tx
+ .select({
+ email: AccountTable.email,
+ workspaceName: WorkspaceTable.name,
+ })
+ .from(UserTable)
+ .innerJoin(AccountTable, eq(UserTable.accountID, AccountTable.id))
+ .innerJoin(WorkspaceTable, eq(WorkspaceTable.id, workspaceID))
+ .where(
+ and(eq(UserTable.workspaceID, workspaceID), eq(UserTable.id, Actor.assert("user").properties.userID)),
+ )
+ .then((rows) => rows[0]),
+ )
+
const { InviteEmail } = await import("@opencode-ai/console-mail/InviteEmail.jsx")
await AWS.sendEmail({
to: email,
@@ -122,8 +138,10 @@ export namespace User {
body: render(
// @ts-ignore
InviteEmail({
+ inviter: emailInfo.email,
assetsUrl: `https://opencode.ai/email`,
- workspace: workspaceID,
+ workspaceID: workspaceID,
+ workspaceName: emailInfo.workspaceName,
}),
),
})
diff --git a/packages/console/mail/emails/components.tsx b/packages/console/mail/emails/components.tsx
index d030b6cbf..ff845c8f4 100644
--- a/packages/console/mail/emails/components.tsx
+++ b/packages/console/mail/emails/components.tsx
@@ -31,6 +31,10 @@ export function A({ children, ...props }: AProps) {
return React.createElement("a", props, children)
}
+export function B({ children, ...props }: AProps) {
+ return React.createElement("b", props, children)
+}
+
export function Span({ children, ...props }: SpanProps) {
return React.createElement("span", props, children)
}
diff --git a/packages/console/mail/emails/templates/InviteEmail.tsx b/packages/console/mail/emails/templates/InviteEmail.tsx
index 978080a9c..5c9630224 100644
--- a/packages/console/mail/emails/templates/InviteEmail.tsx
+++ b/packages/console/mail/emails/templates/InviteEmail.tsx
@@ -1,7 +1,7 @@
// @ts-nocheck
import React from "react"
import { Img, Row, Html, Link, Body, Head, Button, Column, Preview, Section, Container } from "@jsx-email/all"
-import { Hr, Text, Fonts, SplitString, Title, A, Span } from "../components"
+import { Hr, Text, Fonts, SplitString, Title, A, Span, B } from "../components"
import {
unit,
body,
@@ -23,17 +23,24 @@ const CONSOLE_URL = "https://opencode.ai/"
const DOC_URL = "https://opencode.ai/docs/zen"
interface InviteEmailProps {
- workspace: string
+ inviter: string
+ workspaceID: string
+ workspaceName: string
assetsUrl: string
}
-export const InviteEmail = ({ workspace, assetsUrl = LOCAL_ASSETS_URL }: InviteEmailProps) => {
- const subject = `Join the ${workspace} workspace`
- const messagePlain = `You've been invited to join the ${workspace} workspace in the OpenCode Zen Console.`
- const url = `${CONSOLE_URL}workspace/${workspace}`
+export const InviteEmail = ({
+ inviter = "[email protected]",
+ workspaceID = "wrk_01K6XFY7V53T8XN0A7X8G9BTN3",
+ workspaceName = "anomaly",
+ assetsUrl = LOCAL_ASSETS_URL,
+}: InviteEmailProps) => {
+ const subject = `You were invited to the OpenCode Console`
+ const messagePlain = `${inviter} invited you to join the ${workspaceName} workspace (${workspaceID}).`
+ const url = `${CONSOLE_URL}workspace/${workspaceID}`
return (
<Html lang="en">
<Head>
- <Title>{`OpenCode Zen — ${messagePlain}`}</Title>
+ <Title>{`OpenCode — ${messagePlain}`}</Title>
</Head>
<Fonts assetsUrl={assetsUrl} />
<Preview>{messagePlain}</Preview>
@@ -42,15 +49,10 @@ export const InviteEmail = ({ workspace, assetsUrl = LOCAL_ASSETS_URL }: InviteE
<Section style={frame}>
<Row>
<Column>
- <A href={CONSOLE_URL}>
- <Img height="32" alt="OpenCode Zen Logo" src={`${assetsUrl}/zen-logo.png`} />
+ <A href={`${CONSOLE_URL}zen`}>
+ <Img height="32" alt="OpenCode Logo" src={`${assetsUrl}/logo.png`} />
</A>
</Column>
- <Column align="right">
- <Button style={buttonPrimary} href={url}>
- <Span style={code}>Join Workspace</Span>
- </Button>
- </Column>
</Row>
<Row style={headingHr}>
@@ -59,32 +61,26 @@ export const InviteEmail = ({ workspace, assetsUrl = LOCAL_ASSETS_URL }: InviteE
</Column>
</Row>
- <Section>
- <Text style={{ ...compactText, ...breadcrumb }}>
- <Span>OpenCode Zen</Span>
- <Span style={{ ...code, ...breadcrumbColonSeparator }}>:</Span>
- <Span>{workspace}</Span>
- </Text>
- <Text style={{ ...heading, ...compactText }}>
- <Link href={url}>
- <SplitString text={subject} split={40} />
- </Link>
- </Text>
- </Section>
<Section style={{ padding: `${unit}px 0 0 0` }}>
<Text style={{ ...compactText }}>
- You've been invited to join the{" "}
+ <B>{inviter}</B> invited you to join the{" "}
<Link style={medium} href={url}>
- {workspace}
+ <B>{workspaceName}</B>
</Link>{" "}
- workspace in the{" "}
- <Link style={medium} href={CONSOLE_URL}>
- OpenCode Zen Console
+ workspace ({workspaceID}) in the{" "}
+ <Link style={medium} href={`${CONSOLE_URL}zen`}>
+ OpenCode Console
</Link>
.
</Text>
</Section>
+ <Section style={{ padding: `${unit}px 0 0 0` }}>
+ <Button style={buttonPrimary} href={url}>
+ <Span style={code}>Join Workspace</Span>
+ </Button>
+ </Section>
+
<Row style={headingHr}>
<Column>
<Hr />
@@ -93,7 +89,7 @@ export const InviteEmail = ({ workspace, assetsUrl = LOCAL_ASSETS_URL }: InviteE
<Row>
<Column>
- <Link href={CONSOLE_URL} style={footerLink}>
+ <Link href={`${CONSOLE_URL}zen`} style={footerLink}>
Console
</Link>
</Column>
diff --git a/packages/console/mail/emails/templates/static/logo.png b/packages/console/mail/emails/templates/static/logo.png
new file mode 100644
index 000000000..1d4a39639
--- /dev/null
+++ b/packages/console/mail/emails/templates/static/logo.png
Binary files differ