Skip to content

feat(ui): add automatic version check notification to navigation#105

Open
clutester wants to merge 3 commits into
mitre:masterfrom
clutester:feature/version-checker
Open

feat(ui): add automatic version check notification to navigation#105
clutester wants to merge 3 commits into
mitre:masterfrom
clutester:feature/version-checker

Conversation

@clutester
Copy link
Copy Markdown
Contributor

Description

This PR introduces an automated, silent version checker to the Magma sidebar (Navigation.vue) that alerts users when a newer release of Caldera is available on GitHub.

Type of change

  • [*] New feature (non-breaking change which adds functionality)
    • Modified plugins/magma/src/components/Navigation.vue.
    • Added an asynchronous background fetch to the public GitHub API (api.github.com/repos/mitre/caldera/releases/latest) using the onMounted hook.
    • Evaluates the local version store against the latest GitHub release tag.
    • If an update exists, the static version span dynamically transforms into a clickable warning link (e.g., 5.3.0 (Update)).
    • Designed to maximize tight sidebar real-estate by reusing the version text rather than adding bulky icons.

Graceful Degradation (Offline Support)

  • The API call is wrapped in a try...catch block.
  • If the Caldera server is running in an air-gapped environment, behind a strict NAT, or if the GitHub API rate limit is hit, the network error is silently caught in the console.
  • The UI gracefully falls back to displaying the static local version number with zero workflow interruption for the user.

How Has This Been Tested?

  • Compiled locally via npm run build.
  • Hardcoded local state to force a version mismatch and verified the conditional UI renders correctly, matches Caldera's warning text styling, and links out accurately.
  • Simulated an offline environment to verify the catch block successfully intercepts the fetch failure and renders the standard static span.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an automatic “new version available” indicator to the left navigation by checking the latest Caldera GitHub release at runtime and turning the displayed version into an update link when appropriate.

Changes:

  • Adds a background GitHub API fetch on Navigation mount to retrieve releases/latest.
  • Compares local app version against the fetched release tag and conditionally renders an update link.
  • Introduces reactive state (hasUpdate, latestVersion, releaseUrl) to drive the UI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/core/Navigation.vue Outdated
Comment on lines +50 to +56
const githubVersion = data.tag_name.replace('v', '');
latestVersion.value = githubVersion;
releaseUrl.value = data.html_url;

if (githubVersion !== version.value) {
hasUpdate.value = true;
}
Comment on lines +44 to +65
async function checkGitHubVersion() {
try {
const response = await fetch("https://api.github.com/repos/mitre/caldera/releases/latest");
const data = await response.json();

if (data.tag_name) {
const githubVersion = data.tag_name.replace('v', '');
latestVersion.value = githubVersion;
releaseUrl.value = data.html_url;

if (githubVersion !== version.value) {
hasUpdate.value = true;
}
}
} catch (error) {
console.error("Failed to fetch Caldera version from GitHub:", error);
}
}

onMounted(() => {
checkGitHubVersion();
});
Comment on lines +63 to +65
onMounted(() => {
checkGitHubVersion();
});
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

2 participants