Skip to content

[Nitro] Add nitro agent backup command - #10470

Merged
michaelstaib merged 11 commits into
mainfrom
mst/agent-backup
Oct 3, 2026
Merged

michaelstaib merged 11 commits into
mainfrom
mst/agent-backup

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

No description provided.

Copilot AI balanced review requested due to automatic review settings October 2, 2026 21:16
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🎬 Nitro CLI E2E snapshots changed

These flow recordings differ from main (added, removed, or modified). Expand each for the before/after.

🔁 board: modified
Before: mainAfter: this PR
recordingrecording
🔁 board-maximize: modified
Before: mainAfter: this PR
recordingrecording
🔁 search: modified
Before: mainAfter: this PR
recordingrecording

Run 37105049745 · full set in the nitro-e2e-snapshots artifact.

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Archive validation permits destructive empty-root restores, and backup may follow file symlinks outside the workspace.

Review effort: Balanced
Findings: 2 High severity · 4 Medium severity

Open (6)
What changed in this PR

Adds Nitro agent workspace backup/restore support and persistent TUI board orientation preferences.

Changes:

  • Adds ZIP backup and validated, transactional restore commands.
  • Adds activity checks, archive manifests, and JSON summaries.
  • Adds selectable board layouts with persisted preferences.
File Description
TuiShellTests.cs Updates footer-hint coverage.
TuiShellTabsTests.cs Tests layout badges and footer rendering.
KeyMapTests.cs Tests orientation shortcut.
BoardModeTests.cs Tests orientation cycling and rendering.
BoardLayoutTests.cs Tests forced layout decisions.
BoardPreferencesStoreTests.cs Tests preference persistence.
BoardOrientationWriterTests.cs Tests asynchronous preference writes.
CommandTestBase.cs Supports preference-store overrides.
RestoreAgentCommandTests.cs Covers restore behavior and safeguards.
BackupAgentCommandTests.cs Covers archive creation and metadata.
AgentTuiLauncherTests.cs Tests orientation loading and saving.
AgentCommandTests.cs Tests command registration and preferences.
TuiShell.cs Renders tab badges.
ITuiMode.cs Adds tab-badge contract.
TuiMessage.cs Adds orientation-cycle message.
KeyMap.cs Binds o to layout cycling.
BoardOrientationExtensions.cs Adds cycling and labels.
BoardOrientation.cs Defines layout choices.
BoardMode.cs Implements selectable board orientation.
BoardLayout.cs Applies forced layout selection.
AgentsMode.cs Suppresses irrelevant layout hint.
ThrowHelper.cs Adds backup/restore errors.
AgentWorkspaceRestoreSummary.cs Defines restore result.
AgentWorkspaceArchiveSummary.cs Defines backup result.
AgentWorkspaceArchiveManifest.cs Defines archive metadata.
AgentWorkspaceArchive.Restore.cs Validates and restores archives.
AgentWorkspaceArchive.cs Creates workspace archives.
AgentWorkspaceActivity.cs Detects active workspace users.
JsonSourceGenerationContext.cs Registers archive result types.
IBoardPreferencesStore.cs Defines preference storage API.
BoardPreferencesStore.cs Persists board preferences.
BoardPreferencesJsonContext.cs Configures preference serialization.
BoardPreferencesFile.cs Defines preference-file shape.
BoardOrientationWriter.cs Coalesces background writes.
ServiceCollectionExtensions.cs Registers preference storage.
RestoreAgentCommand.cs Implements agent restore.
RestoreActorOption.cs Adds restore actor option.
ForceRestoreAgentOption.cs Adds forced restore option.
ForceBackupAgentOption.cs Adds overwrite option.
ArchiveAgentOption.cs Adds archive-path option.
BackupAgentCommand.cs Implements agent backup.
AgentTuiLauncher.cs Loads and saves board orientation.
AgentCommand.cs Registers commands and preferences.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +138 to +141
if (manifest.Roots.Distinct().Count() != manifest.Roots.Count)
{
throw ThrowHelper.ArchiveManifestInvalid(archivePath);
}
Comment thread src/Nitro/CommandLine/src/CommandLine/Services/Workspace/AgentWorkspaceArchive.cs Outdated
var roots = string.Join(" and ", summary.Roots.Select(root => $"'{root}'"));
var files = summary.FileCount == 1 ? "file" : "files";

console.OkLine($"Backed up {summary.FileCount} {files} from {roots} to '{summary.Archive}'.");
Comment on lines +123 to +124
$"Could not delete the replaced folder '{directory}'. Remove it manually."
.AsWarning());
Comment on lines +317 to +327
await using var source = entry.Open();
await using var file = new FileStream(
destination,
FileMode.CreateNew,
FileAccess.Write,
FileShare.None,
bufferSize: 81920,
useAsync: true);

await source.CopyToAsync(file, cancellationToken);
count++;
Comment on lines +197 to +198
private bool FitsOrientation(string header, int panelWidth)
=> OrientationHeader(header).Length <= Math.Max(0, panelWidth - PanelChromeWidth);
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Patch coverage

94.8% of changed lines covered (871/919)

File Covered Changed Patch %
…/Nitro/CommandLine/src/CommandLine/Tui/Input/TuiMessage.cs 0 1 0.0% 🔴
…/Services/Workspace/AgentWorkspaceArchive.Restore.cs 219 246 89.0% 🟡
src/Nitro/CommandLine/src/CommandLine/Tui/Board/BoardMode.cs 45 49 91.8% 🟡
…/src/CommandLine/Services/Workspace/AgentWorkspaceArchive.cs 195 209 93.3% 🟡
src/Nitro/CommandLine/src/CommandLine/ThrowHelper.cs 33 35 94.3% 🟡
…/CommandLine/src/CommandLine/Commands/Agent/AgentCommand.cs 4 4 100.0% 🟢
…/src/CommandLine/Commands/Agent/AgentTuiLauncher.cs 9 9 100.0% 🟢
…/src/CommandLine/Commands/Agent/BackupAgentCommand.cs 49 49 100.0% 🟢
…/src/CommandLine/Commands/Agent/Options/ArchiveAgentOption.cs 5 5 100.0% 🟢
…/CommandLine/Commands/Agent/Options/ForceBackupAgentOption.cs 5 5 100.0% 🟢
…/Commands/Agent/Options/ForceRestoreAgentOption.cs 5 5 100.0% 🟢
…/src/CommandLine/Commands/Agent/Options/RestoreActorOption.cs 5 5 100.0% 🟢
…/src/CommandLine/Commands/Agent/RestoreAgentCommand.cs 90 90 100.0% 🟢
…/src/CommandLine/Extensions/ServiceCollectionExtensions.cs 1 1 100.0% 🟢
…/CommandLine/Services/Preferences/BoardOrientationWriter.cs 48 48 100.0% 🟢
…/src/CommandLine/Services/Preferences/BoardPreferencesFile.cs 2 2 100.0% 🟢
…/CommandLine/Services/Preferences/BoardPreferencesStore.cs 47 47 100.0% 🟢
…/src/CommandLine/Services/Workspace/AgentWorkspaceActivity.cs 64 64 100.0% 🟢
…/Services/Workspace/AgentWorkspaceArchiveManifest.cs 6 6 100.0% 🟢
…/Services/Workspace/AgentWorkspaceArchiveSummary.cs 5 5 100.0% 🟢

+7 more changed files; see the JSON below for uncovered lines.

Uncovered changed lines (JSON)
{
  "sha": "bc79b8de97731d21b49d518ff87257a335083b91",
  "files": [
    { "path": "src/Nitro/CommandLine/src/CommandLine/Tui/Input/TuiMessage.cs", "ranges": [[63, 63]] },
    { "path": "src/Nitro/CommandLine/src/CommandLine/Services/Workspace/AgentWorkspaceArchive.Restore.cs", "ranges": [[133, 134], [178, 179], [191, 192], [207, 209], [211, 213], [254, 255], [298, 299], [305, 306], [310, 312], [397, 402]] },
    { "path": "src/Nitro/CommandLine/src/CommandLine/Tui/Board/BoardMode.cs", "ranges": [[169, 170], [187, 188]] },
    { "path": "src/Nitro/CommandLine/src/CommandLine/Services/Workspace/AgentWorkspaceArchive.cs", "ranges": [[164, 165], [280, 282], [284, 286], [341, 346]] },
    { "path": "src/Nitro/CommandLine/src/CommandLine/ThrowHelper.cs", "ranges": [[60, 60], [88, 88]] }
  ]
}

Project coverage: 57.9% (300888/519755 lines)

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