Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Check if Amazon Q chat is active
if [ -n "$QCHAT_PROCESS_ID" ]; then
echo "ERROR: Git push blocked while Amazon Q chat is active (QCHAT_PROCESS_ID=$QCHAT_PROCESS_ID)"
echo "Please exit Amazon Q chat with '/quit' before pushing changes."
exit 1
fi

# Continue with push if QCHAT_PROCESS_ID is not set
exit 0
3 changes: 3 additions & 0 deletions crates/chat-cli/src/cli/chat/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ pub const MAX_NUMBER_OF_IMAGES_PER_REQUEST: usize = 10;

/// In bytes - 10 MB
pub const MAX_IMAGE_SIZE: usize = 10 * 1024 * 1024;

/// Environment variable containing the pid of the chat session.
pub const QCHAT_PROCESS_ID: &str = "QCHAT_PROCESS_ID";
2 changes: 1 addition & 1 deletion crates/chat-cli/src/cli/chat/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod cli;
mod command;
mod consts;
pub mod consts;
mod context;
mod conversation_state;
mod hooks;
Expand Down
2 changes: 1 addition & 1 deletion crates/chat-cli/src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mod chat;
pub mod chat;
mod debug;
mod diagnostics;
mod feed;
Expand Down
13 changes: 13 additions & 0 deletions crates/chat-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use clap::Parser;
use crossterm::style::Stylize;
use eyre::Result;
use logging::get_log_level_max;
use platform::Context;
use tracing::metadata::LevelFilter;

#[global_allocator]
Expand All @@ -33,6 +34,18 @@ fn main() -> Result<ExitCode> {
},
};

// Set the QCHAT_PROCESS_ID env var if we're launching chat.
#[cfg(unix)]
match parsed.subcommand {
Some(cli::CliRootCommands::Chat(_)) | None => {
let ctx = Context::new();
let current_pid = nix::unistd::getpid().as_raw().to_string();
// SAFETY: This is only executed in a single-threaded context.
unsafe { ctx.env().set_var(cli::chat::consts::QCHAT_PROCESS_ID, current_pid) };
},
_ => (),
}

let verbose = parsed.verbose > 0;
let runtime = tokio::runtime::Builder::new_multi_thread().enable_all().build()?;
let result = runtime.block_on(parsed.execute());
Expand Down
Loading