feat(shell): /export — export a session to Markdown - #417
Conversation
|
Thanks for the pull request. A maintainer will review it when available. Please keep the PR focused, explain the why in the description, and make sure local checks pass before requesting review. Contribution guide: https://github.com/AI-Shell-Team/aish/blob/main/CONTRIBUTING.md |
|
This pull request description looks incomplete. Please update the missing sections below before review. Missing items:
|
📝 WalkthroughWalkthroughAdds ChangesSession Markdown export
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant Shell
participant SessionStore
participant MarkdownFile
User->>Shell: /export [md]
Shell->>SessionStore: Load session and history
SessionStore-->>Shell: Session data and history
Shell->>MarkdownFile: Write Markdown export
MarkdownFile-->>User: Report success or failure
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/aish-shell/src/app.rs`:
- Around line 3416-3428: Update the history retrieval in the export flow around
store.get_history so it exports every command instead of limiting results to
10,000 entries. Page through all available rows or use an existing unbounded
store API, preserve the current error handling, and add coverage for sessions
containing more than 10,000 commands.
- Around line 3517-3540: Update the session export write flow around the
std::fs::write call so the generated file has owner-only permissions (0600) on
Unix. Ensure this is enforced for both newly created and existing/overwritten
files, while preserving the current success and write_failed reporting behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9fb27beb-4d15-4244-8eb6-d3ed58221344
📒 Files selected for processing (9)
crates/aish-i18n/locales/de-DE.yamlcrates/aish-i18n/locales/en-US.yamlcrates/aish-i18n/locales/es-ES.yamlcrates/aish-i18n/locales/fr-FR.yamlcrates/aish-i18n/locales/ja-JP.yamlcrates/aish-i18n/locales/zh-CN.yamlcrates/aish-shell/src/app.rscrates/aish-shell/src/readline.rscrates/aish-shell/tests/slash_popup_commands.rs
7348a22 to
16c7065
Compare
16c7065 to
285788c
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/aish-i18n/locales/es-ES.yaml`:
- Line 573: Update handle_export_command to render shell.export.forked_label
with the session’s parent/fork source whenever a parent exists, so exported
Markdown includes the fork-source metadata; leave exports without a parent
unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1293380a-a9f4-48a1-b70e-f91b649365fc
📒 Files selected for processing (9)
crates/aish-i18n/locales/de-DE.yamlcrates/aish-i18n/locales/en-US.yamlcrates/aish-i18n/locales/es-ES.yamlcrates/aish-i18n/locales/fr-FR.yamlcrates/aish-i18n/locales/ja-JP.yamlcrates/aish-i18n/locales/zh-CN.yamlcrates/aish-shell/src/app.rscrates/aish-shell/src/readline.rscrates/aish-shell/tests/slash_popup_commands.rs
🚧 Files skipped from review as they are similar to previous changes (8)
- crates/aish-shell/src/readline.rs
- crates/aish-shell/tests/slash_popup_commands.rs
- crates/aish-i18n/locales/en-US.yaml
- crates/aish-i18n/locales/zh-CN.yaml
- crates/aish-i18n/locales/ja-JP.yaml
- crates/aish-i18n/locales/de-DE.yaml
- crates/aish-i18n/locales/fr-FR.yaml
- crates/aish-shell/src/app.rs
| session_label: "- **sesión**: `{uuid}`" | ||
| model_label: "- **modelo**: {model}" | ||
| api_base_label: "- **api_base**: {base}" | ||
| forked_label: "- **bifurcada de**: `{parent}`" |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Render the fork-source metadata in the export handler.
shell.export.forked_label is defined here, but handle_export_command does not call this key or emit the session’s parent/fork source. The exported Markdown therefore omits metadata required by issue #411; render it when a parent exists.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/aish-i18n/locales/es-ES.yaml` at line 573, Update
handle_export_command to render shell.export.forked_label with the session’s
parent/fork source whenever a parent exists, so exported Markdown includes the
fork-source metadata; leave exports without a parent unchanged.
`/export [md]` writes the current session — metadata (uuid/model/api_base/ created/working dir), the AI conversation, and the command history table — to `aish-session-<short>.md` for postmortem or sharing. - History-table cells escape `|`, newlines, and backticks so commands containing them render correctly. - A failed session-record or history fetch surfaces a localized error instead of silently exporting an empty file. Reuses the existing SessionStore get_session/get_history and the session state snapshot; no new persistence path. Closes AI-Shell-Team#411
285788c to
38fd483
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/aish-i18n/locales/ja-JP.yaml`:
- Line 657: Add conditional fork-source metadata output in handle_export_command
using shell.export.forked_label and the session’s parent/fork source, so
exported Markdown includes it only when a parent exists.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 24da020c-a08a-45d3-bcbe-56e6d9a22585
📒 Files selected for processing (9)
crates/aish-i18n/locales/de-DE.yamlcrates/aish-i18n/locales/en-US.yamlcrates/aish-i18n/locales/es-ES.yamlcrates/aish-i18n/locales/fr-FR.yamlcrates/aish-i18n/locales/ja-JP.yamlcrates/aish-i18n/locales/zh-CN.yamlcrates/aish-shell/src/app.rscrates/aish-shell/src/readline.rscrates/aish-shell/tests/slash_popup_commands.rs
🚧 Files skipped from review as they are similar to previous changes (8)
- crates/aish-shell/tests/slash_popup_commands.rs
- crates/aish-shell/src/readline.rs
- crates/aish-i18n/locales/en-US.yaml
- crates/aish-i18n/locales/zh-CN.yaml
- crates/aish-i18n/locales/es-ES.yaml
- crates/aish-i18n/locales/de-DE.yaml
- crates/aish-i18n/locales/fr-FR.yaml
- crates/aish-shell/src/app.rs
| session_label: "- **セッション**: `{uuid}`" | ||
| model_label: "- **モデル**: {model}" | ||
| api_base_label: "- **api_base**: {base}" | ||
| forked_label: "- **フォーク元**: `{parent}`" |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Emit the fork source in the export.
handle_export_command in crates/aish-shell/src/app.rs:3495-3664 never reads shell.export.forked_label, so this translation is currently unused and exported Markdown omits the required fork-source metadata. Add the corresponding conditional output for the session’s parent/fork source.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/aish-i18n/locales/ja-JP.yaml` at line 657, Add conditional fork-source
metadata output in handle_export_command using shell.export.forked_label and the
session’s parent/fork source, so exported Markdown includes it only when a
parent exists.
Summary
Adds the
/export [md]built-in command: writes the current session to a Markdown file (aish-session-<short>.md) for postmortem or sharing.Closes #411
What it does
|, newlines, and backticks so commands containing them render correctly.Scope
Self-contained: reuses the existing
SessionStore::get_session/get_historyand the existing session-state snapshot. No new persistence path, no other commands touched.crates/aish-shell/src/app.rs—handle_export_command+ route.crates/aish-shell/src/readline.rs—/exportpopup entry.crates/aish-i18n/locales/*—shell.export.*+shell.slash.export(6 locales).Verification
cargo clippy -p aish-shell --all-targets -- -D warningsclean.slash_popup_commandstests pass (count + i18n descriptions).Summary by CodeRabbit
/exportcommand to export the current session (conversation plus command history) as a Markdown file.mdormarkdownformat options and provides localized success and error messages./exportin English, German, Spanish, French, Japanese, and Simplified Chinese./exportentry.