Skip to content

Feature/#19 code refactor#21

Merged
273Do merged 10 commits into
developfrom
feature/#19-code-refactor
May 24, 2026
Merged

Feature/#19 code refactor#21
273Do merged 10 commits into
developfrom
feature/#19-code-refactor

Conversation

@273Do
Copy link
Copy Markdown
Owner

@273Do 273Do commented May 24, 2026

概要

実施した内容

  • コードのリファクタと機能修正
  • 不要なファイルの削除

チェックリスト

  • コードがプロジェクトのスタイルガイドラインに従っている
  • セルフレビューを完了
  • 複雑なコードにコメントを追加
  • ドキュメントを更新(該当する場合)
  • 破壊的変更なし(またはやむを得ない場合は文書化済み)
  • ci / cd を通過

備考

関連 Issue

Closes #19

Summary by CodeRabbit

  • 削除

    • エクスプロア画面を削除しました
    • フォーム一覧コンポーネントを削除しました
  • 新規

    • フィールド共通ラッパーを追加しラベル表示を統一しました
    • エントリー/ジャーナルのデータ取得・管理を整理・集約しました(画面の挙動安定化)
  • 改善

    • ロケーションフィールドの未設定表示を「Not set」に更新しました
  • 変更

    • インサイトのグラフを棒からポイント表示に切替えました
  • ドキュメント

    • README の先頭をアプリ紹介に差し替えました

Review Change Stack

@273Do 273Do self-assigned this May 24, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 33bf7151-eae2-4bf2-89e4-7f2fced04677

📥 Commits

Reviewing files that changed from the base of the PR and between 329573a and 9034db0.

📒 Files selected for processing (3)
  • src/app/(journal)/edit.tsx
  • src/app/(journal)/entry/create.tsx
  • src/components/entry/entry-create-view.tsx

Walkthrough

データ購読・操作を新しいフック(useEntryDetail/useEntryList/useJournalList)へ移行し、フィールドUIは FieldWrapper に統一。リスト・ジャーナル・アイコン行の生成はフック/ユーティリティに委譲されています。

Changes

Custom hooks and screen refactoring

Layer / File(s) Summary
Custom hooks for data management
src/utils/entry/use-entry-detail.ts, src/utils/entry/use-entry-list.ts, src/utils/journal/use-journal-list.ts
useEntryDetail はエントリ購読と save()/bookmark()/remove() を提供。useEntryList は取得→プレビュー変換→検索→ソート→月別グループ化を行い { grouped } を返す。useJournalList はジャーナル取得と2列化を返す。
Entry detail screen migration
src/app/(journal)/entry/[id].tsx, src/components/entry/entry-detail.tsx, src/app/(journal)/edit.tsx
エントリ詳細画面が useEntryDetail(entryId) を利用するようになり、保存/削除/ブックマーク処理はフックの save()/remove()/bookmark() を呼ぶ。フィールド表示は値を deserializeValue したものを渡すよう変更。
Entry list and journal view migration
src/components/entry/entry-list-view.tsx, src/components/journal/journal-view.tsx, src/components/journal/icon-select-bottom-sheet.tsx
EntryListViewuseEntryListgrouped を使用する。JournalViewuseJournalListrows を利用する。アイコンシートの行生成は chunkArray に置換。

Field component standardization

Layer / File(s) Summary
FieldWrapper component
src/components/field/field-wrapper.tsx
新規 FieldWrapper がラベルと子要素を縦配置で描画する共通ラッパーを提供。
Field components refactoring
src/components/field/entry-text.tsx, src/components/field/entry-long-text.tsx, src/components/field/emtry-number.tsx, src/components/field/entry-date.tsx, src/components/field/entry-time.tsx, src/components/field/entry-location.tsx
各フィールドがラベルレンダリングを FieldWrapper に委譲。EntryNumber は入力処理を handleValueChange に分離し表示初期値の string 化を String(number ?? "") に変更。EntryLocation の文言を更新。

Cleanup and minor fixes

Layer / File(s) Summary
Schema/comment, header button, chart tweak
src/app/(journal)/edit.tsx, src/db/schemas/entries.ts, src/components/insights/stat-card-check.tsx, README.md, src/app/(journal)/entry/create.tsx, src/components/entry/entry-create-view.tsx
編集画面の Save ボタンから as const 型アサーションを削除、entries スキーマの JSDoc 断片を削除、StatCardCheck の Chart を barpoint に変更、README の先頭ブロック更新、useLiveQuery に依存配列を追加した呼び出しを複数修正。
sequenceDiagram
  participant EntryDetailScreen
  participant useEntryDetail
  participant useLiveQuery
  participant updateEntry

  EntryDetailScreen->>useEntryDetail: useEntryDetail(entryId)
  useEntryDetail->>useLiveQuery: subscribe getEntryDetailQuery(entryId)
  EntryDetailScreen->>useEntryDetail: save() / bookmark() / remove()
  useEntryDetail->>updateEntry: persist / toggle bookmark / delete
Loading

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • 273Do/Nicky#20: StatCard/Chart 設定の変更に関連するコンポーネント修正を含むためコードレベルで関連します.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive タイトル「Feature/#19 code refactor」は変更の内容を部分的に示していますが、多くの機能削除や複雑なリファクタリングが含まれており、より具体的な説明が必要です。 タイトルをより具体的に記述してください。例えば「Refactor entry and journal components to use custom hooks」など、主要な変更を明示してください。
Out of Scope Changes check ❓ Inconclusive ExploreScreenとAllformListの削除が含まれていますが、これらが#19の要件に該当するかどうか明示的には確認できません。また複数の副次的な変更の目的が明確ではありません。 ExploreScreenとAllformListの削除がリファクタリング目標に含まれていることを確認し、説明を追加してください。
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed コード整理とリファクタリングの目標に対して、フック化による責務分離、不要なコンポーネント削除、レイアウト共通化など、全体的なコード再構成が実現されています。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/#19-code-refactor

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/app/`(journal)/entry/[id].tsx:
- Around line 28-29: The edit form is currently kept in the parent via
useEntryDetail (including valuesRef) and only toggled by editMode, which
prevents fresh initialization on reopen; move the ref/state hooks into a
dedicated child component (e.g., EntryEditForm) so the form is mounted/unmounted
when editMode changes. Concretely: extract the form markup and any logic that
uses valuesRef from the parent into a new component that accepts entry,
setValue, save, bookmark, remove (or minimal handlers) as props, remove
valuesRef from parent scope, and render the child conditionally (editMode ?
<EntryEditForm ... /> : <EntryView ... />) so switching modes triggers a remount
and fresh initialization; apply the same refactor to the other form instance in
this file that uses useEntryDetail.

In `@src/components/field/emtry-number.tsx`:
- Line 8: The import in emtry-number.tsx currently uses a relative path for
FieldWrapper; change it to use the project path alias by replacing the relative
import of FieldWrapper with an alias import from
"`@/components/field/field-wrapper`" (or the correct path under src that exports
FieldWrapper) so all references to FieldWrapper use the `@/` alias per the src/*
import guideline.

In `@src/components/field/entry-date.tsx`:
- Line 8: Update the relative import for FieldWrapper in entry-date.tsx to use
the project path alias instead of a relative path: replace the current
"./field-wrapper" import with the alias that points to the same module under src
(e.g. import from "`@/components/field/field-wrapper`") so all references to
FieldWrapper follow the repository's "`@/`..." convention.

In `@src/components/field/entry-long-text.tsx`:
- Line 6: Replace the current relative import of FieldWrapper in
entry-long-text.tsx with the project path-alias import that uses "`@/`..." instead
of a relative path; update the import statement that brings in FieldWrapper so
it references the module via the `@/` alias (keeping the same exported symbol name
FieldWrapper) to comply with the src/* alias rule.

In `@src/components/field/entry-text.tsx`:
- Line 6: 現在の相対パス import は規約に反するので、`import { FieldWrapper } from
"./field-wrapper";` をプロジェクトのエイリアスを使う形に置き換えてください(例: `import { FieldWrapper } from
"`@/components/field/field-wrapper`";`)—該当シンボル: FieldWrapper を含む import
文を更新して、src/* を参照するすべての相対パスを `@/...` に統一してください。

In `@src/components/field/entry-time.tsx`:
- Line 8: この行の相対インポート import { FieldWrapper } from "./field-wrapper";
をプロジェクトのパスエイリアスを使う形に置き換えてください—つまり同じエクスポート名 FieldWrapper を維持しつつインポート元を
"`@/components/field/field-wrapper`" のような `@/...` エイリアスに変更し、TypeScript
コンパイル/ESLint を通ることを確認してください。

In `@src/utils/entry/use-entry-detail.ts`:
- Line 19: useLiveQuery に依存配列が渡されておらず、entryId
が変わっても購読が更新されない問題があります。useLiveQuery(getEntryDetailQuery(entryId)) の呼び出し(関数
useEntryDetail 内)に第2引数として [entryId] を渡して依存関係を指定し、entryId
が変わったときに購読クエリ(getEntryDetailQuery)を再評価/再購読するようにしてください。

In `@src/utils/entry/use-entry-list.ts`:
- Around line 26-28: The call to useLiveQuery in use-entry-list.ts omits the
dependency array so getEntriesQuery(journalId) won't re-run when journalId
changes; update the call useLiveQuery(getEntriesQuery(journalId)) to pass the
dependency array [journalId] as the second argument (keeping the returned const
{ data: entries } and subsequent previewEntries = entries.map(buildPreviewEntry)
unchanged) so the query updates when journalId changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b10659c7-2ba1-4eaf-a297-a10bff76fdae

📥 Commits

Reviewing files that changed from the base of the PR and between e8a0162 and 2a1a894.

📒 Files selected for processing (19)
  • src/app/(journal)/edit.tsx
  • src/app/(journal)/entry/[id].tsx
  • src/app/explore.tsx
  • src/components/all-form-list.tsx
  • src/components/entry/entry-detail.tsx
  • src/components/entry/entry-list-view.tsx
  • src/components/field/emtry-number.tsx
  • src/components/field/entry-date.tsx
  • src/components/field/entry-location.tsx
  • src/components/field/entry-long-text.tsx
  • src/components/field/entry-text.tsx
  • src/components/field/entry-time.tsx
  • src/components/field/field-wrapper.tsx
  • src/components/journal/icon-select-bottom-sheet.tsx
  • src/components/journal/journal-view.tsx
  • src/db/schemas/entries.ts
  • src/utils/entry/use-entry-detail.ts
  • src/utils/entry/use-entry-list.ts
  • src/utils/journal/use-journal-list.ts
💤 Files with no reviewable changes (3)
  • src/app/explore.tsx
  • src/components/all-form-list.tsx
  • src/db/schemas/entries.ts

Comment thread src/app/(journal)/entry/[id].tsx
Comment thread src/components/field/emtry-number.tsx
Comment thread src/components/field/entry-date.tsx
Comment thread src/components/field/entry-long-text.tsx
Comment thread src/components/field/entry-text.tsx
Comment thread src/components/field/entry-time.tsx
Comment thread src/utils/entry/use-entry-detail.ts Outdated
Comment thread src/utils/entry/use-entry-list.ts Outdated
@273Do
Copy link
Copy Markdown
Owner Author

273Do commented May 24, 2026

直下なのでエイリアスはしなくていい

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Line 5: The image tag <img src="docs/screenshots/app-images.svg" /> in
README.md lacks an alt attribute; add a meaningful alt text describing the image
(e.g., "App screenshots" or a brief description of what's shown) to improve
accessibility and provide fallback text for screen readers and when the image
fails to load.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2b97ba20-1f6a-4b31-9e06-c024243505b7

📥 Commits

Reviewing files that changed from the base of the PR and between 6550e2d and 329573a.

⛔ Files ignored due to path filters (1)
  • docs/screenshots/app-images.svg is excluded by !**/*.svg
📒 Files selected for processing (3)
  • README.md
  • src/utils/entry/use-entry-detail.ts
  • src/utils/entry/use-entry-list.ts

Comment thread README.md
@273Do 273Do merged commit 4b5a203 into develop May 24, 2026
3 checks passed
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.

コード整理・リファクタ

1 participant