From c7dfbbeed0e7b5a7421b4b0d8c115a24f5ba7534 Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 10 Oct 2025 21:21:55 -0400 Subject: [PATCH] wip: zen --- packages/console/core/src/user.ts | 20 +++++- packages/console/mail/emails/components.tsx | 4 ++ .../mail/emails/templates/InviteEmail.tsx | 60 ++++++++---------- .../mail/emails/templates/static/logo.png | Bin 0 -> 1726 bytes 4 files changed, 51 insertions(+), 33 deletions(-) create mode 100644 packages/console/mail/emails/templates/static/logo.png diff --git a/packages/console/core/src/user.ts b/packages/console/core/src/user.ts index 63877150..40d74f93 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 d030b6cb..ff845c8f 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 978080a9..5c963022 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 = "test@anoma.ly", + 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 ( - {`OpenCode Zen — ${messagePlain}`} + {`OpenCode — ${messagePlain}`} {messagePlain} @@ -42,15 +49,10 @@ export const InviteEmail = ({ workspace, assetsUrl = LOCAL_ASSETS_URL }: InviteE
- - OpenCode Zen Logo + + OpenCode Logo - - - @@ -59,32 +61,26 @@ export const InviteEmail = ({ workspace, assetsUrl = LOCAL_ASSETS_URL }: InviteE -
- - OpenCode Zen - : - {workspace} - - - - - - -
- You've been invited to join the{" "} + {inviter} invited you to join the{" "} - {workspace} + {workspaceName} {" "} - workspace in the{" "} - - OpenCode Zen Console + workspace ({workspaceID}) in the{" "} + + OpenCode Console .
+
+ +
+
@@ -93,7 +89,7 @@ export const InviteEmail = ({ workspace, assetsUrl = LOCAL_ASSETS_URL }: InviteE - + Console 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 0000000000000000000000000000000000000000..1d4a396398a2e8f8c0ac4aa935a9102b8683f5c1 GIT binary patch literal 1726 zcmb`I`&ZI;7{@-mJg?{S%X8lEAD)L26BWA7*2NY8 zur53da}yi9Qv?9E`hO0K;9H19^U#8DG&Bf6&s>$}X7%}l zkp}_ztIW=L#tH!IW8s*C$FnTv#hqn1+2-EaC4NG#1r-}}yFY33mQUaq#^+Sn_MwTb z&Nqu#nSS=zSAlIl;jDX<+slnasN{MvPSO}rywTa`$A0^ed%J@q6DQxrO>1P|QG|{4 zl^Wk`1DY_pGGx!fhdFdl71I`6anB<8<0c-co+9oDB*Qg^LgBhq0Q^CT0^r5UAd=~d zW^dYm9DC^wiZFK`Q6!Vet}>wKR+Gt%jWpxzShEUIRNl}a4gFSX!>&c;kjN#?RVrCB zG@vNl#Ob*JLskdOq_!ano%zLzW068s)TT(ttYh?2w%34CECN&VIh#zz=eTK-8m zHe)-gZl?^V*;^90LzdF|1KG_<_+Y#}`60(Kz%0eFuuogr(g9uD6%kQ!b}bf*H;pPs zz3MHiS^A(wZZelE;+gQ5<|GtV{J8dHDl39fEK>E&Bpr#vd!$W2O0mTsqtu%hK`e`C2b3bzr!; zSwU5L`bU!zp>Dkh^IWO5-SH{2f6c-ZnQp$luUxElu5*1npmueAR>z*-+Eg=l&}c$AZOhb zo`=+_`^EKux{cbI6k;!g??kn>>7Gn8$#kcj-W$>R-ugdpru%1e-=P3dV!T!Yjh37s z-5ar!K{sy)6di}I*$=9D?$p4_sw&6YTvnQuoGQ&mfI1b;$Bo*ZvlIf~z*7N`Yq3J> z=~f=(#ml+rh8vZSCNnRF-pyTRI?(NqNMt=+EtM+xxLM8AN$00--b2+(D{yA*p+5TGHgO?7J*` zPIk;g?D(c5QRO+^)J_`wpph5qKC1nCN;&uYKRbFF2yDOs)c-|?at>k39(Od+)G({b z!`$r3a04S{Lj%{}eSg-M_}#D)6S`yPxc~{m*1fvgg$%_rV@32jd_$LqP<1FiCkY+W z$9~9R6bQZHaQI$7==1Gu-g92J1{`qkPgn!Ks#UCBDZC_GykZ~ky7c;9ocY~=@Zcy6 I6qH!-A40eeDgXcg literal 0 HcmV?d00001