Skip to content

RI-8122 Add "Insert timestamp" to suggestions, help widget, and context menu#5635

Open
pd-redis wants to merge 7 commits intomainfrom
fe/feature/RI-8122/datetime-widgets
Open

RI-8122 Add "Insert timestamp" to suggestions, help widget, and context menu#5635
pd-redis wants to merge 7 commits intomainfrom
fe/feature/RI-8122/datetime-widgets

Conversation

@pd-redis
Copy link
Contributor

@pd-redis pd-redis commented Mar 13, 2026

What

  • Keeps the existing toolbar Timestamp button and DateTimePicker popover unchanged.
  • Adds "Insert timestamp" in three places, all opening the same popover:
    • Suggestions: When the cursor is on a unix-time argument (e.g. EXPIREAT mykey or SET key value PXAT ), a completion item "Insert timestamp..." is shown; choosing it opens the date/time picker and inserts nothing.
    • Help-style UI: When the cursor is on a unix-time argument, an "Insert timestamp" button appears in the query footer (next to Tutorials); it opens the same picker.
    • Context menu: Right-click in the editor shows "Insert timestamp"; it opens the same picker.
  • Picker state is lifted to QueryEditorContext (from QueryWrapper) so all entry points use the same open/close/show logic.
  • Suggestion acceptance is handled in onWillInsertSuggestItem so the picker opens reliably when "Insert timestamp..." is selected.
  • Context menu and command handlers use a ref for openTimestampPicker so they always call the current callback.

Demo:

Screen.Recording.2026-03-13.at.9.52.10.mov

Testing

  1. Toolbar: With a command that has unix-time args (e.g. EXPIREAT mykey or SET k v PXAT), click the Timestamp button → picker opens; pick date/time and Insert → value is inserted at cursor.
  2. Suggestions: Type EXPIREAT mykey (space after mykey) → "Insert timestamp..." appears in the list; select it (Enter or click) → picker opens; no text is inserted.
  3. Help button: With cursor after EXPIREAT mykey , confirm "Insert timestamp" appears in the footer; click it → picker opens.
  4. Context menu: Right-click in the editor → "Insert timestamp" is in the menu; click it → picker opens.

Closes #RI-8122

Made with Cursor


Note

Medium Risk
Adds new date/time picker UI paths and Monaco editor commands/actions that modify query-editor interactions and suggestion behavior; regressions could affect autocomplete/help widgets and cursor insertions. Dependency updates (react-day-picker v9) and new time/date components increase UI surface area but are scoped to Workbench.

Overview
Adds a reusable date/time picking UI (RiCalendar, RiDatePicker, RiTimeInput, and DateTimePicker) and wires it into the Workbench query editor to insert Unix timestamps at the cursor.

Extends Monaco integration to expose “Insert timestamp” via autocomplete (a new Insert timestamp... completion item for unix-time args), a context-menu action, and a footer help button that appears when the cursor is on a unix-time argument. Timestamp picker open/close state is lifted into QueryEditorContext, and unix-time detection is added via a new ICommandTokenType.UnixTime plus helpers/tests (commandHasUnixTimeArgs, findSuggestionsByArg updates).

Written by Cursor Bugbot for commit f119c65. This will update automatically on new commits. Configure here.

- Introduced `RiCalendar` and `RiDatePicker` components for enhanced date selection functionality.
- Integrated `react-day-picker` for calendar UI and added styles for better presentation.
- Updated `QueryActions` to include a timestamp picker that inserts Unix timestamps into the query editor.
- Added utility functions for handling Unix time arguments in commands.

References: #RI-XXXX
- Adjusted calendar component styles for improved layout and spacing.
- Updated date picker positioning and button size for better usability.
- Refactored calendar component to streamline locale handling and remove unused code.

References: #RI-8122
…nput components

- Introduced comprehensive unit tests for the `RiCalendar`, `RiDatePicker`, and `RiTimeInput` components to ensure proper rendering and functionality.
- Tests cover rendering, interaction, and state management for each component, enhancing overall test coverage and reliability.
- Added a timestamp picker feature to the query editor, allowing users to insert Unix timestamps directly into their queries.
- Integrated a new command for opening the timestamp picker and updated the UI to display a button when the cursor is on a Unix time argument.
- Refactored related components and hooks to support the new functionality, including updates to context and completion suggestions.

References: #RI-XXXX
- Updated the query editor to utilize a ref for the timestamp picker, ensuring consistent access to the picker function across different contexts.
- Modified the autocomplete suggestions to trigger the timestamp picker when the corresponding suggestion is accepted.
- Added a new prop to the `useRedisCompletions` hook for handling timestamp insertion from suggestions.
- Implemented unit tests to verify the correct behavior of timestamp suggestions when the cursor is positioned on Unix time arguments.
@jit-ci
Copy link

jit-ci bot commented Mar 13, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

- Updated the timestamp validation logic in the QueryActions component to check for null values explicitly, enhancing robustness in handling timestamp insertion.
- Refactored the logic for determining if the current argument is a Unix time type, improving accuracy by introducing a new helper function, `isArgUnixTimePosition`.
- This change allows for better handling of oneof/block arguments that may contain Unix time, ensuring more robust timestamp validation in the query editor.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

const showTimestampPicker = useMemo(
() => commandHasUnixTimeArgs(REDIS_COMMANDS, query),
[REDIS_COMMANDS, query],
)
Copy link

Choose a reason for hiding this comment

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

Multiline query breaks toolbar timestamp button visibility

Medium Severity

commandHasUnixTimeArgs splits the full editor query by whitespace (/\s+/) and only examines the first token as the command name. In the workbench, the editor can contain multiple commands across lines. For a query like GET key\nEXPIREAT mykey , the first token is GET, so showTimestampPicker evaluates to false — hiding both the toolbar Timestamp button and the "Insert timestamp" help widget, even though the cursor is on an EXPIREAT line. Since showTimestampPicker gates currentArgIsUnixTime in Query.tsx, the cursor-aware check never gets a chance to show the UI.

Additional Locations (1)
Fix in Cursor Fix in Web

return [now.getHours(), now.getMinutes(), now.getSeconds()]
.map((n) => String(n).padStart(2, '0'))
.join(':')
}
Copy link

Choose a reason for hiding this comment

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

Duplicated time-formatting logic across two files

Low Severity

formatCurrentTime in RiTimeInput.tsx and buildTimeString in DateTimePicker.tsx implement identical logic — formatting a Date's hours, minutes, and seconds into an HH:MM:SS string with zero-padding. The only difference is formatCurrentTime hardcodes new Date() while buildTimeString accepts a Date parameter. These could be unified into a single shared utility.

Additional Locations (1)
Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant