Browse Source

reorganize serena memories

Yuki Takei 7 months ago
parent
commit
c4bd2aff29

+ 72 - 0
.serena/memories/apps-app-jotai-migration-fix-errors.md

@@ -0,0 +1,72 @@
+# 概要
+apps/app 配下で pnpm run lint:typecheck をすると沢山のエラーがでるが、これはリファクタの影響である
+そのエラーを潰したい
+
+# エラータイプA
+
+## エラーメッセージ例
+
+```
+src/client/components/Me/BasicInfoSettings.tsx:8:10 - error TS2724: '"~/states/server-configurations"' has no exported member named 'useRegistrationWhitelist'. Did you mean 'registrationWhitelistAtom'?
+
+8 import { useRegistrationWhitelist } from '~/states/server-configurations';
+           ~~~~~~~~~~~~~~~~~~~~~~~~
+```
+
+## 原因・経緯
+
+server-configurations.ts からカスタムフックを消したため、インポートできなくなっている
+
+## 対策
+useFoo() は使えないので、fooAtom を直接 import する
+
+```
+import { fooAtom } from '~/states/server-configurations';
+```
+
+利用側は以下:
+
+```
+// 旧コード例
+const [foo, setFoo] = useFoo();
+const [foo] = useFoo();
+const [, setFoo] = useFoo();
+
+// 置き換え新コード例
+const foo = useAtomValue(fooAtom);
+const setFoo = useSetAtom(fooAtom);
+```
+
+useAtomValue と useSetAtom は以下のようにインポートできる
+
+```
+import { useAtomValue } from 'jotai';
+import { useSetAtom } from 'jotai';
+```
+
+# エラータイプB
+
+## エラーメッセージ例
+```
+src/client/components/PageControls/PageControls.tsx:139:9 - error TS2488: Type 'boolean | null' must have a '[Symbol.iterator]()' method that returns an iterator.
+
+139   const [isSearchPage] = useIsSearchPage();
+```
+
+## 原因・経緯
+`useFoo()` の返り値の型が変わった
+
+具体的には、useAtom() 利用から useAtomValue() 利用に変わった
+
+## 対策
+
+```
+// 旧コード例
+const [foo, setFoo] = useFoo();
+const [foo] = useFoo();
+const [, setFoo] = useFoo();
+
+// 置き換え新コード例
+const foo = useAtomValue(fooAtom);
+const setFoo = useSetAtom(fooAtom);
+```

+ 0 - 0
apps/app/docs/plan/jotai-migration-progress.md → .serena/memories/apps-app-jotai-migration-progress.md


+ 0 - 0
apps/app/docs/plan/jotai-migration.md → .serena/memories/apps-app-jotai-migration.md


+ 51 - 0
.serena/memories/apps-app-jotai-typecheck-handover.md

@@ -0,0 +1,51 @@
+Handover Tips for Jotai migration & TS typecheck (support/use-jotai)
+
+Context:
+- Goal: Eliminate TS2488 errors caused by legacy tuple-style custom hooks after migrating to Jotai single-value hooks.
+- Command per CLAUDE.md: `cd apps/app && pnpm run lint:typecheck` (ONLY this for type checking).
+- Branch: support/use-jotai
+
+Current Status (at interruption):
+- All identified tuple destructuring patterns converted to single-value usage (e.g. `const value = useXxx();`).
+- Last edited file: `src/client/components/Sidebar/SidebarNav/SecondaryItems.tsx` (removed `[isAdmin]`, `[growiCloudUri]`, `[isGuestUser]`).
+- A rerun of typecheck after this final change was attempted but the command execution was cancelled, so confirmation of 0 remaining TS2488 errors is still pending.
+- Previously remaining single TS error (TS2488) was always of the same form: `const [something] = useHook();`.
+- Other non-blocking lint issues still present (console logs in `PageView.tsx`, `<img>` tags without `alt` or Next.js `<Image>` replacement, `any` types). These do NOT affect `vue-tsc` typecheck success but will appear when running full lint tasks.
+
+Likely Next Step:
+1. Run: `cd apps/app && pnpm run lint:typecheck`.
+2. If TS2488 still appears, fix by:
+   - Change `const [name] = useSomeHook();` to `const name = useSomeHook();`.
+   - Remove unused variable names if no longer needed.
+3. Repeat until typecheck passes with no errors.
+
+Useful Grep (do manually in next session):
+- Search residual tuple patterns: `grep -R "const \[" apps/app/src/client apps/app/src/components | grep use`.
+
+Patterns Already Normalized:
+- `useCurrentUser`, `useCurrentPageData`, `useCurrentPageId`, `useCurrentPagePath`, `useLatestRevision`, `usePageNotFound`, `useIsEditable`, all `useIsGuestUser|ReadOnlyUser|SharedUser|Admin|DefaultLogo`, server config atoms (showPageLimitation*, isMailerSetup, etc.), remote revision hooks.
+
+Remote Revision Migration:
+- All former imports from `~/stores/remote-latest-page` replaced by hooks in `~/states/page` (e.g. `useSetRemoteLatestPageData`, `useRemoteRevisionId`, etc.). If any stragglers appear, replace path and remove tuple destructuring.
+
+Caveats:
+- Do NOT reintroduce tuple destructuring; hooks now return single values.
+- Avoid modifying console logs, `<img>` tags, or lint-only issues unless explicitly tasked (keep scope focused so auto-approve remains stable).
+
+Definition of Done:
+- `pnpm run lint:typecheck` exits 0 with no TS errors.
+
+If Additional Errors Appear:
+- TS2307 (old remote-latest-page path): update import to `~/states/page` and adjust variable names to direct values.
+- TS2724/TS2305 (missing exports for removed legacy hooks): replace usage with the new atom-based hook listed in `/states/*` directories.
+
+After Success (Optional Future Tasks):
+- Remove debug `console.log` in `PageView.tsx`.
+- Replace `<img>` with Next `<Image>` and add `alt` attributes where flagged.
+- Tighten `any` usages in files like `ProfileImageSettings.tsx`, `CustomizeLogoSetting.tsx`.
+
+Quick Checklist For Next Session:
+[ ] Run typecheck command
+[ ] Fix any residual TS2488
+[ ] Re-run until clean
+[ ] Commit with message: "chore(app): remove remaining tuple destructuring for jotai migration"