Skip to content

Fix launchDesk#4

Open
Dilshan Madusanka (madudilshan47-dot) wants to merge 11 commits into
codezelaca:mainfrom
madudilshan47-dot:main
Open

Fix launchDesk#4
Dilshan Madusanka (madudilshan47-dot) wants to merge 11 commits into
codezelaca:mainfrom
madudilshan47-dot:main

Conversation

@madudilshan47-dot
Copy link
Copy Markdown

@madudilshan47-dot Dilshan Madusanka (madudilshan47-dot) commented May 10, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced form validation to properly require title and category fields
    • Fixed search and filtering to match across all relevant fields
    • Corrected metrics calculations for fixed items and due-soon counts
    • Resolved CSV export functionality to properly include check titles
    • Fixed demo reset to load correct sample data

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2026

📝 Walkthrough

Walkthrough

This PR corrects multiple bugs across the checklist application: storage key consistency, form validation, search/filter matching, item deletion, status updates, CSS rendering, metrics calculation, demo data loading, and CSV export field names.

Changes

Checklist Application Bug Fixes

Layer / File(s) Summary
Storage & Configuration
js/app.js
STORAGE_LOAD_KEY is aligned with the save key (launchdesk-v1-items); demo reset fetch URL is corrected to data/launch-checks.json.
Form Submission & Validation
js/app.js
Form submit handler is wired to handleAddCheck; validation blocks submission when title or category is missing.
Search & Filter Matching
js/app.js
Search term is corrected to match title, category, priority, status, and owner; status filter compares against check.status.
Item Operations
js/app.js
Deletion detects [data-remove-id] attribute; status change flow saves, reapplies filters, and logs the update.
Display Rendering & Metrics
js/app.js
Status CSS classes are slugified (spaces become hyphens); "fixed" counts status === "Fixed" and "due soon" counts checks with daysUntil(dueDate) between 0–7 inclusive.
Data Export
js/app.js
CSV export is corrected to use check.title instead of a non-existent check.name.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A checklist once broken, now fixed with great care,
Storage keys match, filters compare,
Deletions are smooth, metrics ring true,
From form to export, the app starts anew! 🎉

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Fix launchDesk' is vague and generic, using non-descriptive language that doesn't convey the specific nature of the changes made. Consider a more specific title that highlights the primary fix, such as 'Fix localStorage key, form validation, and search filtering in launchDesk app' or focus on the most critical bug fixed.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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: 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 `@js/app.js`:
- Around line 240-243: The day-difference calculation used for the dueSoon
bucket is off-by-one because daysUntil compares a parsed date (UTC midnight)
with new Date() (local time); update the daysUntil implementation so it
normalizes both the target date and "today" to local midnight (e.g.,
setHours(0,0,0,0) or equivalent) before computing the difference, then keep
using that corrected daysUntil when computing dueSoon in the expression that
filters checks.
🪄 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 Plus

Run ID: 8d7ebe84-bb73-46da-81d5-f1c7a51abb69

📥 Commits

Reviewing files that changed from the base of the PR and between ccb0d19 and d5c14d4.

📒 Files selected for processing (1)
  • js/app.js

Comment thread js/app.js
Comment on lines +240 to +243
const dueSoon = checks.filter((check) => {
const days = daysUntil(check.dueDate);
return days >= 0 && days <= 7;
}).length;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

In ECMAScript, does new Date("2026-05-10")parse as UTC or local time, and what is the recommended way to avoid off-by-one day errors when computing day differences againstnew Date()?

💡 Result:

  1. new Date("2026-05-10") is parsed as UTC midnight (2026-05-10T00:00:00Z), not local time. [1] So the Date object represents an instant at the start of the UTC day; when you display it using local-time getters/formatters (e.g., toString(), getFullYear(), etc.), it may appear as the previous day in time zones west of UTC (off-by-one in the display layer). 2) Recommended way to avoid off-by-one day errors when computing day differences vs new Date() For “calendar day” differences, don’t subtract raw timestamps coming from mixed origins/normalizations. Instead, normalize both sides to a consistent day boundary in the domain you care about (UTC for global/backend logic, or a specific IANA time zone via a library/Temporal). If you want UTC-based day differences using ISO date-only strings, parse them as UTC and then compute using UTC midnight: const start = new Date('2026-05-10T00:00:00Z'); const end = new Date; // Normalize end to UTC midnight too end.setUTCHours(0, 0, 0, 0); const msPerDay = 24 * 60 * 60 * 1000; const diffDays = Math.round((end - start) / msPerDay); Why this helps: Date math is based on instants (timestamps), while “day differences” are usually about calendar days; UTC avoids DST-length day problems because UTC days are always 86,400,000 ms, and normalization prevents partial-day values from producing 0.99/1.01 day rounding errors. [2][3] If you instead need “local calendar day” differences, normalize both dates using local midnight (via setHours(0,0,0,0)), or better, use an explicit time zone library rather than relying on environment locale/timezone rules. Sources: [1] MDN Date page explains: when timezone offset is absent, date-only forms are interpreted as a UTC time (with a historical spec compatibility note). [3] ECMAScript spec defines time values relative to UTC days and 86,400,000 ms per day boundaries. [2] Synyx article explains DST/day-length issues and that UTC avoids those problems for “how many days” calculations.

Citations:


🏁 Script executed:

git ls-files js/app.js

Repository: codezelaca/fs-se-debugging-bugs

Length of output: 85


🏁 Script executed:

if [ -f js/app.js ]; then wc -l js/app.js; fi

Repository: codezelaca/fs-se-debugging-bugs

Length of output: 89


🏁 Script executed:

if [ -f js/app.js ]; then sed -n '235,250p' js/app.js; fi

Repository: codezelaca/fs-se-debugging-bugs

Length of output: 701


🏁 Script executed:

rg "function daysUntil|const daysUntil" js/app.js -A 6

Repository: codezelaca/fs-se-debugging-bugs

Length of output: 276


Normalize day math before dueSoon bucketing.

The daysUntil() function compares new Date(dateValue) (which parses ISO strings like "2026-05-10" as UTC midnight) against new Date() (which uses local time). This timezone mismatch causes incorrect day-difference calculations, producing off-by-one counts near the 0 and 7-day boundaries depending on the local timezone and time of day.

Normalize both dates to local midnight before computing the difference:

Suggested fix
 function daysUntil(dateValue) {
-  const today = new Date();
-  const target = new Date(dateValue);
-  const difference = target.getTime() - today.getTime();
-  return Math.ceil(difference / 86400000);
+  if (!dateValue) return Number.POSITIVE_INFINITY;
+
+  const now = new Date();
+  const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
+
+  const [year, month, day] = String(dateValue).split("-").map(Number);
+  const target = new Date(year, month - 1, day);
+
+  return Math.floor((target.getTime() - today.getTime()) / 86400000);
 }
🤖 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 `@js/app.js` around lines 240 - 243, The day-difference calculation used for
the dueSoon bucket is off-by-one because daysUntil compares a parsed date (UTC
midnight) with new Date() (local time); update the daysUntil implementation so
it normalizes both the target date and "today" to local midnight (e.g.,
setHours(0,0,0,0) or equivalent) before computing the difference, then keep
using that corrected daysUntil when computing dueSoon in the expression that
filters checks.

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