Skip to content

Commit a97f3f8

Browse files
committed
define a global capture dirctory
1 parent b709854 commit a97f3f8

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

crates/chat-cli/src/cli/chat/capture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::cli::ConversationState;
2323
use crate::os::Os;
2424

2525
// The shadow repo path that MUST be appended with a session-specific directory
26-
pub const SHADOW_REPO_DIR: &str = "/Users/kiranbug/.amazonq/captures/";
26+
// pub const SHADOW_REPO_DIR: &str = "/Users/kiranbug/.amazonq/captures/";
2727

2828
// CURRENT APPROACH:
2929
// We only enable automatically enable checkpoints when the user is already in a git repo.

crates/chat-cli/src/cli/chat/cli/capture.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::io::Write;
2-
use std::path::PathBuf;
32

43
use clap::Subcommand;
54
use crossterm::style::{
@@ -16,14 +15,14 @@ use eyre::Result;
1615
use crate::cli::chat::capture::{
1716
Capture,
1817
CaptureManager,
19-
SHADOW_REPO_DIR,
2018
};
2119
use crate::cli::chat::{
2220
ChatError,
2321
ChatSession,
2422
ChatState,
2523
};
2624
use crate::os::Os;
25+
use crate::util::directories::get_shadow_repo_dir;
2726

2827
#[derive(Debug, PartialEq, Subcommand)]
2928
pub enum CaptureSubcommand {
@@ -68,7 +67,8 @@ impl CaptureSubcommand {
6867
)
6968
)?;
7069
} else {
71-
let path = PathBuf::from(SHADOW_REPO_DIR).join(session.conversation.conversation_id());
70+
let path = get_shadow_repo_dir(os, session.conversation.conversation_id().to_string())
71+
.map_err(|e| ChatError::Custom(e.to_string().into()))?;
7272
let start = std::time::Instant::now();
7373
session.conversation.capture_manager = Some(
7474
CaptureManager::manual_init(os, path)

crates/chat-cli/src/util/directories.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub enum DirectoryError {
4343
type Result<T, E = DirectoryError> = std::result::Result<T, E>;
4444

4545
const WORKSPACE_AGENT_DIR_RELATIVE: &str = ".amazonq/cli-agents";
46+
const GLOBAL_SHADOW_REPO_DIR: &str = ".aws/.amazonq/cli-captures";
4647
const GLOBAL_AGENT_DIR_RELATIVE_TO_HOME: &str = ".aws/amazonq/cli-agents";
4748
const CLI_BASH_HISTORY_PATH: &str = ".aws/amazonq/.cli_bash_history";
4849

@@ -249,6 +250,10 @@ pub fn get_mcp_auth_dir(os: &Os) -> Result<PathBuf> {
249250
Ok(home_dir(os)?.join(".aws").join("sso").join("cache"))
250251
}
251252

253+
pub fn get_shadow_repo_dir(os: &Os, conversation_id: String) -> Result<PathBuf> {
254+
Ok(home_dir(os)?.join(GLOBAL_SHADOW_REPO_DIR).join(conversation_id))
255+
}
256+
252257
/// Generate a unique identifier for an agent based on its path and name
253258
fn generate_agent_unique_id(agent: &crate::cli::Agent) -> String {
254259
use std::collections::hash_map::DefaultHasher;

0 commit comments

Comments
 (0)