File tree Expand file tree Collapse file tree 5 files changed +27
-2
lines changed
Expand file tree Collapse file tree 5 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 1+ # Check if Amazon Q chat is active
2+ if [ -n "$QCHAT_PROCESS_ID" ]; then
3+ echo "ERROR: Git push blocked while Amazon Q chat is active (QCHAT_PROCESS_ID=$QCHAT_PROCESS_ID)"
4+ echo "Please exit Amazon Q chat with '/quit' before pushing changes."
5+ exit 1
6+ fi
7+
8+ # Continue with push if QCHAT_PROCESS_ID is not set
9+ exit 0
Original file line number Diff line number Diff line change @@ -26,3 +26,6 @@ pub const MAX_NUMBER_OF_IMAGES_PER_REQUEST: usize = 10;
2626
2727/// In bytes - 10 MB
2828pub const MAX_IMAGE_SIZE : usize = 10 * 1024 * 1024 ;
29+
30+ /// Environment variable containing the pid of the chat session.
31+ pub const QCHAT_PROCESS_ID : & str = "QCHAT_PROCESS_ID" ;
Original file line number Diff line number Diff line change 11pub mod cli;
22mod command;
3- mod consts;
3+ pub mod consts;
44mod context;
55mod conversation_state;
66mod hooks;
Original file line number Diff line number Diff line change 1- mod chat;
1+ pub mod chat;
22mod debug;
33mod diagnostics;
44mod feed;
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ use clap::Parser;
1717use crossterm:: style:: Stylize ;
1818use eyre:: Result ;
1919use logging:: get_log_level_max;
20+ use platform:: Context ;
2021use tracing:: metadata:: LevelFilter ;
2122
2223#[ global_allocator]
@@ -33,6 +34,18 @@ fn main() -> Result<ExitCode> {
3334 } ,
3435 } ;
3536
37+ // Set the QCHAT_PROCESS_ID env var if we're launching chat.
38+ #[ cfg( unix) ]
39+ match parsed. subcommand {
40+ Some ( cli:: CliRootCommands :: Chat ( _) ) | None => {
41+ let ctx = Context :: new ( ) ;
42+ let current_pid = nix:: unistd:: getpid ( ) . as_raw ( ) . to_string ( ) ;
43+ // SAFETY: This is only executed in a single-threaded context.
44+ unsafe { ctx. env ( ) . set_var ( cli:: chat:: consts:: QCHAT_PROCESS_ID , current_pid) } ;
45+ } ,
46+ _ => ( ) ,
47+ }
48+
3649 let verbose = parsed. verbose > 0 ;
3750 let runtime = tokio:: runtime:: Builder :: new_multi_thread ( ) . enable_all ( ) . build ( ) ?;
3851 let result = runtime. block_on ( parsed. execute ( ) ) ;
You can’t perform that action at this time.
0 commit comments