Skip to content

Conversation

@yileicn
Copy link
Member

@yileicn yileicn commented Jan 30, 2026

User description

  • Add SpecificDay enum to TimeRange options
  • Extend convertTimeRange function to support specific date parameter
  • Add date picker UI when "Specific day" is selected in conversation and instruction log pages
  • Update ConversationSearchOption type definition to include specificDate field
  • Position SpecificDay option after Yesterday in dropdown menu

Users can now query data for a specific date (e.g., 2026-01-25) by selecting "Specific day" from the time range dropdown and choosing a date.


PR Type

Enhancement


Description

  • Add "Specific day" time range option to filter conversations and instruction logs

  • Implement date picker UI that appears when "Specific day" is selected

  • Extend convertTimeRange function to handle specific date parameter

  • Update search option types to include specificDate field for date storage


Diagram Walkthrough

flowchart LR
  A["User selects<br/>Specific day"] --> B["Date picker<br/>appears"]
  B --> C["User picks<br/>date"]
  C --> D["convertTimeRange<br/>processes date"]
  D --> E["Query filtered<br/>by specific date"]
Loading

File Walkthrough

Relevant files
Enhancement
+page.svelte
Add specific day date picker to conversation search           

src/routes/page/conversation/+page.svelte

  • Add getTodayStr helper function to format current date as YYYY-MM-DD
  • Initialize specificDate field in searchOption object
  • Pass specificDate parameter to convertTimeRange calls
  • Add conditional date picker input that displays when SpecificDay is
    selected
  • Update timeRange change handler to set specificDate when SpecificDay
    is chosen
+20/-3   
+page.svelte
Add specific day date picker to instruction log search     

src/routes/page/instruction/log/+page.svelte

  • Add getTodayStr helper function to format current date as YYYY-MM-DD
  • Initialize specificDate field in searchOption object
  • Pass specificDate parameter to convertTimeRange calls
  • Add conditional date picker input that displays when SpecificDay is
    selected
  • Update timeRange change handler to set specificDate when SpecificDay
    is chosen
+20/-3   
enums.js
Add SpecificDay enum to TimeRange                                               

src/lib/helpers/enums.js

  • Add SpecificDay enum value with label "Specific day"
  • Position after Yesterday in the timeRange enum object
+1/-0     
common.js
Extend convertTimeRange to support specific date                 

src/lib/helpers/utils/common.js

  • Add specificDate parameter to convertTimeRange function signature
  • Add JSDoc documentation for specificDate parameter
  • Implement SpecificDay case in switch statement
  • Parse specificDate and convert to UTC start and end times using
    moment.js
  • Validate specificDate before processing
+13/-1   
Configuration changes
constants.js
Add SpecificDay to time range options constant                     

src/lib/helpers/constants.js

  • Add SpecificDay option to TIME_RANGE_OPTIONS array
  • Position SpecificDay after Yesterday in the dropdown menu
  • Mark option with isSpecificDay flag for UI differentiation
+1/-0     
Documentation
conversationTypes.js
Add specificDate property to search option type                   

src/lib/helpers/types/conversationTypes.js

  • Add specificDate property to ConversationSearchOption type definition
  • Document that specificDate is used when timeRange is SpecificDay
  • Specify date format as YYYY-MM-DD with example
+1/-0     

- Add SpecificDay enum to TimeRange options
- Extend convertTimeRange function to support specific date parameter
- Add date picker UI when "Specific day" is selected in conversation and instruction log pages
- Update ConversationSearchOption type definition to include specificDate field
- Position SpecificDay option after Yesterday in dropdown menu

Users can now query data for a specific date (e.g., 2026-01-25) by selecting
"Specific day" from the time range dropdown and choosing a date.
@qodo-code-review
Copy link

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

🔴
Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Silent invalid date: When timeRange is TimeRange.SpecificDay and specificDate is missing/invalid,
convertTimeRange silently returns null start/end times which can unintentionally broaden
queries instead of failing closed or applying a safe default.

Referred Code
case TimeRange.SpecificDay:
    if (specificDate && moment(specificDate).isValid()) {
        ret = {
            ...ret,
            // @ts-ignore
            startTime: moment(specificDate).startOf('day').utc().format(),
            // @ts-ignore
            endTime: moment(specificDate).endOf('day').utc().format()
        };
    }
    break;

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
Non-strict date parse: convertTimeRange validates specificDate with moment(specificDate).isValid() which is
non-strict and may accept unexpected formats, allowing malformed input to influence
filtering rather than enforcing YYYY-MM-DD strictly.

Referred Code
if (specificDate && moment(specificDate).isValid()) {
    ret = {
        ...ret,
        // @ts-ignore
        startTime: moment(specificDate).startOf('day').utc().format(),
        // @ts-ignore
        endTime: moment(specificDate).endOf('day').utc().format()
    };

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Enforce strict date parsing

In the convertTimeRange function, use strict moment.js parsing to validate the
specificDate against the 'YYYY-MM-DD' format and use moment.utc to avoid
timezone issues.

src/lib/helpers/utils/common.js [244-254]

 case TimeRange.SpecificDay:
-    if (specificDate && moment(specificDate).isValid()) {
+    if (specificDate && moment(specificDate, 'YYYY-MM-DD', true).isValid()) {
         ret = {
-            ...ret,
-            // @ts-ignore
-            startTime: moment(specificDate).startOf('day').utc().format(),
-            // @ts-ignore
-            endTime: moment(specificDate).endOf('day').utc().format()
+            startTime: moment.utc(specificDate, 'YYYY-MM-DD').startOf('day').format(),
+            endTime: moment.utc(specificDate, 'YYYY-MM-DD').endOf('day').format()
         };
     }
     break;
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly proposes using strict date format validation and moment.utc to improve robustness, prevent potential timezone issues, and remove @ts-ignore comments.

Medium
Refactor duplicated function to a utility

Move the duplicated getTodayStr function to a shared utility file and simplify
its implementation using moment.js to avoid code duplication.

src/routes/page/conversation/+page.svelte [41-50]

 	const pageSize = 15;
-
-	// Get today's date in YYYY-MM-DD format
-	const getTodayStr = () => {
-		const d = new Date();
-		return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0');
-	};
 
 	/** @type {boolean} */
 	let isLoading = false;
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies duplicated code across two files and proposes a valid refactoring to a shared utility, which improves maintainability and follows the DRY principle.

Low
Possible issue
Throw an error for invalid input

Modify the convertTimeRange function to throw an error for invalid timeRange
inputs instead of returning an object with null values.

src/lib/helpers/utils/common.js [198-208]

 export function convertTimeRange(timeRange, specificDate) {
     let ret = { startTime: null, endTime: null };
 
     if (!timeRange) {
-        return ret;
+        throw new Error("timeRange parameter cannot be empty.");
     }
 
     const found = TIME_RANGE_OPTIONS.find(x => x.value === timeRange);
     if (!found) {
-        return ret;
+        throw new Error(`Invalid timeRange: ${timeRange}`);
     }
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why: This is a valid suggestion for improving robustness by failing fast, but the current implementation of returning null values is also a reasonable design choice and appears to be handled correctly by the calling code.

Low
  • More

@Ryan-Freya
Copy link

Reviewed

@iceljc iceljc merged commit ec4d358 into SciSharp:main Jan 30, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants