wealth/docs/decisions/0023-desktop-composer-is-an...

20 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 0023 The desktop composer is an intercepted dialog
Status: Proposed · Area: architecture · Date: 2026-10-07, amended 2026-10-09 · Decided by: agent
## Context
C4 ۷.۳ opens «پست جدید» on desktop as a 640px dialog over the page the creator is on, while /compose/post is also a page of its own (a reload, a shared link, a login that returns there). Mobile keeps the pushed page.
## Decision
- bear's `(main)` layout has a `@modal` slot. `@modal/(.)compose/post` intercepts a soft navigation to /compose/post and renders the composer in island `Modal size="wide"`; a hard load gets the `(flow)` full page. Since 2026-10-09 the edit route `(.)compose/post/[id]` (J08-4) and `(.)compose/prediction` (J09, `Modal size="xwide"`, 960) are intercepted the same way.
- The slot is emptied by explicit null pages for the routes the dialog lands on (`@modal/channels/[username]`), never by a catch-all: a catch-all would match every unbuilt path, and a soft navigation there keeps the old page under the new URL.
- `(main)/default.tsx` reloads the URL when the intercept fires from outside `(main)` (the full composer's header, a login that returns there), so the full page takes over instead of a dialog over an empty frame.
- Closing the dialog goes back in history. Publishing over the creator's own channel also goes back, then refreshes, so the channel isn't in history twice; anywhere else it replaces the dialog's entry with the channel and refreshes. The refresh is needed because the channel under the dialog is reused, not fetched again.
## Alternatives
- Dialog state without a route: rejected; the URL would not say what is open, and the composer's deep link would need a second code path.
- A `[...catchAll]` slot page: rejected for the reason above.
## Consequences
Every new route the dialog can land on needs its own null `@modal` page. While the dialog is open `usePathname()` reads /compose/post, so the page under it sees that path. Intercept pages have no `loading.tsx`: a loading dialog would be a second Modal instance, so the dialog would open twice; each intercept renders its own dialog skeleton behind `AuthGuard` instead.