Skip to content

feat: add arf history import subcommand (experimental)#31

Merged
eitsupi merged 11 commits intomainfrom
feat/history-import
Feb 1, 2026
Merged

feat: add arf history import subcommand (experimental)#31
eitsupi merged 11 commits intomainfrom
feat/history-import

Conversation

@eitsupi
Copy link
Copy Markdown
Owner

@eitsupi eitsupi commented Feb 1, 2026

No description provided.

eitsupi and others added 2 commits February 1, 2026 12:58
Add ability to import command history from radian, R native (.Rhistory),
or another arf database.

Features:
- Parse radian history format with timestamps and multiline support
- Route commands by mode: shell → shell.db, r/browse → r.db
- Infer mode from arf database filename (shell.db → shell)
- Skip unknown modes with warnings
- Dry-run mode to preview imports

Includes 19 unit tests covering parsing and import logic.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Allow users to specify a custom hostname for imported entries, making
them distinguishable from native arf entries in history queries.

Example: arf history import --from radian --hostname "radian-import"

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@eitsupi eitsupi changed the title feat: add arf history import subcommand (experimental) feat: add arf history import subcommand (experimental) Feb 1, 2026
@eitsupi eitsupi force-pushed the feat/history-import branch from d1b062c to fd31529 Compare February 1, 2026 13:15
@eitsupi eitsupi marked this pull request as ready for review February 1, 2026 13:15
Copilot AI review requested due to automatic review settings February 1, 2026 13:15
@eitsupi eitsupi force-pushed the feat/history-import branch from fd31529 to 6f94052 Compare February 1, 2026 13:22
Copy link
Copy Markdown

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 experimental arf history import subcommand to migrate command history into arf’s SQLite-backed history databases from other sources.

Changes:

  • Introduces arf history import with --from, --file, --hostname, and --dry-run options.
  • Adds a new history::import module implementing parsers/import routing for radian, .Rhistory, and arf SQLite sources (with tests).
  • Updates README documentation and regenerates shell completion snapshots (bash/fish/zsh/powershell).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
crates/arf-console/src/main.rs Wires new history import action into CLI execution and implements import flow + dry-run output.
crates/arf-console/src/cli.rs Adds the HistoryAction::Import subcommand and ImportSource value enum.
crates/arf-console/src/history/mod.rs Exposes the new history::import module.
crates/arf-console/src/history/import.rs Implements parsing/import logic and adds unit/integration-style tests.
README.md Documents usage, options, and supported sources for history import.
crates/arf-console/src/snapshots/arf__cli__tests__completions_{bash,fish,zsh,powershell}.snap Updates completion snapshots to include the new history import subcommand and flags.

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

- Add ValueHint::Hostname to --hostname option for better shell completions
- Handle CRLF line endings in radian history parsing
- Fix doc comment: "Files named `shell.db`" instead of "ending with"
- Remove misleading "read-only mode" comment
- Update README section title to include all import sources
- Unify dry-run logic with actual import (use import_entries for both)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link
Copy Markdown

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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.


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

- Fix default_arf_path() to use config::history_dir() for correct path
- Update --file help text to reflect actual default (history.dir/r.db)
- Use in-memory databases for dry-run to avoid creating files/directories

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link
Copy Markdown

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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.


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

- Preserve leading whitespace in parse_r_history (use trim_end instead
  of trim to avoid changing indented code from .Rhistory)
- Change default_arf_path to accept history_dir as parameter, making
  callers responsible for resolving config (XDG, arf.toml, CLI)
- Load config in handle_history_import to use effective history.dir
- Add import_entries_dry_run function to simulate import without
  opening databases, avoiding SQLite initialization in dry-run mode
- Short-circuit dry-run before opening any database handles
- Use TempDir in test_parse_arf_history_not_found instead of hardcoded
  /nonexistent path for cross-platform reliability
- Add test for leading whitespace preservation in R history parsing
- Update test_import_entries_dry_run to test the new function

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link
Copy Markdown

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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.


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

- Require --file for --from arf to prevent self-import (source = target)
- Respect --config and --history-dir CLI flags in history import
- Create history_dir with create_dir_all before opening databases
- Reset current_mode on # time: boundaries in radian parser to prevent
  mode carryover between entries
- Remove unused default_arf_path function
- Add edge case tests for regression prevention:
  - Mode not carried over between radian entries
  - Consecutive timestamps without commands
  - File not found errors for radian and R history
  - CRLF line endings in radian history
  - None mode entries go to R database

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link
Copy Markdown

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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.


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

- Remove unused `dry_run` parameter from `import_entries()` since all
  call sites pass `false` and dry-run is handled by `import_entries_dry_run()`
- Update README to clarify that `--file` is required for `--from arf`
- Add note about running import twice for both r.db and shell.db

Addresses Copilot review feedback on commit 09e8947.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link
Copy Markdown

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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.


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

Prevent `arf history import --from arf --file <path>` from importing
a database into itself, which would duplicate history entries.

Uses `fs::canonicalize()` to detect when the source file path matches
`r.db` or `shell.db` in the target history directory. If they match,
the command exits with a clear error message.

Addresses Copilot review feedback.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link
Copy Markdown

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

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.


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

eitsupi and others added 2 commits February 1, 2026 14:56
- Remove ValueHint::Hostname from --hostname option to avoid misleading
  file completions in Bash (compgen -f was being used)
- Defer history_dir resolution until after dry-run check, allowing
  `arf history import --dry-run` to work in environments where
  dirs::data_dir() is unavailable

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add test for shell.db self-import rejection (was only testing r.db)
- Add test for `--from arf` requiring `--file` option
- Fix misleading error message for arf import without --file
- Document duplicate import behavior in README

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@eitsupi eitsupi merged commit b564f2b into main Feb 1, 2026
10 checks passed
@eitsupi eitsupi deleted the feat/history-import branch February 1, 2026 15:05
eitsupi added a commit that referenced this pull request Feb 1, 2026
- [Unreleased] history import (#31), :info enhancements (#29)
- [0.2.0-beta.1] vi mode indicator (#23), Windows Rprofile fix (#20)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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