Skip to content

Let the chat connect the user's own domain - #152

Open
jelveh wants to merge 1 commit into
mainfrom
chat-custom-domain
Open

jelveh wants to merge 1 commit into
mainfrom
chat-custom-domain

Conversation

@jelveh

@jelveh jelveh commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Why

When a user asked the AI to put their site on their own domain, the AI could only tell them to open the Publish menu. The chat's Publish card handled only .puter.site addresses, and an address like joes.com passed to OfferPublish became joes-com.puter.site.

The AI can't open Puter's domain window itself: puter.hosting.attach() opens a popup, and browsers only allow that straight from a user's click. A button on a chat card counts as that click, the same way the Publish card does.

What

A new OfferCustomDomain tool (src/tools/chat_ui/domain.js) puts the Publish card in the chat in a new domain mode. The card's button calls the popover's existing useOwnDomain, so the plan check, name reservation, Puter's window, domain records and status checks are all shared.

State Card shows
Not published yet (paid) Address field + Publish with your domain. Reserves the name, opens Puter's window, publishes behind it
Live, no domain Site link + Use custom domain
Live, domain connected Domain link + Change domain (or Connect again if the address changed), with a line while it waits for DNS / fails / stops working
Free plan Use custom domain, which opens the upgrade dialog; the card switches once the plan changes
Signed out No card; the AI tells them to sign in

Changes outside the new tool:

  • ui.js: publishWithDomain / useOwnDomain take an optional via from the card (its typed name, fail, publish, onDomain). Without via, the popover behaves as before. connectCustomDomain takes onDomain. Domain and plan changes also redraw chat cards.
  • publish.js:
    • Adds the domain view.
    • publishFromCard can publish onto a reserved name.
    • The chosen domain is saved on the card's tool result, and an older card reads "Domain added" after a reload.
    • A publish that lands after the domain was chosen doesn't overwrite that record.
  • Prompt: own-domain requests go to OfferCustomDomain. Older chats whose prompt still sends users to the Publish menu get a note (DOMAIN_TOOL_NOTE). OfferPublish's description points to the new tool too.
  • Connecting a domain from a live card isn't held up by a running turn, since it publishes nothing, matching the popover. It does wait during an address change.

Testing

  • npm test and npm run build pass.
  • test-custom-domain.mjs runs the real ui.js domain code with the card's via:
    • Puter's window opens in the click.
    • The card's name, rather than the popover's, is reserved.
    • The card runs the publish.
    • Errors go to the card, including after switching projects.
    • A build in progress blocks it; the free plan opens the upgrade.
  • test-publish-card.mjs runs the real card and tool: every state above, the busy labels, saved records, the frozen "Domain added" card, reloads and wiring.
  • Not tested in a live browser against Puter's real domain window, since that needs a paid account.

The AI could only send users to the Publish menu for a custom domain. Now
it calls OfferCustomDomain, which puts the Publish card in the chat in a
domain mode. Its button is the popover's Use custom domain (useOwnDomain),
so Puter's window still opens straight from the user's click, as a browser
requires of a popup.

- Before a first publish the card has the address field and "Publish with
  your domain": it reserves the name, opens Puter's window and publishes,
  as the popover's route does (publishWithDomain), with the card's own
  field, errors and publish passed in.
- On a live site it shows the address (the domain once it works) and Use
  custom domain, Change domain or Connect again, with a line while the
  domain waits for DNS. A turn doesn't hold it up; an address change does.
- On the free plan the button opens the upgrade, and the card turns into
  the paid one when the plan changes.
- The domain chosen is saved on the card's tool result, so an older card
  reads "Domain added" after a reload.
- The prompt points own-domain requests at the tool, and older chats whose
  prompt sends the user to the Publish menu get a note.
@reynaldichernando

Copy link
Copy Markdown
Member

Preview of this branch at 631e9fe

The preview is its own app, so it starts with no projects. Your builder.puter.com projects won't show up there.

@reynaldichernando

Copy link
Copy Markdown
Member
image

@reynaldichernando

Copy link
Copy Markdown
Member
image

@reynaldichernando

reynaldichernando commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

for the manual "Use custom domain" button, we automatically picked the .puter.site subdomain for the user to avoid having them do double work (typing the name of puter site subdomain and typing their domain name)

i think this should just be a button that opens the dns flow, and we just automatically pick the puter.site subdomain for them

in any case, this is working as expected right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants