Skip to content

fix: preserve tab state when switching between views#98

Open
deacon-mp wants to merge 1 commit into
masterfrom
fix/preserve-tab-state-keepalive
Open

fix: preserve tab state when switching between views#98
deacon-mp wants to merge 1 commit into
masterfrom
fix/preserve-tab-state-keepalive

Conversation

@deacon-mp
Copy link
Copy Markdown
Contributor

Summary

  • Wraps <router-view> with <KeepAlive> to preserve component state across tab switches
  • Filters, selections, and scroll positions are now preserved when navigating away and back
  • Adds onActivated hooks to refresh data from API when returning to a tab
  • Migrates polling intervals to onActivated/onDeactivated to stop background polling on inactive tabs

Test plan

  • Switch from Abilities (with filters set) to Operations and back — filters should persist
  • Switch from Operations (with operation selected) to Agents and back — operation selection should persist
  • Create a new ability in one tab, switch to Operations and back to Abilities — new ability should appear
  • Verify agent polling stops when leaving Agents tab (check network tab)
  • Verify operation polling stops when leaving Operations tab

Wraps router-view with Vue's KeepAlive to preserve component state
(filters, selections, scroll position) when switching tabs. Adds
onActivated hooks to refresh data from stores so changes made in
other tabs are immediately visible. Migrates polling intervals to
onActivated/onDeactivated to stop background polling on inactive tabs.
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

This PR aims to preserve per-tab UI state (filters/selections/scroll) by caching routed views with Vue’s <KeepAlive>, while refreshing data on tab re-entry and stopping background polling when a tab is inactive.

Changes:

  • Wraps the main (non-login) <router-view> in <KeepAlive> to cache routed views across tab switches.
  • Adds onActivated hooks to many views to refresh data when returning to a tab.
  • Migrates polling teardown from onBeforeUnmount to onDeactivated for kept-alive views (Agents/Operations).

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 19 comments.

Show a summary per file
File Description
src/App.vue Wrapes routed views in <KeepAlive> to preserve per-tab component state
src/views/SettingsView.vue Refreshes main config on activation
src/views/SchedulesView.vue Refreshes schedules/agents on activation
src/views/PlannersView.vue Refreshes planners on activation
src/views/PayloadsView.vue Refreshes payloads on activation
src/views/OperationsView.vue Refreshes operations/agents on activation; clears polling on deactivation
src/views/ObjectivesView.vue Refreshes objectives on activation
src/views/ObfuscatorsView.vue Refreshes obfuscators on activation
src/views/HomeView.vue Refreshes main config on activation
src/views/FactSourcesView.vue Refreshes sources on activation
src/views/ExfilledFilesView.vue Refreshes operations/files on activation
src/views/ContactsView.vue Refreshes contacts on activation
src/views/AgentsView.vue Starts polling on activation; clears polling on deactivation
src/views/AdversariesView.vue Refreshes abilities/adversaries/objectives on activation
src/views/AbilitiesView.vue Refreshes abilities on activation

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

Comment on lines +22 to +24
onActivated(() => {
sourceStore.getSources($api);
});
Comment thread src/App.vue
Comment on lines +31 to +33
router-view(v-slot="{ Component }")
KeepAlive
component(:is="Component")
Comment thread src/views/HomeView.vue
Comment on lines +21 to +27
onActivated(async () => {
try {
await coreStore.getMainConfig($api);
} catch (error) {
console.error(error);
}
});
Comment on lines +42 to +44
onActivated(async () => {
await abilityStore.getAbilities($api);
});
Comment on lines +183 to +187
onActivated(async () => {
await operationStore.getOperations($api);
await agentStore.getAgents($api);
agentStore.updateAgentGroups();
selectOperation();
Comment on lines +34 to +38
onActivated(async () => {
await abilityStore.getAbilities($api);
await adversaryStore.getAdversaries($api);
await objectiveStore.getObjectives($api);
});
Comment on lines +32 to +35
onActivated(async () => {
await operationStore.getOperations($api);
exfilStore.loadFiles($api, selectedOperationId.value);
});
Comment on lines +183 to +187
onActivated(async () => {
await operationStore.getOperations($api);
await agentStore.getAgents($api);
agentStore.updateAgentGroups();
selectOperation();
Comment on lines +23 to +25
onActivated(async () => {
await coreStore.getMainConfig($api);
});
Comment on lines +15 to +17
onActivated(async () => {
await coreStore.getPlanners($api);
});
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