Skip to content

Assignable Keyboard Shortcuts Updates - #4532

Merged
objecttothis merged 5 commits into
masterfrom
WebShells-CI4-Shortcuts
May 7, 2026
Merged

objecttothis merged 5 commits into
masterfrom
WebShells-CI4-Shortcuts

Conversation

@WebShells

@WebShells WebShells commented May 6, 2026 •

Copy link
Copy Markdown
Member

Few updates regarding HotKeys/ Keyboard Shortcut section.

. Added Shortcut TAB under config section where user can re-assign the shortcuts as needed
. Shortcuts Help Modal in Sales Register now reflects the assigned shortcuts
. Updates JS section in register in order to retreive assigned keys from database.
. Migration file
. Success message on submit
. Added the needed language strings and routes.
. CI4 Support shortcut configuration for sales hotkeys.

Updated version of #3720

Summary by CodeRabbit

  • New Features

    • Keyboard shortcuts configuration UI to customize and save bindings; client-side validation and duplicate-binding errors shown.
    • Sales register and help screens now use user-configured shortcuts (dynamic ALT-key behavior, supports completing sale after payment).
  • Localization

    • Added UI text for shortcuts, configuration, duplicate-binding warnings, and save errors.
  • Database

    • Migration to add default shortcut keys.

@WebShells
WebShells requested review from jekkos and objecttothis May 6, 2026 04:19
@WebShells WebShells self-assigned this May 6, 2026
@WebShells WebShells added enhancement CodeIgniter4 Issue relates to the conversion to CodeIgniter 4 labels May 6, 2026
@coderabbitai

coderabbitai Bot commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a keyboard-shortcut configuration system: default shortcuts seeded via migration, library accessors expose defaults and options, admin UI to view/save bindings with validation, controller endpoint to persist changes, and sales views/controllers updated to display and apply configured shortcuts.

Changes

Keyboard Shortcut Configuration System

Layer / File(s) Summary
Data Model & Defaults
app/Libraries/Sale_lib.php
KEY_SHORTCUT_DEFAULTS constant defines default shortcut entries (value, code, label) for ten sales actions.
Library Data Accessors
app/Libraries/Sale_lib.php
getKeyShortcutsOptions() returns value→label options; getKeyShortcuts() reads key_<name> from config with defaults and returns parsed {value, code, label} per shortcut.
Database Seeding
app/Database/Migrations/20260506000000_AddShortcutKeys.php
Migration up() inserts default key_* entries into app_config (batch insert ignoring duplicates); down() deletes those keys.
Language & UI Strings
app/Language/en/Config.php
Adds language keys: shortcuts, shortcuts_configuration, shortcuts_duplicate_bindings, shortcuts_save_error.
Configuration Backend
app/Controllers/Config.php
getIndex() exposes $this->config, keyboardShortcutOptions, and keyboardShortcuts to the manage view; new postSaveShortcuts() validates posted key_<name> values against allowed options, rejects duplicate bindings, and persists via appconfig->batch_save(), returning JSON success/error.
Configuration UI
app/Views/configs/manage.php, app/Views/configs/shortcuts_config.php
Manage view adds a "Shortcuts" tab; shortcuts_config.php renders a form with dropdowns for each shortcut, initializes data defaults, submits via AJAX, and shows success or localized error messages (including duplicate-binding errors).
Sales Register Integration
app/Controllers/Sales.php, app/Views/sales/register.php
Register controller/view now receive keyboardShortcuts; register view builds shortcutCodes and paymentsCoverTotal, replaces hardcoded ALT-key handlers with a dynamic onkeyup router that maps configured shortcuts to actions and conditionally completes sale after payment.
Sales Help View Update
app/Views/sales/help.php
Help view initializes $keyboardShortcuts and renders the system shortcuts table by iterating $shortcut_labels, preferring shortcut label then code, instead of hardcoded rows.

Sequence Diagram

sequenceDiagram
    actor Admin
    participant ConfigUI as Config UI
    participant ConfigCtrl as Config Controller
    participant DB as Database
    participant SalesUI as Sales Register
    participant SalesCtrl as Sales Controller
    participant SaleLib as Sale_lib

    rect rgba(100, 150, 255, 0.5)
    Note over Admin,DB: Keyboard Shortcut Configuration Flow
    Admin->>ConfigUI: Load shortcuts configuration tab
    ConfigUI->>ConfigCtrl: GET config/manage
    ConfigCtrl->>SaleLib: getKeyShortcuts()
    SaleLib->>DB: Read current key_* values
    DB-->>SaleLib: Return configured shortcuts
    SaleLib-->>ConfigCtrl: Return parsed shortcuts
    ConfigCtrl->>ConfigUI: Render manage view with shortcuts
    ConfigUI-->>Admin: Display shortcut configuration form
    Admin->>ConfigUI: Update shortcut bindings & submit
    ConfigUI->>ConfigCtrl: POST config/saveShortcuts
    ConfigCtrl->>ConfigCtrl: Validate against allowed options
    ConfigCtrl->>ConfigCtrl: Detect duplicate bindings
    alt Validation passes
        ConfigCtrl->>DB: batch_save key_* values
        DB-->>ConfigCtrl: Save successful
        ConfigCtrl-->>ConfigUI: Return JSON success
        ConfigUI-->>Admin: Show success notification
    else Duplicates detected
        ConfigCtrl-->>ConfigUI: Return JSON error
        ConfigUI-->>Admin: Show error message
    end
    end

    rect rgba(150, 255, 100, 0.5)
    Note over SalesUI,SaleLib: Keyboard Shortcut Usage Flow
    SalesCtrl->>SalesCtrl: _reload()
    SalesCtrl->>SaleLib: getKeyShortcuts()
    SaleLib->>DB: Read current key_* values
    DB-->>SaleLib: Return configured shortcuts
    SaleLib-->>SalesCtrl: Return parsed shortcuts
    SalesCtrl->>SalesUI: Render register with keyboardShortcuts
    SalesUI-->>SalesUI: Build shortcutCodes map from config
    Admin->>SalesUI: Press ALT + configured key
    SalesUI->>SalesUI: onkeyup handler maps code to action
    alt Action is "complete"
        SalesUI->>SalesUI: Check if payments cover total
        alt Payments cover total
            SalesUI->>SalesUI: Trigger finish sale
        else Insufficient payment
            SalesUI->>SalesUI: Trigger add payment
        end
    else Other action
        SalesUI->>SalesUI: Execute mapped action
    end
    end
Loading

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰 I nibble keys and map each bind,

ALT and code now intertwined.
Admin sets, the register obeys,
Saved with checks in tidy arrays.
Hops of joy for shortcuts refined.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 69.23% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Assignable Keyboard Shortcuts Updates' accurately captures the main change: implementing configurable keyboard shortcuts across the application, including a new config tab, database migration, and updated register UI.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch WebShells-CI4-Shortcuts

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


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
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (1)
app/Views/configs/shortcuts_config.php (1)

7-23: ⚡ Quick win

$shortcut_defaults duplicates Sale_lib::KEY_SHORTCUT_DEFAULTS — eliminatable.

This view re-implements the same default-resolution logic that Sale_lib::get_key_shortcuts() already provides. Adding a new shortcut in the future requires updating both Sale_lib.php and this view.

The Config controller's getIndex() should pass the output of $this->sale_lib->get_key_shortcuts() (which already returns resolved value/code/label per shortcut) so the view can use $keyboard_shortcuts[$name]['value'] for the dropdown selection, removing the need for $shortcut_defaults entirely.

♻️ Proposed refactor (view-side change)

In Config::getIndex(), add alongside $key_shortcuts_options:

// (additional code block, not a diff — goes in Config::getIndex())
$data['keyboard_shortcuts'] = $this->sale_lib->get_key_shortcuts();

Then in shortcuts_config.php:

-$shortcut_defaults = [
-    'cancel'    => '27 | ESC',
-    'items'     => '49 | ALT + 1',
-    'customers' => '50 | ALT + 2',
-    'suspend'   => '51 | ALT + 3',
-    'suspended' => '52 | ALT + 4',
-    'amount'    => '53 | ALT + 5',
-    'payment'   => '54 | ALT + 6',
-    'complete'  => '55 | ALT + 7',
-    'finish'    => '56 | ALT + 8',
-    'help'      => '57 | ALT + 9',
-];
-
-$shortcut_values = [];
-foreach ($shortcut_defaults as $name => $default_value) {
-    $shortcut_values[$name] = $config['key_' . $name] ?? $default_value;
-}
+/**
+ * `@var` array $keyboard_shortcuts  resolved by Sale_lib::get_key_shortcuts()
+ */

And in the dropdown call:

-                    $shortcut_values[$name],
+                    $keyboard_shortcuts[$name]['value'] ?? '',
🤖 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 `@app/Views/configs/shortcuts_config.php` around lines 7 - 23, Remove the
duplicated $shortcut_defaults and resolution logic in shortcuts_config.php and
instead consume the resolved shortcuts provided by
Sale_lib::get_key_shortcuts(); update Config::getIndex() to set
$data['keyboard_shortcuts'] = $this->sale_lib->get_key_shortcuts(); then in the
view replace any use of $shortcut_defaults/$shortcut_values with
$keyboard_shortcuts (e.g. use $keyboard_shortcuts[$name]['value'] for the
dropdown selection and build any needed mapping from that array), ensuring all
references to shortcut names use the keys in $keyboard_shortcuts so the view no
longer maintains its own defaults.
🤖 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 `@app/Controllers/Config.php`:
- Around line 962-973: Before calling
$this->appconfig->batch_save($batch_save_data) ensure no duplicate shortcut
values exist: after populating $batch_save_data from $current_shortcuts (and
using $this->request->getPost('key_'.$name) and $allowed_shortcuts), scan the
values for duplicates (the 'key_'.$name entries) and if any duplicates are
found, abort and return a validation error response indicating duplicate
shortcut bindings instead of calling batch_save(); this enforces uniqueness
server-side for current_shortcuts and prevents conflicting hotkeys.

In `@app/Database/Migrations/20260506000000_add_shortcut_keys.php`:
- Around line 30-35: The migration's down() is empty so rollback leaves the 10
inserted key_* rows in app_config; implement down() to undo what up() did by
deleting those rows and reversing any schema changes: in the migration class
(methods up() and down()) add logic in down() to remove the inserted app_config
entries (e.g., DB::table('app_config')->where('name', 'LIKE', 'key_%')->delete()
or explicitly whereIn(['key_1',...'key_10'])) and revert any other alterations
made in up() so a migrate:rollback returns the database to its prior state.

In `@app/Views/configs/manage.php`:
- Around line 32-34: The shortcuts child view expects $config but
Config::getIndex() never includes it in the view data; update the getIndex()
method to add the controller's config to the data array (set $data['config'] =
$this->config) before calling view()/render so the shortcuts_config.php child
view can access $config (refer to Config::getIndex(), $data array, and
$this->config).

In `@app/Views/configs/shortcuts_config.php`:
- Around line 86-91: Replace the hardcoded English fallback string used in the
AJAX error handler (the literal 'Unable to save Shortcut Settings.' used with
xhr.responseJSON?.message ?? xhr.responseText ?? ...) with a PHP-rendered
language string; add a key (e.g. "shortcuts_save_error") to the Config language
files (app/Language/*/Config.php) and echo that localized string into the script
block so the fallback becomes the PHP i18n value instead of the hardcoded text.

In `@app/Views/sales/register.php`:
- Around line 868-871: The hotkey handler for keyboardShortcuts.complete.code
currently triggers $("#add_payment_button").click() then immediately sets
window.location.href which can bypass the payment POST; change this to route
through the same form-submit flow used by the UI buttons (i.e., invoke the
payment form's submit handler or trigger the exact submit button/action that
performs the POST and wait for its success callback) instead of hard-redirecting
to site_url('sales/complete'); ensure the code waits for the add-payment
submission to finish (or its success callback) and only then calls the
completion routine or redirects to the completion endpoint.
- Around line 844-883: The shortcut handler dereferences
keyboardShortcuts.<action>.code directly inside document.body.onkeyup, which can
throw if entries are missing; fix by guarding lookups before comparing to
event.keyCode—e.g., in document.body.onkeyup (the Alt branch and the non-Alt
switch) first resolve each code with optional chaining or null-checks (e.g.,
const itemsCode = keyboardShortcuts?.items?.code) and then use those local
variables in the switch/case tests (or skip cases when code is undefined);
ensure all references like keyboardShortcuts.items.code,
keyboardShortcuts.customers.code, keyboardShortcuts.complete.code, etc., are
accessed via the guarded variables so missing shortcuts won’t cause a runtime
TypeError.

---

Nitpick comments:
In `@app/Views/configs/shortcuts_config.php`:
- Around line 7-23: Remove the duplicated $shortcut_defaults and resolution
logic in shortcuts_config.php and instead consume the resolved shortcuts
provided by Sale_lib::get_key_shortcuts(); update Config::getIndex() to set
$data['keyboard_shortcuts'] = $this->sale_lib->get_key_shortcuts(); then in the
view replace any use of $shortcut_defaults/$shortcut_values with
$keyboard_shortcuts (e.g. use $keyboard_shortcuts[$name]['value'] for the
dropdown selection and build any needed mapping from that array), ensuring all
references to shortcut names use the keys in $keyboard_shortcuts so the view no
longer maintains its own defaults.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: e3596562-2f35-489e-96b5-5c22305f4e22

📥 Commits

Reviewing files that changed from the base of the PR and between 7edefe8 and 078414f.

📒 Files selected for processing (10)
  • app/Config/Routes.php
  • app/Controllers/Config.php
  • app/Controllers/Sales.php
  • app/Database/Migrations/20260506000000_add_shortcut_keys.php
  • app/Language/en/Config.php
  • app/Libraries/Sale_lib.php
  • app/Views/configs/manage.php
  • app/Views/configs/shortcuts_config.php
  • app/Views/sales/help.php
  • app/Views/sales/register.php

Comment thread app/Controllers/Config.php Resolved
Comment thread app/Views/configs/manage.php Resolved
Comment thread app/Views/sales/register.php Resolved
Comment thread app/Views/sales/register.php Resolved
Comment thread app/Config/Routes.php Resolved
Comment thread app/Controllers/Config.php Resolved
Comment thread app/Controllers/Config.php Resolved
Comment thread app/Controllers/Sales.php Resolved
Comment thread app/Controllers/Sales.php Resolved
Comment thread app/Views/configs/shortcuts_config.php Resolved
Comment thread app/Views/sales/help.php Resolved
Comment thread app/Views/sales/help.php Resolved
Comment thread app/Views/sales/help.php Resolved
Comment thread app/Views/sales/register.php Resolved
@WebShells
WebShells force-pushed the WebShells-CI4-Shortcuts branch from 078414f to 328bde0 Compare May 6, 2026 13:25
@WebShells
WebShells requested a review from objecttothis May 6, 2026 13:30

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 `@app/Views/sales/register.php`:
- Around line 408-409: The hidden field complete_after_payment is never
set/consumed, so the Alt+Complete hotkey stops after adding a payment; update
the hotkey handler that triggers `#add_payment_button` to set
complete_after_payment=1 before submitting and modify Sales::postAddPayment() to
read and consume that flag (on successful payment create, proceed to complete
the sale/invoice flow and reset the flag) so the flow continues to completion;
reference the complete_after_payment hidden input, the `#add_payment_button`
handler, and Sales::postAddPayment() when making the changes.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3317aed0-7209-49d3-94b7-3b0a40d00aa7

📥 Commits

Reviewing files that changed from the base of the PR and between 078414f and 328bde0.

📒 Files selected for processing (9)
  • app/Controllers/Config.php
  • app/Controllers/Sales.php
  • app/Database/Migrations/20260506000000_AddShortcutKeys.php
  • app/Language/en/Config.php
  • app/Libraries/Sale_lib.php
  • app/Views/configs/manage.php
  • app/Views/configs/shortcuts_config.php
  • app/Views/sales/help.php
  • app/Views/sales/register.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/Language/en/Config.php

Comment thread app/Views/sales/register.php Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@app/Controllers/Sales.php`:
- Around line 475-478: The branch that auto-completes a sale when
$complete_after_payment is true unconditionally calls postComplete() even if
prior validation set errors (e.g., $data['error'] from the giftcard or
amount_tendered handling), so change the conditional to only call postComplete()
when there are no validation errors and amount_due is <= 0; specifically check
that empty($data['error']) (or equivalent validation flag) before invoking
postComplete(), and ensure you pass a string to bccomp by casting
$this->sale_lib->get_amount_due() to (string) to avoid implicit conversion
warnings.

In `@app/Views/sales/register.php`:
- Around line 570-571: The inline JSON emitted for keyboardShortcuts and
paymentsCoverTotal is not hardened for script context; update the calls to
json_encode in the register view (the lines setting keyboardShortcuts and
paymentsCoverTotal) to pass JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT |
JSON_HEX_AMP (and ensure a safe default like [] or false is used before
encoding) so characters like </script>, quotes and ampersands are escaped and
cannot break out into stored-XSS.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: b5870b1f-3895-478f-9ae8-d986e8e35437

📥 Commits

Reviewing files that changed from the base of the PR and between 328bde0 and 4f71057.

📒 Files selected for processing (2)
  • app/Controllers/Sales.php
  • app/Views/sales/register.php

Comment thread app/Controllers/Sales.php Resolved
Comment thread app/Views/sales/register.php Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@app/Views/sales/register.php`:
- Around line 884-889: The complete hotkey handler (shortcutCodes.complete) only
clicks `#finish_sale_button` when paymentsCoverTotal is true, but in non-POS flows
where `#finish_sale_button` is absent it falls back to submitting
`#add_payment_form` which is disabled and calls postAddPayment() incorrectly;
change the logic so when paymentsCoverTotal is true and `#finish_sale_button` does
not exist but `#finish_invoice_quote_button` exists (the active non-POS completion
action), trigger/click `#finish_invoice_quote_button` instead of submitting
`#add_payment_form`, otherwise preserve the existing branch that sets
complete_after_payment and submits `#add_payment_form`; ensure references to
shortcutCodes.complete, paymentsCoverTotal, `#finish_sale_button`,
`#finish_invoice_quote_button`, `#add_payment_form` and postAddPayment() are updated
accordingly.
- Around line 877-879: In the switch branch for shortcutCodes.amount in
register.php, replace the hard-coded selector "#amount_tendered" with a selector
that targets the currently enabled/visible tender input (e.g., the first enabled
input inside the tender inputs container) so the handler focuses and selects the
active tender field instead of a possibly disabled gift-card field; update the
focus/select calls in that case to query for an enabled input under the tender
controls (e.g., first enabled .tender input) and call focus() and select() on
it.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 31bb14db-79a8-4efa-853a-2a0f90c5b728

📥 Commits

Reviewing files that changed from the base of the PR and between 4f71057 and d6b2cde.

📒 Files selected for processing (2)
  • app/Controllers/Sales.php
  • app/Views/sales/register.php

Comment thread app/Views/sales/register.php Resolved
Comment thread app/Views/sales/register.php Resolved

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

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 `@app/Views/sales/register.php`:
- Around line 907-910: The cancel shortcut branch in the keyup handler (the
switch on event.keyCode that checks shortcutCodes.cancel and triggers
$("#cancel_sale_button").click()) runs for every bare key and will fire while
typing; change the logic so the configurable cancel binding only triggers when
combined with a modifier (e.g. require event.altKey) or keep Escape as a fixed
cancel (check for keyCode 27) and ignore plain printable keys — update the
switch/condition around shortcutCodes.cancel to test event.altKey (or explicitly
match Escape) before calling cancel_sale_button.click(), leaving existing cancel
button invocation unchanged.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 37800e32-de90-44d1-9ac6-f6ac735448dc

📥 Commits

Reviewing files that changed from the base of the PR and between d6b2cde and b0089d0.

📒 Files selected for processing (1)
  • app/Views/sales/register.php

Comment thread app/Views/sales/register.php Resolved
@coderabbitai

coderabbitai Bot commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 3 file(s) based on 1 unresolved review comment.

Files modified:

  • app/Views/login.php
  • app/Views/partial/header.php
  • app/Views/sales/register.php

Commit: 3f15f726112a9d7c279ee35500db90bde9f613b0

The changes have been pushed to the WebShells-CI4-Shortcuts branch.

Time taken: 2m 6s

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 `@app/Views/sales/register.php`:
- Around line 860-910: The key handler in document.body.onkeyup currently fires
shortcuts and the Escape cancel regardless of modals; update the handler to
first detect visible BootstrapDialog modals by checking $('.modal.in').length
and, if any modal is open, skip/return early so shortcuts (including the Escape
→ $("#cancel_sale_button").click()) are ignored while a modal (e.g., the
shortcuts help or modal-dlg) is active. Place this check at the top of the
document.body.onkeyup function (before the switch and before the Escape cancel
branch) so all shortcutCodes and the cancel behavior are suppressed when a
'.modal.in' exists.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 456636a8-3207-48cc-a3cf-b79d2c31f74a

📥 Commits

Reviewing files that changed from the base of the PR and between d6b2cde and 3f15f72.

📒 Files selected for processing (3)
  • app/Views/login.php
  • app/Views/partial/header.php
  • app/Views/sales/register.php

Comment thread app/Views/sales/register.php Resolved
@WebShells
WebShells force-pushed the WebShells-CI4-Shortcuts branch from f62097a to 328bde0 Compare May 6, 2026 18:30
@WebShells
WebShells force-pushed the WebShells-CI4-Shortcuts branch from 194c86b to 253954d Compare May 6, 2026 22:36

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
app/Views/configs/shortcuts_config.php (1)

31-31: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Escape rendered language output in view markup

On Line 31, render the language string through esc() for consistency with view output-escaping rules.

Suggested fix
-                    <div id="required_fields_message"><?= lang('Common.fields_required_message') ?></div>
+                    <div id="required_fields_message"><?= esc(lang('Common.fields_required_message')) ?></div>

As per coding guidelines, "Sanitize user input; escape output using esc() helper".

🤖 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 `@app/Views/configs/shortcuts_config.php` at line 31, The view currently
outputs the language string directly in the div with id
"required_fields_message"; wrap the lang('Common.fields_required_message') call
with the esc() helper to ensure consistent output escaping (i.e., replace the
direct lang(...) use inside the div#required_fields_message with
esc(lang(...))).
🤖 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 `@app/Views/configs/shortcuts_config.php`:
- Around line 74-79: The AJAX error handler passes unescaped xhr.responseText
(and possibly xhr.responseJSON.message) into $.notify which can lead to XSS;
update the error callback that builds the notify message (the block referencing
xhr and $.notify) to sanitize/escape any user-supplied text before
rendering—either call a shared escapeHtml(text) utility or convert the string
into a plain-text node (use textContent/createTextNode) and then pass the
escaped/plain-text string to $.notify, ensuring the fallback <?=
json_encode(lang('Config.shortcuts_save_error')) ?> remains unchanged.

---

Duplicate comments:
In `@app/Views/configs/shortcuts_config.php`:
- Line 31: The view currently outputs the language string directly in the div
with id "required_fields_message"; wrap the
lang('Common.fields_required_message') call with the esc() helper to ensure
consistent output escaping (i.e., replace the direct lang(...) use inside the
div#required_fields_message with esc(lang(...))).
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: f40cd178-2dc0-4abb-9fd2-c33dc5f49bb3

📥 Commits

Reviewing files that changed from the base of the PR and between f62097a and 253954d.

📒 Files selected for processing (9)
  • app/Controllers/Config.php
  • app/Controllers/Sales.php
  • app/Database/Migrations/20260506000000_AddShortcutKeys.php
  • app/Language/en/Config.php
  • app/Libraries/Sale_lib.php
  • app/Views/configs/manage.php
  • app/Views/configs/shortcuts_config.php
  • app/Views/sales/help.php
  • app/Views/sales/register.php
✅ Files skipped from review due to trivial changes (1)
  • app/Database/Migrations/20260506000000_AddShortcutKeys.php
🚧 Files skipped from review as they are similar to previous changes (7)
  • app/Views/configs/manage.php
  • app/Views/sales/help.php
  • app/Language/en/Config.php
  • app/Views/sales/register.php
  • app/Controllers/Sales.php
  • app/Libraries/Sale_lib.php
  • app/Controllers/Config.php

Comment thread app/Views/configs/shortcuts_config.php Resolved
objecttothis
objecttothis previously approved these changes May 7, 2026

@objecttothis objecttothis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Take a look at the two suggestions I made. Fix them if you want. Otherwise we are ready for you to squash and merge.

Comment thread app/Language/en/Config.php Resolved
Comment thread app/Views/configs/shortcuts_config.php Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 `@app/Views/configs/shortcuts_config.php`:
- Around line 67-72: The success callback currently passes response.message
directly into $.notify (in the success handler), creating an XSS risk; update
that handler to sanitize the message using DOMPurify.sanitize() before passing
it to $.notify (mirror the sanitization used in the error handler), i.e.,
replace direct use of response.message in the success handler with a sanitized
variable via DOMPurify.sanitize(response.message) so $.notify receives only the
cleaned string.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7f79f21b-83d3-415d-ac01-90ecba88cb2c

📥 Commits

Reviewing files that changed from the base of the PR and between ff36d3d and 9e6a6df.

📒 Files selected for processing (3)
  • app/Controllers/Config.php
  • app/Language/en/Config.php
  • app/Views/configs/shortcuts_config.php
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/Language/en/Config.php
  • app/Controllers/Config.php

Comment thread app/Views/configs/shortcuts_config.php Resolved
@WebShells
WebShells requested a review from objecttothis May 7, 2026 16:21
@objecttothis
objecttothis merged commit 81213f0 into master May 7, 2026
13 checks passed
@objecttothis
objecttothis deleted the WebShells-CI4-Shortcuts branch May 7, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CodeIgniter4 Issue relates to the conversion to CodeIgniter 4 enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants