feat: improve article creation UX and fix archived note access#237
Conversation
When creating an article from the note editor, the article is now automatically linked to the note after saving, improving the UX by eliminating manual steps. Also uses replace navigation to prevent returning to empty create page. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Previously, getNoteByArticleId filtered out archived notes, causing 404 errors when accessing articles linked by archived public notes. Now archived status is not filtered, so public notes' articles remain accessible even after archiving. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
ce4f34b to
847a2ef
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ce4f34b34c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // 查找 articleId 匹配的笔记(不过滤归档状态,归档的公开笔记仍可访问其文章) | ||
| const note = await db.query.rotes.findFirst({ | ||
| where: (rotes, { eq, and }) => and(eq(rotes.articleId, articleId), eq(rotes.archived, false)), | ||
| where: (rotes, { eq }) => eq(rotes.articleId, articleId), |
There was a problem hiding this comment.
Restrict article-note lookup to public candidates
getNoteByArticleId now picks the first note with a matching articleId without filtering by visibility, but both article read endpoints authorize non-authors from that single returned note (note.state === 'public'). Because the DB schema does not enforce one-note-per-article, an article linked to both a public note and a private archived note can now be denied intermittently if the private row is returned first, which regresses public article availability after this change. Prefer filtering/ordering this lookup for permission checks so public references are selected deterministically.
Useful? React with 👍 / 👎.
Summary
Changes
Test plan
🤖 Generated with Claude Code