公開のトップページをアプリに返す - #73
Conversation
`type: "article"` は住所を 2 つ取っていた——索引の `/a/{slug}` と記事の
`/a/{slug}/{id}`。前者はプラットフォームのものだったことが一度もない(索引は
レコードの一覧で、手書きの公開ページは同じ datasets をすでに受け取っている)のに、
`path` と `type` は排他で public ビューはアプリに 1 つなので、記事を出すアプリは
公開の顔を丸ごと手放していた。
- `views[].type` を撤去。`article` ブロック単独が「このコレクションのレコードは
`/a/{slug}/{id}` で markdown として描かれる」の宣言になり、`path` はすべての
ビューで必須。`type` は名指しで断る(足すべきものを言う必要があるので、
strict の Unrecognized key では足りない)
- `article.collection` を追加。索引が自前になった以上、雑誌の表紙が 2 本目の
dataset を読む理由はいくらでもある。1 本しかないビューでは省ける
- `view.open(cid, id)` ——フレームは `sandbox="allow-scripts"` のみで、
ページからリンクが張れない。URL ではなくレコードを名指し、slug は親が持つので、
ページは読んでいるアプリの外へ人を送れない
- protocol は据え置き(2.0.0)。判定を `type` から `article` に付け替えただけで、
古い reader は `path` を描くので「別のアプリを見せる」ではなく劣化になった
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Sorry @snakajima, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 4 days and 7 hours by commenting @sourcery-ai review. Upgrade to get a review now.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (18)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe PR replaces ChangesArticle view declarations and publication
Sandbox article navigation
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: 🔵 Low · up to The new article-linking behavior delegates final destination selection to host code; an incorrect binding or authorization check could send users to an unintended article or expose content across app or tenant boundaries. The PR is mergeable with explicit owner awareness and follow-up to verify host-side destination and authorization enforcement. Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant SandboxedView
participant ViewParent
participant Host
SandboxedView->>ViewParent: Send open request with cid and id
ViewParent->>ViewParent: Validate request and article collection
ViewParent->>Host: Call navigate(OpenAsk)
Host-->>ViewParent: Return navigation result
ViewParent-->>SandboxedView: Send openResult when navigation does not occur
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Title checkExplanation The title describes the public-page integration added by the pull request. It is related to the new view communication and navigation flow, although it does not mention the broader article declaration changes. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's GuideThis PR transfers ownership of Sequence diagram for safe article navigation from a sandboxed viewsequenceDiagram
participant Index as App index
participant Parent as View parent
participant Host as Host navigate port
participant Article as Article page
Index->>Parent: view.open(cid, id)
Parent->>Parent: readOpenMessage(data, articleCid)
alt valid article collection and id
Parent->>Host: navigate({cid, id})
Host->>Article: navigate to /a/{slug}/{id}
else invalid collection or id
Parent-->>Index: openResult(opened: false, reason)
else no navigation port
Parent-->>Index: openResult(opened: false, reason: no-navigation)
end
Flow diagram for article declaration validation and projectionflowchart TD
Manifest[View manifest with path and article block]
Normalize[normalizeViews]
Validate[articleCollectionProblems]
Resolve[articleCid]
Project[publicViewProjection]
Reader[Reader receives resolved article.collection]
Manifest --> Normalize
Normalize --> Validate
Validate -->|valid| Resolve
Resolve --> Project
Project --> Reader
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
type: "article"は住所を 2 つ取っていた。/a/{slug}/a/{slug}/{id}索引がプラットフォームのものだったことは一度もない——ただのレコードの一覧で、手書きの公開ページは同じ datasets をすでに受け取っている。それでも
viewSourceProblemsがpathとtypeを排他にし、public ビューはアプリに 1 つなので、記事を出すアプリは公開の顔を丸ごと手放していた。表紙も About もセクションのナビも置けず、記事アプリは全部おなじページになる。記事ページのほうは本当にプラットフォームのものである。markdown は sandbox の外・host の origin で
v-htmlされるので、articleMarkdown.ts(marked→DOMPurify)がセキュリティ境界そのもので、ページに渡せる代物ではない。変えたこと
views[].typeを撤去。articleブロック単独が宣言になる。{ "id": "public", "audience": "public", "path": "views/home.html", "collections": ["articles"], "article": { "title": "title", "body": "body", "byline": "byline" } }pathはすべてのビューで必須。typeは名指しで断る——足すべきもの(path)を言う必要があるので、.strict()の "Unrecognized key" では足りない。article.collectionを追加。 索引が自前になった以上、雑誌の表紙が 2 本目の dataset(セクション、マストヘッド)を読む理由はいくらでもある。以前の「コレクションは 1 本だけ」は、プラットフォームが全部描いていたから安上がりだっただけ。1 本しか名指していないビューでは省ける。射影は解決済みのcollectionを必ず載せるので、reader が推論をやり直すことはない。view.open(cid, id)——新しい橋の動詞。 フレームはsandbox="allow-scripts"のみ(allow-top-navigationもallow-popupsも無い)ので、ページからリンクが張れない。索引がアプリのものになった以上これが要る。cidはそのアプリが記事を描く唯一のコレクションでなければ断られる/も先頭の.も空も不可)で、host の encode 忘れに依存しないopened: false, reason: "no-navigation"は拒否ではない。navigate ポートを持たない親(著者のプレビューのペイン)の答えで、ページ側にできることは何もない。本番では通常 settle しない——遷移がこの文書を持っていくから。それがリンクの意味論protocol は据え置き
protocolForの判定をtypeからarticleに付け替えただけで、記事アプリは 2.0.0 のまま。古い reader はpath(1.0.0 から知っている鍵)を描くので、間違えるのは/a/{slug}/{id}だけ——「索引の位置に生成フォームを出す=別のアプリを見せる」から「共有リンクが索引に落ちる」への劣化になった。major を維持したのは、これらのアプリがidFrom: "slug"で既に 2.0.0 だからタダだから。検証
yarn typecheck/yarn lint/yarn test(545 pass)/yarn check:apps(ALL 10 APPS PUBLISH)。test/test_viewOpen.tsは 9 本。ブートストラップをnode:vmで実際に走らせてview.openが出す線とその settle まで見ている。手順
reader が先——mulmoserver を先に出し、このパッケージの publish 後に MT。既存のブログアプリ 2 本(
ai-notes/ai-journal)は互換の受け皿を作らず、著者がtypeを消して索引ページを足す。計画: mulmoterminal
plans/feat-shared-app-app-owned-index.mdSummary by Sourcery
Return public index rendering to applications while keeping secure platform article pages and adding a safe navigation bridge from sandboxed views.
New Features:
view.open(cid, id)API for sandboxed public pages to navigate to articles safely.Bug Fixes:
type: "article"declaration and missing view paths.Enhancements:
articledeclaration model.Tests:
view.openmessage flow.Summary by CodeRabbit
New Features
Breaking Changes
type: "article"view declaration is no longer supported; use anarticleblock instead.