Skip to content

Fix Modified timestamp in commands.js#1316

Open
k-sumayya wants to merge 2 commits intoopenwisp:masterfrom
k-sumayya:fix-modified-timestamp
Open

Fix Modified timestamp in commands.js#1316
k-sumayya wants to merge 2 commits intoopenwisp:masterfrom
k-sumayya:fix-modified-timestamp

Conversation

@k-sumayya
Copy link
Copy Markdown

Fixes #1263

Description

The "Modified" field in Recent Commands was incorrectly using response.created, which caused it to display the creation timestamp instead of the last modification time.

This PR updates the implementation to use response.modified, ensuring consistency with the API response and WebSocket handler.

Changes

  • Replaced response.created with response.modified in commands.js

Testing

  • Set up OpenWISP locally
  • Reproduced the issue where "Modified" showed incorrect timestamp
  • Applied the fix
  • Verified that the Modified field now shows correct updated timestamp

Impact

  • Fixes incorrect UI behavior
  • Aligns frontend with backend data

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 24, 2026

📝 Walkthrough

Walkthrough

This PR advances the openwisp-controller submodule pointer and applies two small fixes: (1) AbstractVpnClient._get_common_name no longer mutates the device's name when truncating it (uses a local name variable and passes it into the CN formatting), and (2) the Recent Commands UI now uses response.modified for the "Modified" field instead of response.created.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • #1263: Fixes the Recent Commands row using created for the "Modified" field — this PR changes the UI to use response.modified.
  • #1284: Related to AbstractVpnClient._get_common_name mutating device name — this PR prevents mutation by using a local truncated name.

Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ❌ Error The PR contains changes to openwisp-controller submodule and vpn.py that are unrelated to the primary objective of fixing the Modified timestamp in commands.js. Remove unrelated changes (submodule commit and vpn.py mutation fix) or clarify their relationship to issue #1263 in the description.
Title check ⚠️ Warning The title lacks the required type prefix (e.g., [fix], [change]). It should follow the format '[type] Descriptive title'. Update the title to '[fix] Modified timestamp in commands.js' to comply with the required format.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description is comprehensive and mostly follows the template, covering reference to issue #1263, clear description of changes, testing performed, and impact assessment.
Linked Issues check ✅ Passed The PR successfully addresses issue #1263 by replacing response.created with response.modified in commands.js to fix the Modified timestamp display in Recent Commands.
Bug Fixes ✅ Passed One-line fix replaces response.created with response.modified for Modified field, directly addressing bug #1263 root cause.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown
Contributor

@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.

Caution

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

⚠️ Outside diff range comments (1)
openwisp-controller (1)

1-54: ⚠️ Potential issue | 🟠 Major

PR scope mismatch: this change set does not implement the timestamp bug fix.

From Line 1 onward, this submodule update only includes CI workflow changes (.github/workflows/bot-ci-failure.yml). I don’t see the required frontend change in connection/static/connection/js/commands.js (response.createdresponse.modified) described in the PR objective, so the reported user-facing bug would remain unaddressed in this diff.

Please update the submodule pointer (or include the intended commit) that contains the commands.js fix.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openwisp-controller` around lines 1 - 54, The PR only updates the CI workflow
and is missing the frontend timestamp fix; update the submodule pointer (or
include the missing commit) that contains the change in
connection/static/connection/js/commands.js where the code should use
response.modified instead of response.created (search for the symbol
response.created in commands.js and replace it with response.modified), then
commit the updated submodule reference (or add the file change) so the PR
includes both the CI updates and the frontend bugfix.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@openwisp-controller`:
- Around line 1-54: The PR only updates the CI workflow and is missing the
frontend timestamp fix; update the submodule pointer (or include the missing
commit) that contains the change in connection/static/connection/js/commands.js
where the code should use response.modified instead of response.created (search
for the symbol response.created in commands.js and replace it with
response.modified), then commit the updated submodule reference (or add the file
change) so the PR includes both the CI updates and the frontend bugfix.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ac9b0fdc-561e-4441-9330-baaac54d89c4

📥 Commits

Reviewing files that changed from the base of the PR and between d4d013f and aa5fb9c.

📒 Files selected for processing (3)
  • openwisp-controller
  • openwisp_controller/config/base/vpn.py
  • openwisp_controller/connection/static/connection/js/commands.js
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.12 | django~=4.2.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=5.2.0
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp}

📄 CodeRabbit inference engine (Custom checks)

**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp}: Flag potential security vulnerabilities in code
Avoid unnecessary comments or docstrings for code that is already clear
Code formatting is compact and readable. Do not add excessive blank lines, especially inside function or method bodies
Flag unused or redundant code
Ensure variables, functions, classes, and files have descriptive and consistent names
New code must handle errors properly: log errors that cannot be resolved by the user with error level, log unusual conditions with warning level, log important background actions with info level, and provide user-facing messages for errors that the user can solve autonomously

Files:

  • openwisp_controller/connection/static/connection/js/commands.js
  • openwisp_controller/config/base/vpn.py
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp,sql}

📄 CodeRabbit inference engine (Custom checks)

Flag obvious performance regressions, such as heavy loops, repeated I/O, or unoptimized queries

Files:

  • openwisp_controller/connection/static/connection/js/commands.js
  • openwisp_controller/config/base/vpn.py
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp,sh,bash,sql}

📄 CodeRabbit inference engine (Custom checks)

Cryptic or non-obvious code (regex, complex bash commands, or hard-to-read code) must include a concise comment explaining why it is needed and why the complexity is acceptable

Files:

  • openwisp_controller/connection/static/connection/js/commands.js
  • openwisp_controller/config/base/vpn.py
**/*.{py,html}

📄 CodeRabbit inference engine (Custom checks)

For Django pull requests, ensure all user-facing strings are marked as translatable using the Django i18n framework

Files:

  • openwisp_controller/config/base/vpn.py
🧠 Learnings (4)
📚 Learning: 2026-02-17T19:13:17.774Z
Learnt from: nemesifier
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/config/whois/commands.py:0-0
Timestamp: 2026-02-17T19:13:17.774Z
Learning: The openwisp-controller repository does not use Ruff as a linting tool. Do not suggest code changes based on Ruff warnings for this repository.

Applied to files:

  • openwisp-controller
📚 Learning: 2026-01-15T15:05:49.557Z
Learnt from: DragnEmperor
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/config/management/commands/clear_last_ip.py:38-42
Timestamp: 2026-01-15T15:05:49.557Z
Learning: In Django projects, when using select_related() to traverse relations (for example, select_related("organization__config_settings")), the traversed relation must not be deferred. If you also use .only() in the same query, include the relation name or FK field (e.g., "organization" or "organization_id") in the .only() list to avoid the error "Field X cannot be both deferred and traversed using select_related at the same time." Apply this guideline to Django code in openwisp_controller/config/management/commands/clear_last_ip.py and similar modules by ensuring any select_related with an accompanying only() includes the related field names to prevent deferred/traversed conflicts.

Applied to files:

  • openwisp_controller/config/base/vpn.py
📚 Learning: 2026-02-17T19:13:10.088Z
Learnt from: nemesifier
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/config/whois/commands.py:0-0
Timestamp: 2026-02-17T19:13:10.088Z
Learning: In reviews for the openwisp/openwisp-controller repository, do not propose changes based on Ruff warnings. The project does not use Ruff as its linter; ignore Ruff-related suggestions and follow the repository’s established linting and configuration rules. This guidance applies to all Python files under the openwisp_controller directory.

Applied to files:

  • openwisp_controller/config/base/vpn.py
📚 Learning: 2026-01-15T15:07:17.354Z
Learnt from: DragnEmperor
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/geo/estimated_location/tests/tests.py:172-175
Timestamp: 2026-01-15T15:07:17.354Z
Learning: In this repository, flake8 enforces E501 (line too long) via setup.cfg (max-line-length = 88) while ruff ignores E501 via ruff.toml. Therefore, use '# noqa: E501' on lines that intentionally exceed 88 characters to satisfy flake8 without affecting ruff checks. This applies to Python files across the project (any .py) and is relevant for tests as well. Use sparingly and only where breaking lines is not feasible without hurting readability or functionality.

Applied to files:

  • openwisp_controller/config/base/vpn.py
🔇 Additional comments (3)
openwisp_controller/connection/static/connection/js/commands.js (1)

507-509: Correct mapping for “Modified” timestamp.

Line 508 now uses response.modified, which matches the field label and backend payload, so the Recent Commands UI will display the right timestamp.

As per coding guidelines, "Ensure variables, functions, classes, and files have descriptive and consistent names," and this change restores consistent field-to-value mapping.

openwisp_controller/config/base/vpn.py (1)

895-901: Good fix: avoids mutating device.name while preserving CN formatting.

Line 895 and Line 900 correctly keep truncation local (name) and pass that value into formatting, which aligns behavior without mutating model state. No new correctness/security/performance issues in this segment.

openwisp-controller (1)

17-21: Good least-privilege permission scoping in workflow.

Line 19 reduces global permissions, and Line 48-Line 51 scopes write permissions to the specific job that needs them. This is a solid security improvement.

Also applies to: 48-51

@k-sumayya k-sumayya force-pushed the fix-modified-timestamp branch from aa5fb9c to c40911a Compare March 24, 2026 11:53
@openwisp-companion
Copy link
Copy Markdown

Commit Message Format Failure

Hello @k-sumayya,
(Analysis for commit c40911a)

The commit message is not in the correct format. The issue number referenced in the title must also be included in the body.

Example of correct format:

[fix] Fix incorrect Modified timestamp in Recent Commands #1263

This commit addresses an issue where the Modified timestamp was not being
updated correctly for recent commands.

Fixes #1263

@k-sumayya k-sumayya force-pushed the fix-modified-timestamp branch from c40911a to b2dd709 Compare March 24, 2026 13:08
@coveralls
Copy link
Copy Markdown

coveralls commented Mar 24, 2026

Coverage Status

coverage: 98.658%. remained the same
when pulling 4dc5fc1 on k-sumayya:fix-modified-timestamp
into d4d013f on openwisp:master.

This commit fixes an issue where the Modified timestamp
was incorrectly using response.created instead of response.modified.

Fixes openwisp#1263
@k-sumayya k-sumayya force-pushed the fix-modified-timestamp branch from b2dd709 to 54cb1ec Compare March 24, 2026 13:28
Copy link
Copy Markdown
Contributor

@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 the current code and only fix it if needed.

Inline comments:
In `@openwisp-controller`:
- Line 1: The submodule pointer currently references commit d4d013f... which
doesn't include the bug fix for issue `#1263`; update the submodule reference in
the repository to the commit that contains the commands.js fix (54cb1ec) so the
change from response.created to response.modified is included, then run git
submodule sync && git submodule update --init --recursive (or update the
submodule SHA in the parent repo and commit that change) ensuring the new
pointer points to commit 54cb1ec that includes the commands.js modification.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 2c4d042e-ccb2-4758-a785-04695c04fd1a

📥 Commits

Reviewing files that changed from the base of the PR and between b2dd709 and 54cb1ec.

📒 Files selected for processing (3)
  • openwisp-controller
  • openwisp_controller/config/base/vpn.py
  • openwisp_controller/connection/static/connection/js/commands.js
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=4.2.0
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp}

📄 CodeRabbit inference engine (Custom checks)

**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp}: Flag potential security vulnerabilities in code
Avoid unnecessary comments or docstrings for code that is already clear
Code formatting is compact and readable. Do not add excessive blank lines, especially inside function or method bodies
Flag unused or redundant code
Ensure variables, functions, classes, and files have descriptive and consistent names
New code must handle errors properly: log errors that cannot be resolved by the user with error level, log unusual conditions with warning level, log important background actions with info level, and provide user-facing messages for errors that the user can solve autonomously

Files:

  • openwisp_controller/connection/static/connection/js/commands.js
  • openwisp_controller/config/base/vpn.py
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp,sql}

📄 CodeRabbit inference engine (Custom checks)

Flag obvious performance regressions, such as heavy loops, repeated I/O, or unoptimized queries

Files:

  • openwisp_controller/connection/static/connection/js/commands.js
  • openwisp_controller/config/base/vpn.py
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp,sh,bash,sql}

📄 CodeRabbit inference engine (Custom checks)

Cryptic or non-obvious code (regex, complex bash commands, or hard-to-read code) must include a concise comment explaining why it is needed and why the complexity is acceptable

Files:

  • openwisp_controller/connection/static/connection/js/commands.js
  • openwisp_controller/config/base/vpn.py
**/*.{py,html}

📄 CodeRabbit inference engine (Custom checks)

For Django pull requests, ensure all user-facing strings are marked as translatable using the Django i18n framework

Files:

  • openwisp_controller/config/base/vpn.py
🧠 Learnings (4)
📚 Learning: 2026-02-17T19:13:17.774Z
Learnt from: nemesifier
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/config/whois/commands.py:0-0
Timestamp: 2026-02-17T19:13:17.774Z
Learning: The openwisp-controller repository does not use Ruff as a linting tool. Do not suggest code changes based on Ruff warnings for this repository.

Applied to files:

  • openwisp-controller
📚 Learning: 2026-01-15T15:05:49.557Z
Learnt from: DragnEmperor
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/config/management/commands/clear_last_ip.py:38-42
Timestamp: 2026-01-15T15:05:49.557Z
Learning: In Django projects, when using select_related() to traverse relations (for example, select_related("organization__config_settings")), the traversed relation must not be deferred. If you also use .only() in the same query, include the relation name or FK field (e.g., "organization" or "organization_id") in the .only() list to avoid the error "Field X cannot be both deferred and traversed using select_related at the same time." Apply this guideline to Django code in openwisp_controller/config/management/commands/clear_last_ip.py and similar modules by ensuring any select_related with an accompanying only() includes the related field names to prevent deferred/traversed conflicts.

Applied to files:

  • openwisp_controller/config/base/vpn.py
📚 Learning: 2026-02-17T19:13:10.088Z
Learnt from: nemesifier
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/config/whois/commands.py:0-0
Timestamp: 2026-02-17T19:13:10.088Z
Learning: In reviews for the openwisp/openwisp-controller repository, do not propose changes based on Ruff warnings. The project does not use Ruff as its linter; ignore Ruff-related suggestions and follow the repository’s established linting and configuration rules. This guidance applies to all Python files under the openwisp_controller directory.

Applied to files:

  • openwisp_controller/config/base/vpn.py
📚 Learning: 2026-01-15T15:07:17.354Z
Learnt from: DragnEmperor
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/geo/estimated_location/tests/tests.py:172-175
Timestamp: 2026-01-15T15:07:17.354Z
Learning: In this repository, flake8 enforces E501 (line too long) via setup.cfg (max-line-length = 88) while ruff ignores E501 via ruff.toml. Therefore, use '# noqa: E501' on lines that intentionally exceed 88 characters to satisfy flake8 without affecting ruff checks. This applies to Python files across the project (any .py) and is relevant for tests as well. Use sparingly and only where breaking lines is not feasible without hurting readability or functionality.

Applied to files:

  • openwisp_controller/config/base/vpn.py
🔇 Additional comments (2)
openwisp_controller/connection/static/connection/js/commands.js (1)

507-509: Correct timestamp source for Modified field (Line 508) — LGTM.

Switching to response.modified fixes the incorrect UI mapping and aligns this render path with backend serializer data and websocket updates.

openwisp_controller/config/base/vpn.py (1)

895-902: Excellent fix to eliminate side effects!

The refactoring correctly prevents mutation of d.name by:

  • Creating a local name variable with the truncated value (line 895)
  • Using the local name in the ZeroTier format comparison (line 898)
  • Overriding the name key when spreading d.__dict__ to ensure the format string receives the truncated value (line 900)

This maintains the same logical behavior while eliminating the unintended side effect of modifying the device's name attribute.

@@ -0,0 +1 @@
Subproject commit d4d013f39eafc701089f287785c3aed81c07f7bd
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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Submodule pointer in current branch =="
git ls-tree HEAD openwisp-controller

echo
echo "== Recent commits in submodule checkout =="
git -C openwisp-controller log --oneline -n 15 || true

echo
echo "== Files changed in target commit =="
git -C openwisp-controller show --name-only --pretty=format:'%H %s' d4d013f39eafc701089f287785c3aed81c07f7bd

echo
echo "== Inspect commands.js at target commit for created/modified usage =="
git -C openwisp-controller show d4d013f39eafc701089f287785c3aed81c07f7bd:connection/static/connection/js/commands.js | rg -n 'response\.(created|modified)|Modified:'

Repository: openwisp/openwisp-controller

Length of output: 662


Submodule pointer does not include the bug fix for issue #1263.

The submodule pointer at line 1 points to commit d4d013f..., which only updates .github/workflows/bot-ci-failure.yml. The actual bug fix for issue #1263 (updating response.created to response.modified in commands.js) is in a different commit (54cb1ec). The current pointer does not deliver the promised user-facing fix.

Update the submodule pointer to include the bug fix commit.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openwisp-controller` at line 1, The submodule pointer currently references
commit d4d013f... which doesn't include the bug fix for issue `#1263`; update the
submodule reference in the repository to the commit that contains the
commands.js fix (54cb1ec) so the change from response.created to
response.modified is included, then run git submodule sync && git submodule
update --init --recursive (or update the submodule SHA in the parent repo and
commit that change) ensuring the new pointer points to commit 54cb1ec that
includes the commands.js modification.

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.

[fix] Recent Commands row uses "created" timestamp for the "Modified" field

2 participants