Merged
Conversation
- Add `arf history export` command to backup history to a unified SQLite file - Exports both r.db and shell.db to a single file with customizable table names - Use --r-table and --shell-table to specify table names (defaults: r, shell) - Update `arf history import --from arf` to support unified export files - Files named r.db/shell.db use existing single-mode import - Other filenames trigger unified import using table names - Split export functionality into separate history/export.rs module - Add comprehensive tests for export and unified import Co-Authored-By: Claude Opus 4.5 <[email protected]>
Address review findings: - Add validate_table_name() to prevent SQL injection via table names - Add --unified flag to explicitly specify unified file format - Add parent directory existence check for export output path - Quote table names in SQL queries for safety Co-Authored-By: Claude Opus 4.5 <[email protected]>
Verify that parse_unified_arf_history works regardless of filename, which validates the --unified flag behavior indirectly. Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add history export section with options - Update history import section with unified file support - Document --unified, --r-table, --shell-table options Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Use temp file + rename pattern to prevent incomplete files on error - Clean up stale temp files from previous failed attempts - Add documentation notes about concurrent access and restore procedure Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Mention radian/.Rhistory import in Fuzzy History Search highlight - Add import/export support to Features list Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Fix TOCTOU race condition in stale temp file cleanup - Use unique .arf-export-tmp extension to avoid collisions - Clarify documentation about atomicity guarantees Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
This reverts commit bb8f447.
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Collapse nested if statements in export.rs - Allow too_many_arguments for handle_history_import - Use &Path instead of &PathBuf in handle_history_export Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR adds an experimental history export/import feature to arf console, enabling users to back up their R and shell command history to a unified SQLite file and restore it later or transfer it between machines.
Changes:
- Added
arf history exportsubcommand to export both R and shell history to a single SQLite file with customizable table names - Extended
arf history import --from arfto support unified export files (auto-detected by filename or explicit--unifiedflag) - Implemented table name validation to prevent SQL injection attacks
- Added atomic write operations using temp files for data safety during export
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/arf-console/src/cli.rs | Defines new Export action with --file, --r-table, and --shell-table parameters |
| crates/arf-console/src/main.rs | Implements handlers for export and unified import functionality |
| crates/arf-console/src/history/mod.rs | Exports new export module |
| crates/arf-console/src/history/export.rs | Core export logic with atomic writes, table creation, and data copying |
| crates/arf-console/src/history/import.rs | Adds unified import parser, table validation, and helper functions |
| docs/configuration.md | Documents export/import commands with examples |
| README.md | Updates feature descriptions and adds comprehensive export/import documentation |
| CHANGELOG.md | Documents new features and changes |
| crates/arf-console/src/snapshots/*.snap | Updated shell completion and help text snapshots |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add validation to reject same table names for r_table and shell_table in both export and import to prevent data loss/duplication - Fix documentation to use correct CLI syntax (--file flag required) - Remove non-existent --dry-run from export examples - Add tests for same table name validation Co-Authored-By: Claude Opus 4.5 <[email protected]>
Also improve --unified flag help text with clearer auto-detection explanation. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add timestamp to temp file name for unpredictability (security) - Add write permission check before export starts - Document cross-platform atomicity limitations - Document intentional design difference between low-level export function and CLI handler - Reject underscore-only table names (e.g., "_", "___") - Add test for temp file cleanup on export failure - Add round-trip integration test for export/import - Update shell completion snapshots Addresses roborev job 113 findings. Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add comment explaining intentional behavior for write permission check cleanup (test file may be left if removal fails) - Add process ID to temp file name for better uniqueness - Improve cleanup test with clearer comments explaining the flow - Add test_export_cleans_up_temp_file_on_copy_failure to verify cleanup when failure occurs during data copy (not just open) Co-Authored-By: Claude Opus 4.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
arf history exportsubcommand for backing up history to a unified SQLite filearf history import --from arfto restore or transfer historyChanges
arf history export <file>command with--dry-run,--r-table,--shell-tableoptionsarf history import --from arfto support unified export filesTest plan
🤖 Generated with Claude Code