Add /workspace command for agent session snapshot and restore#310
Add /workspace command for agent session snapshot and restore#310ashishpatel26 wants to merge 2 commits into
Conversation
Introduces workspace snapshots: named captures of an agent session's state (session key, CLI source, working directory) that survive Terminal restarts. The /workspace command provides save and list subcommands; snapshots persist to workspaces.json in the user's config directory. Closes microsoft#193
|
@ashishpatel26 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds workspace snapshot persistence and /workspace slash-command support, plus introduces a new app event to feed terminal command output back into the agent for multi-turn execution.
Changes:
- Introduces
workspace_snapshotmodule for saving/listing/loading/deleting snapshots persisted toworkspaces.json - Adds
/workspace save [name]and/workspace listcommand plumbing and tests - Adds
AppEvent::CommandOutputReadyand follow-up prompt submission; updates i18n strings and dev test dependency
Reviewed changes
Copilot reviewed 95 out of 96 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tools/wta/src/workspace_snapshot.rs | New snapshot store model + JSON persistence helpers + unit tests |
| tools/wta/src/slash_command_tests.rs | Adds tests for /workspace list empty state and unknown subcommand usage |
| tools/wta/src/main.rs | Registers the new workspace_snapshot module |
| tools/wta/src/commands.rs | Adds workspace command spec and help summary key |
| tools/wta/src/app.rs | Implements /workspace handler; adds CommandOutputReady event and handler; passes session_id into choice execution |
| tools/wta/locales/en-US.yml | Adds commands.workspace.summary string |
| tools/wta/locales/en-GB.yml | Adds commands.workspace.summary string |
| tools/wta/locales/zh-TW.yml | Adds commands.workspace.summary string |
| tools/wta/locales/zh-CN.yml | Adds commands.workspace.summary string |
| tools/wta/locales/vi-VN.yml | Adds commands.workspace.summary string |
| tools/wta/locales/uz-Latn-UZ.yml | Adds commands.workspace.summary string |
| tools/wta/locales/ur-PK.yml | Adds commands.workspace.summary string |
| tools/wta/locales/uk-UA.yml | Adds commands.workspace.summary string |
| tools/wta/locales/ug-CN.yml | Adds commands.workspace.summary string |
| tools/wta/locales/tt-RU.yml | Adds commands.workspace.summary string |
| tools/wta/locales/tr-TR.yml | Adds commands.workspace.summary string |
| tools/wta/locales/th-TH.yml | Adds commands.workspace.summary string |
| tools/wta/locales/te-IN.yml | Adds commands.workspace.summary string |
| tools/wta/locales/ta-IN.yml | Adds commands.workspace.summary string |
| tools/wta/locales/sv-SE.yml | Adds commands.workspace.summary string |
| tools/wta/locales/sr-Latn-RS.yml | Adds commands.workspace.summary string |
| tools/wta/locales/sr-Cyrl-RS.yml | Adds commands.workspace.summary string |
| tools/wta/locales/sr-Cyrl-BA.yml | Adds commands.workspace.summary string |
| tools/wta/locales/sq-AL.yml | Adds commands.workspace.summary string |
| tools/wta/locales/sl-SI.yml | Adds commands.workspace.summary string |
| tools/wta/locales/sk-SK.yml | Adds commands.workspace.summary string |
| tools/wta/locales/ru-RU.yml | Adds commands.workspace.summary string |
| tools/wta/locales/ro-RO.yml | Adds commands.workspace.summary string |
| tools/wta/locales/quz-PE.yml | Adds commands.workspace.summary string |
| tools/wta/locales/qps-plocm.yml | Adds pseudo-loc commands.workspace.summary string |
| tools/wta/locales/qps-ploca.yml | Adds pseudo-loc commands.workspace.summary string |
| tools/wta/locales/qps-ploc.yml | Adds pseudo-loc commands.workspace.summary string |
| tools/wta/locales/pt-PT.yml | Adds commands.workspace.summary string |
| tools/wta/locales/pt-BR.yml | Adds commands.workspace.summary string |
| tools/wta/locales/pl-PL.yml | Adds commands.workspace.summary string |
| tools/wta/locales/pa-IN.yml | Adds commands.workspace.summary string |
| tools/wta/locales/or-IN.yml | Adds commands.workspace.summary string |
| tools/wta/locales/nn-NO.yml | Adds commands.workspace.summary string |
| tools/wta/locales/nl-NL.yml | Adds commands.workspace.summary string |
| tools/wta/locales/ne-NP.yml | Adds commands.workspace.summary string |
| tools/wta/locales/nb-NO.yml | Adds commands.workspace.summary string |
| tools/wta/locales/mt-MT.yml | Adds commands.workspace.summary string |
| tools/wta/locales/ms-MY.yml | Adds commands.workspace.summary string |
| tools/wta/locales/mr-IN.yml | Adds commands.workspace.summary string |
| tools/wta/locales/ml-IN.yml | Adds commands.workspace.summary string |
| tools/wta/locales/mk-MK.yml | Adds commands.workspace.summary string |
| tools/wta/locales/mi-NZ.yml | Adds commands.workspace.summary string |
| tools/wta/locales/lv-LV.yml | Adds commands.workspace.summary string |
| tools/wta/locales/lt-LT.yml | Adds commands.workspace.summary string |
| tools/wta/locales/lo-LA.yml | Adds commands.workspace.summary string |
| tools/wta/locales/lb-LU.yml | Adds commands.workspace.summary string |
| tools/wta/locales/kok-IN.yml | Adds commands.workspace.summary string |
| tools/wta/locales/ko-KR.yml | Adds commands.workspace.summary string |
| tools/wta/locales/kn-IN.yml | Adds commands.workspace.summary string |
| tools/wta/locales/km-KH.yml | Adds commands.workspace.summary string |
| tools/wta/locales/kk-KZ.yml | Adds commands.workspace.summary string |
| tools/wta/locales/ka-GE.yml | Adds commands.workspace.summary string |
| tools/wta/locales/ja-JP.yml | Adds commands.workspace.summary string |
| tools/wta/locales/it-IT.yml | Adds commands.workspace.summary string |
| tools/wta/locales/is-IS.yml | Adds commands.workspace.summary string |
| tools/wta/locales/id-ID.yml | Adds commands.workspace.summary string |
| tools/wta/locales/hy-AM.yml | Adds commands.workspace.summary string |
| tools/wta/locales/hu-HU.yml | Adds commands.workspace.summary string |
| tools/wta/locales/hr-HR.yml | Adds commands.workspace.summary string |
| tools/wta/locales/hi-IN.yml | Adds commands.workspace.summary string |
| tools/wta/locales/he-IL.yml | Adds commands.workspace.summary string |
| tools/wta/locales/gu-IN.yml | Adds commands.workspace.summary string |
| tools/wta/locales/gl-ES.yml | Adds commands.workspace.summary string |
| tools/wta/locales/gd-gb.yml | Adds commands.workspace.summary string |
| tools/wta/locales/ga-IE.yml | Adds commands.workspace.summary string |
| tools/wta/locales/fr-FR.yml | Adds commands.workspace.summary string |
| tools/wta/locales/fr-CA.yml | Adds commands.workspace.summary string |
| tools/wta/locales/fil-PH.yml | Adds commands.workspace.summary string |
| tools/wta/locales/fi-FI.yml | Adds commands.workspace.summary string |
| tools/wta/locales/fa-IR.yml | Adds commands.workspace.summary string |
| tools/wta/locales/eu-ES.yml | Adds commands.workspace.summary string |
| tools/wta/locales/et-EE.yml | Adds commands.workspace.summary string |
| tools/wta/locales/es-MX.yml | Adds commands.workspace.summary string |
| tools/wta/locales/es-ES.yml | Adds commands.workspace.summary string |
| tools/wta/locales/el-GR.yml | Adds commands.workspace.summary string |
| tools/wta/locales/de-DE.yml | Adds commands.workspace.summary string |
| tools/wta/locales/da-DK.yml | Adds commands.workspace.summary string |
| tools/wta/locales/cy-GB.yml | Adds commands.workspace.summary string |
| tools/wta/locales/cs-CZ.yml | Adds commands.workspace.summary string |
| tools/wta/locales/ca-Es-VALENCIA.yml | Adds commands.workspace.summary string |
| tools/wta/locales/ca-ES.yml | Adds commands.workspace.summary string |
| tools/wta/locales/bs-Latn-BA.yml | Adds commands.workspace.summary string |
| tools/wta/locales/bn-IN.yml | Adds commands.workspace.summary string |
| tools/wta/locales/bg-BG.yml | Adds commands.workspace.summary string |
| tools/wta/locales/az-Latn-AZ.yml | Adds commands.workspace.summary string |
| tools/wta/locales/as-IN.yml | Adds commands.workspace.summary string |
| tools/wta/locales/ar-SA.yml | Adds commands.workspace.summary string |
| tools/wta/locales/am-ET.yml | Adds commands.workspace.summary string |
| tools/wta/locales/af-ZA.yml | Adds commands.workspace.summary string |
| tools/wta/Cargo.toml | Adds tempfile dev-dependency for new unit tests |
Comments suppressed due to low confidence (6)
tools/wta/src/app.rs:1
- Slicing
Stringby byte index can panic whensession_keycontains non-ASCII (slice boundary may not be on a UTF-8 char boundary). Use a safe truncation approach (e.g.,chars().take(8)orget(..8).unwrap_or(...)with a char-boundary search) to avoid runtime panics.
tools/wta/src/workspace_snapshot.rs:1 - The module-level docs describe
/workspace restore [name], but the implemented command handler inApp::cmd_workspaceonly supportssaveandlist. Please either implement therestoresubcommand (likely usingload()and opening a new tab/session) or update the docs and related user-facing strings to match the actual behavior.
tools/wta/src/workspace_snapshot.rs:1 load_storecurrently treats any read error and any JSON parse error as 'no snapshots' by returningdefault(). This will silently hide important problems like permission errors or a corruptedworkspaces.json, and/workspace listwill incorrectly report 'No saved workspaces.' Consider returning aResult<SnapshotStore, io::Error/serde_json::Error>(or mapping to yourStringerror) and only falling back to empty onErrorKind::NotFound.
tools/wta/src/workspace_snapshot.rs:1- Writing JSON directly to the destination path is not crash-safe: if the process is terminated mid-write,
workspaces.jsoncan become truncated/corrupted and all snapshots may be lost. Prefer an atomic write strategy (write to a temp file in the same directory,fsyncif needed, thenrenameover the target) to make snapshot persistence resilient.
tools/wta/src/workspace_snapshot.rs:1 - This test uses a hard-coded
/tmp/...path, which is platform-specific (fails on Windows) and can be flaky if that file happens to exist. Usetempfile::tempdir()and join a guaranteed-nonexistent filename inside it (or create aNamedTempFileand delete it before calling) to make the test deterministic and cross-platform.
tools/wta/locales/zh-CN.yml:1 - Many non-English locale files add
commands.workspace.summarybut keep the value in English, and the text says 'restore' even though the command currently supportssave|list. Consider (a) updating the string to match implemented subcommands, and (b) either providing translations or omitting the key in non-English locales so the app can fall back to en-US instead of showing untranslated English in localized UIs.
@check-spelling-bot Report
|
| Dictionary | Entries | Covers | Uniquely |
|---|---|---|---|
| cspell:csharp/csharp.txt | 32 | 2 | 2 |
| cspell:aws/aws.txt | 232 | 2 | 2 |
| cspell:fonts/fonts.txt | 536 | 1 | 1 |
Consider adding to the extra_dictionaries array (in the .github/actions/spelling/config.json file):
"cspell:csharp/csharp.txt",
"cspell:aws/aws.txt",
"cspell:fonts/fonts.txt",
To stop checking additional dictionaries, put (in the .github/actions/spelling/config.json file):
"check_extra_dictionaries": []Forbidden patterns 🙅 (1)
In order to address this, you could change the content to not match the forbidden patterns (comments before forbidden patterns may help explain why they're forbidden), add patterns for acceptable instances, or adjust the forbidden patterns themselves.
These forbidden patterns matched content:
Should be reentrancy
[Rr]e[- ]entrancy
Errors and Warnings ❌ (2)
See the 📂 files view, the 📜action log, 👼 SARIF report, or 📝 job summary for details.
| ❌ Errors and Warnings | Count |
|---|---|
| 54 | |
| ❌ forbidden-pattern | 1 |
See ❌ Event descriptions for more information.
✏️ Contributor please read this
By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.
If the listed items are:
- ... misspelled, then please correct them instead of using the command.
- ... names, please add them to
.github/actions/spelling/allow/names.txt. - ... APIs, you can add them to a file in
.github/actions/spelling/allow/. - ... just things you're using, please add them to an appropriate file in
.github/actions/spelling/expect/. - ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in
.github/actions/spelling/patterns/.
See the README.md in each directory for more information.
🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉
If the flagged items are 🤯 false positives
If items relate to a ...
-
binary file (or some other file you wouldn't want to check at all).
Please add a file path to the
excludes.txtfile matching the containing file.File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^refers to the file's path from the root of the repository, so^README\.md$would exclude README.md (on whichever branch you're using). -
well-formed pattern.
If you can write a pattern that would match it,
try adding it to thepatterns.txtfile.Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.
|
@microsoft-github-policy-service agree |
Closes #193
Summary
/workspace save [name]command saves the current agent session state (session key, CLI source, working directory) to a named slot/workspace listcommand shows all saved workspace namesworkspaces.jsonin the user config directory and survive Terminal restartsworkspace_snapshotwith full public API:save(),load(),list(),delete()commands.workspace.summaryi18n key added to all 89 locale files to satisfy the parity testtempfiledev-dependency added for the snapshot unit testsTesting
All 912 existing tests pass. Two new slash command tests added:
slash_workspace_list_when_no_snapshots_shows_system_messageslash_workspace_unknown_subcommand_shows_usage