Skip to content

feat: Migrate to IndexedDB, add date selector and roll-over time settings#9

Merged
hidao80 merged 12 commits into
mainfrom
develop
Jun 6, 2026
Merged

feat: Migrate to IndexedDB, add date selector and roll-over time settings#9
hidao80 merged 12 commits into
mainfrom
develop

Conversation

@hidao80

@hidao80 hidao80 commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • IndexedDB migration: Replace all localStorage usage with an IndexedDB KV store (js/lib/storage.js). Data is written synchronously to a localStorage buffer on every keystroke and committed to IndexedDB only on date change, tab hide, or navigation — preventing data loss under debounce race conditions.
  • Date selector: A date input in the top-right corner filters the textarea to show only log entries within the configured roll-over time boundary for the selected day. The selected date persists across sessions and cannot be set to a future date.
  • Date roll-over time: New config setting for the hour at which a "day" begins (default 05:00). Entries logged before the roll-over are counted as the previous day, making the app usable for night-shift workers.
  • Versioned data migration: A runMigrations() system safely moves existing localStorage data to IndexedDB on first launch. Supports old key variants (date-roll-over-time-value). Migration is retried on failure.
  • Cross-tab sync: BroadcastChannel('fast-logbook-sync') replaces the storage event for real-time sync across tabs.
  • One-time upgrade notice: Existing users see a modal explaining the new date selector on first launch after upgrade. Dismissed state is stored in IndexedDB so it never shows again.
  • Help updates: Added date selector and roll-over time explanations to help tabs; added a Changelog tab with version history from git log.
  • Bug fixes: Fixed initialized guard to prevent saveLogs() writing an empty buffer before loadLogs() completes (Bootstrap modal focus-move triggered blur, corrupting IndexedDB). Fixed config.js shortcut input placeholders not displaying. Fixed translateElement() in i18n to set placeholder instead of innerHTML for <input>/<textarea> elements.

@hidao80 hidao80 self-assigned this Jun 6, 2026
@hidao80 hidao80 added the enhancement New feature or request label Jun 6, 2026
@netlify

netlify Bot commented Jun 6, 2026

Copy link
Copy Markdown

Deploy Preview for fast-logbook ready!

Name Link
🔨 Latest commit cdb7e26
🔍 Latest deploy log https://app.netlify.com/projects/fast-logbook/deploys/6a239051ece4e800083f7f71
😎 Deploy Preview https://deploy-preview-9--fast-logbook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@hidao80, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 32 minutes and 58 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 82a2a549-83ec-4322-93d2-98065238c583

📥 Commits

Reviewing files that changed from the base of the PR and between 2c72408 and cdb7e26.

📒 Files selected for processing (6)
  • .claude/rules/assistant-style.md
  • index.html
  • js/config.js
  • js/lib/download.js
  • js/lib/multilingualization.js
  • js/main.js

Walkthrough

このPRは、アプリケーションの永続化層をlocalStorageからIndexedDBへ全面移行し、日付単位のログ管理とロールオーバー時刻機能を実装します。新しいストレージモジュールが非同期キー・バリュー操作とlocalStorageからの移行処理を提供し、すべてのモジュールがこれを使用するように再構成されています。日付選択UIと多言語対応が追加され、メインアプリケーションロジックはバッファード書き込み、日付別フィルタリング、BroadcastChannelによるクロスタブ同期を実装した大規模なリファクタリングを受けています。分析機能は削除されました。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PR タイトルは IndexedDB への移行と日付セレクター、ロールオーバー時刻設定という主要な変更を明確に示しており、変更セットの主要な目的を適切に要約しています。
Description check ✅ Passed PR 説明は IndexedDB 移行、日付セレクター、ロールオーバー時刻設定、データ移行、クロスタブ同期、ヘルプ更新などの実装内容と対応しており、変更セットに関連しています。
Docstring Coverage ✅ Passed Docstring coverage is 93.33% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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


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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
sw.js (1)

36-50: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

CACHE_NAME の初期化が非同期レースになっており、precache が不定になります。

install 時点で CACHE_NAME が未設定の可能性があり、/js/lib/storage.js を含む assets の事前キャッシュが安定しません。install 内で manifest 取得→CACHE_NAME 決定→addAll を同一チェーンで待つ構成にしてください(またはビルド時に固定バージョンを埋め込む)。

🤖 Prompt for 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.

In `@sw.js` around lines 36 - 50, The CACHE_NAME initialization currently runs
asynchronously outside the install handler causing a race; move the
fetch('/manifest.json') and manifestData.version -> CACHE_NAME assignment into
the self.addEventListener("install", ...) waitUntil promise chain so that you
first fetch and set CACHE_NAME, then call caches.open(CACHE_NAME) and
cache.addAll(assets) in the same chain; ensure the install handler’s e.waitUntil
only resolves after manifest fetch, CACHE_NAME assignment, and cache.addAll
complete (alternatively embed a fixed version at build time to avoid runtime
fetch).
🤖 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 @.claude/rules/assistant-style.md:
- Line 1: The document header contains a misspelling "# Assistant stylle rules"
— change "stylle" to "style" so the heading reads "# Assistant style rules";
search the file for any other occurrences of "stylle" and correct them to
"style" (update the top-level heading and any rule titles or references that use
the misspelled word).

In `@index.html`:
- Line 171: ボタンの表示文言がハードコードされた "OK" になっているので、i18n と整合させるために
id="dateFeatureNoticeOkButton" を持つボタンの中身を直接書き換えず、既存の翻訳パターンに合わせて翻訳キー化してください;
具体的には該当ボタンを data-translate(またはプロジェクトで使われている同等の属性)を使って例えば
data-translate="common.ok" のような翻訳キーを紐付けるか、該当の初期化コードで dateFeatureNoticeOkButton の
innerText を翻訳関数でセットするように変更してください(ボタン id: dateFeatureNoticeOkButton を参照)。
- Around line 160-172: The modal can become unclosable because
dateFeatureNoticeModal is set with data-bs-backdrop="static" and
data-bs-keyboard="false" while the OK button (dateFeatureNoticeOkButton) lacks a
dismiss attribute and relies solely on js/main.js's setItem(...); fix by adding
a safe close path: add data-bs-dismiss="modal" to the button so Bootstrap can
always close it, and in js/main.js ensure the setItem(...) completion handler
explicitly hides the modal (use Bootstrap's Modal API on element with id
"dateFeatureNoticeModal") on both success and failure as a fallback.

In `@js/config.js`:
- Around line 73-77: The current selector assigns target based only on
ROUNDING_UNIT_MINUTE_KEY which causes the 'date-roll-over-time' key to match the
<h5> (data-translate) instead of the time <input>, so the UI input isn't
updated; modify the selection logic in the block that sets target (using key,
ROUNDING_UNIT_MINUTE_KEY and $$one) to special-case the 'date-roll-over-time'
key and select the input element (e.g. an
input[type="time"][data-translate='date-roll-over-time']) rather than the
generic [data-translate='...'] so target.value updates the correct element.

In `@js/lib/download.js`:
- Around line 112-115: downloadLog can pass null into generateFormattedLog
because getItem(LOG_DATA_KEY) or getItem(ROUNDING_UNIT_MINUTE_KEY) can return
null/undefined, causing .split() exceptions or NaN; fix by providing safe
fallbacks and type-coercion before calling generateFormattedLog: ensure logData
is set to a safe empty string when both the function argument log and
getItem(LOG_DATA_KEY) are falsy, ensure mins is coerced to a Number and falls
back to a sensible default (e.g., 1 or 0) when getItem(ROUNDING_UNIT_MINUTE_KEY)
is missing or NaN, and validate these values (logData as string, mins as finite
number) in downloadLog prior to invoking generateFormattedLog.

In `@js/lib/multilingualization.js`:
- Around line 27-31: The current placeholder logic uses window.__i18n_t(key)
(symbol: __i18n_t) which returns the key when untranslated, so the existing if
(translated) check doesn't detect missing translations; update the logic to
detect untranslated entries by checking the i18n dictionary existence (e.g.
window.__i18n_dict[key]) or by comparing translated === key, and if untranslated
fall back to '' before assigning elem.placeholder; adjust the branch handling
for elem.tagName === 'INPUT' || elem.tagName === 'TEXTAREA' to only set
placeholder when a real translation exists.

In `@js/main.js`:
- Around line 40-42: The current conversion const version = Number(stored ?? 0)
can produce NaN when stored contains a corrupt value, causing the migration
check to always fail; modify the logic around getItem(MIGRATION_VERSION_KEY) so
you coerce the retrieved stored value to a number and explicitly guard against
NaN (e.g., compute a numericValue from stored and set version to 0 when
Number.isNaN(numericValue)); update the code path that uses stored/version
(refer to MIGRATION_VERSION_KEY, getItem, stored, version) to use this NaN-safe
fallback so migrations are retried.

---

Outside diff comments:
In `@sw.js`:
- Around line 36-50: The CACHE_NAME initialization currently runs asynchronously
outside the install handler causing a race; move the fetch('/manifest.json') and
manifestData.version -> CACHE_NAME assignment into the
self.addEventListener("install", ...) waitUntil promise chain so that you first
fetch and set CACHE_NAME, then call caches.open(CACHE_NAME) and
cache.addAll(assets) in the same chain; ensure the install handler’s e.waitUntil
only resolves after manifest fetch, CACHE_NAME assignment, and cache.addAll
complete (alternatively embed a fixed version at build time to avoid runtime
fetch).
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8e3aa09a-8b51-4ee5-9abe-2c75c30cef42

📥 Commits

Reviewing files that changed from the base of the PR and between b7cad5b and 2c72408.

⛔ Files ignored due to path filters (1)
  • manifest.json is excluded by !**/*.json
📒 Files selected for processing (11)
  • .claude/rules/assistant-style.md
  • .npmrc
  • config.html
  • index.html
  • js/config.js
  • js/lib/analytics.js
  • js/lib/download.js
  • js/lib/multilingualization.js
  • js/lib/storage.js
  • js/main.js
  • sw.js
💤 Files with no reviewable changes (1)
  • js/lib/analytics.js

Comment thread .claude/rules/assistant-style.md Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread js/config.js
Comment thread js/lib/download.js
Comment thread js/lib/multilingualization.js Outdated
Comment thread js/main.js
@hidao80 hidao80 merged commit fd866f7 into main Jun 6, 2026
7 checks passed
@hidao80 hidao80 deleted the develop branch June 6, 2026 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant