Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

[codex] expose structured app context modes in CLI (#5564)

Louis Beaumontc2cddee560da
diff --git a/crates/screenpipe-engine/src/cli/mod.rs b/crates/screenpipe-engine/src/cli/mod.rs
index 8ba7b3778..926fa95fe 100644
--- a/crates/screenpipe-engine/src/cli/mod.rs
+++ b/crates/screenpipe-engine/src/cli/mod.rs
@@ -145,6 +145,31 @@ impl From<CliTranscriptionMode> for TranscriptionMode {
}
}
+#[derive(Clone, Copy, Debug, ValueEnum, PartialEq, Eq)]
+pub enum CliAppContext {
+ /// Disable structured app context
+ Off,
+ /// Build compact context for search, summaries, and pipes
+ Memory,
+ /// Keep action controls, state, and bounds for computer-use agents
+ Automation,
+ /// Build both the memory and automation projections from one capture
+ Both,
+}
+
+impl CliAppContext {
+ fn resolved(self) -> (bool, screenpipe_config::SemanticContextMode) {
+ use screenpipe_config::SemanticContextMode;
+
+ match self {
+ Self::Off => (false, SemanticContextMode::Memory),
+ Self::Memory => (true, SemanticContextMode::Memory),
+ Self::Automation => (true, SemanticContextMode::ComputerUse),
+ Self::Both => (true, SemanticContextMode::Both),
+ }
+ }
+}
+
#[derive(Clone, Debug, ValueEnum, PartialEq)]
pub enum OutputFormat {
Text,
@@ -564,9 +589,18 @@ pub struct RecordArgs {
#[arg(long, default_value_t = false)]
pub disable_screenshots: bool,
+ /// Select structured app context: off, memory, automation, or both.
+ /// Memory builds compact context for retrieval and pipes; automation keeps
+ /// action controls, state, and bounds for computer-use agents. Off by default.
+ #[arg(long, value_enum)]
+ pub app_context: Option<CliAppContext>,
+
/// Enable experimental normalized semantic context parsing. Parsing runs
/// after durable frame capture in a bounded background worker. Off by
/// default, preserving the historical capture and retrieval behavior.
+ /// Kept for compatibility; equivalent to `--app-context memory` on a
+ /// fresh CLI configuration. `--app-context` takes precedence when
+ /// both are supplied.
#[arg(
long,
env = "SCREENPIPE_ENABLE_SEMANTIC_CONTEXT",
@@ -848,6 +882,7 @@ pub struct RecordArgSources {
pub filter_music: bool,
pub disable_vision: bool,
pub disable_screenshots: bool,
+ pub app_context: bool,
pub enable_semantic_context: bool,
pub ignored_windows: bool,
pub included_windows: bool,
@@ -911,6 +946,7 @@ impl RecordArgSources {
filter_music: from_command_line(record, "filter_music"),
disable_vision: from_command_line(record, "disable_vision"),
disable_screenshots: from_command_line(record, "disable_screenshots"),
+ app_context: from_command_line(record, "app_context"),
enable_semantic_context: from_command_line(record, "enable_semantic_context"),
ignored_windows: from_command_line(record, "ignored_windows"),
included_windows: from_command_line(record, "included_windows"),
@@ -963,6 +999,7 @@ impl RecordArgSources {
|| self.filter_music
|| self.disable_vision
|| self.disable_screenshots
+ || self.app_context
|| self.enable_semantic_context
|| self.ignored_windows
|| self.included_windows
@@ -1103,6 +1140,11 @@ impl RecordArgs {
} else {
screenpipe_config::AecMode::Off
};
+ let (enable_semantic_context, semantic_context_mode) =
+ self.app_context.map(CliAppContext::resolved).unwrap_or((
+ self.enable_semantic_context,
+ screenpipe_config::SemanticContextMode::Memory,
+ ));
screenpipe_config::RecordingSettings {
audio_chunk_duration: self.audio_chunk_duration as i32,
@@ -1110,7 +1152,8 @@ impl RecordArgs {
disable_audio: self.disable_audio,
disable_vision: self.disable_vision,
disable_screenshots: self.disable_screenshots,
- enable_semantic_context: self.enable_semantic_context,
+ enable_semantic_context,
+ semantic_context_mode,
// CLI has no --disable-timeline flag; the desktop app drives this
// toggle. Default to enabled (timeline on) for the engine binary.
disable_timeline: false,
@@ -1432,7 +1475,14 @@ impl RecordArgs {
if sources.disable_screenshots {
settings.disable_screenshots = self.disable_screenshots;
}
- if sources.enable_semantic_context {
+ if sources.app_context {
+ let (enabled, mode) = self
+ .app_context
+ .expect("explicit app context source must have a value")
+ .resolved();
+ settings.enable_semantic_context = enabled;
+ settings.semantic_context_mode = mode;
+ } else if sources.enable_semantic_context {
settings.enable_semantic_context = self.enable_semantic_context;
}
// An explicit --monitor-id or --use-all-monitors means the user wants
@@ -2341,10 +2391,17 @@ mod tests {
match cli.command {
Command::Record(args) => {
assert!(!args.pause_on_drm_content, "default should be false");
+ assert!(args.app_context.is_none());
assert!(
!args.enable_semantic_context,
"semantic parsing must remain opt-in"
);
+ let settings = args.to_recording_settings();
+ assert!(!settings.enable_semantic_context);
+ assert_eq!(
+ settings.semantic_context_mode,
+ screenpipe_config::SemanticContextMode::Memory
+ );
}
_ => panic!("expected Record command"),
}
@@ -2357,7 +2414,66 @@ mod tests {
match cli.command {
Command::Record(args) => {
assert!(args.enable_semantic_context);
- assert!(args.to_recording_settings().enable_semantic_context);
+ let settings = args.to_recording_settings();
+ assert!(settings.enable_semantic_context);
+ assert_eq!(
+ settings.semantic_context_mode,
+ screenpipe_config::SemanticContextMode::Memory
+ );
+ }
+ _ => panic!("expected Record command"),
+ }
+ }
+
+ #[test]
+ fn test_app_context_modes_flow_to_recording_settings() {
+ use screenpipe_config::SemanticContextMode;
+
+ let cases = [
+ ("off", false, SemanticContextMode::Memory),
+ ("memory", true, SemanticContextMode::Memory),
+ ("automation", true, SemanticContextMode::ComputerUse),
+ ("both", true, SemanticContextMode::Both),
+ ];
+
+ for (value, enabled, mode) in cases {
+ let cli =
+ Cli::try_parse_from(["screenpipe", "record", "--app-context", value]).unwrap();
+ match cli.command {
+ Command::Record(args) => {
+ let settings = args.to_recording_settings();
+ assert_eq!(settings.enable_semantic_context, enabled, "mode: {value}");
+ assert_eq!(settings.semantic_context_mode, mode, "mode: {value}");
+ assert!(
+ record_sources(["screenpipe", "record", "--app-context", value,])
+ .app_context,
+ "mode should register as an explicit CLI source: {value}"
+ );
+ }
+ _ => panic!("expected Record command"),
+ }
+ }
+ }
+
+ #[test]
+ fn test_app_context_argument_takes_precedence_over_legacy_enable_flag() {
+ let cli = Cli::try_parse_from([
+ "screenpipe",
+ "record",
+ "--enable-semantic-context",
+ "--app-context",
+ "off",
+ ])
+ .unwrap();
+
+ match cli.command {
+ Command::Record(args) => {
+ let settings = args.to_recording_settings();
+ assert!(!settings.enable_semantic_context);
+ assert_eq!(
+ settings.semantic_context_mode,
+ screenpipe_config::SemanticContextMode::Memory
+ );
}
_ => panic!("expected Record command"),
}
@@ -2686,6 +2802,77 @@ mod tests {
);
}
+ #[test]
+ fn test_app_context_off_overrides_persisted_enabled_mode() {
+ let args = ["screenpipe", "record", "--app-context", "off"];
+ let cli = Cli::try_parse_from(args).unwrap();
+ let sources = record_sources(args);
+ let mut settings = screenpipe_config::RecordingSettings {
+ enable_semantic_context: true,
+ semantic_context_mode: screenpipe_config::SemanticContextMode::Both,
+ ..Default::default()
+ };
+
+ match cli.command {
+ Command::Record(args) => args.apply_explicit_overrides(&mut settings, &sources),
+ _ => panic!("expected Record command"),
+ }
+
+ assert!(!settings.enable_semantic_context);
+ assert_eq!(
+ settings.semantic_context_mode,
+ screenpipe_config::SemanticContextMode::Memory
+ );
+ }
+
+ #[test]
+ fn test_app_context_automation_overrides_persisted_disabled_mode() {
+ let args = ["screenpipe", "record", "--app-context", "automation"];
+ let cli = Cli::try_parse_from(args).unwrap();
+ let sources = record_sources(args);
+ let mut settings = screenpipe_config::RecordingSettings {
+ enable_semantic_context: false,
+ semantic_context_mode: screenpipe_config::SemanticContextMode::Memory,
+ ..Default::default()
+ };
+
+ match cli.command {
+ Command::Record(args) => args.apply_explicit_overrides(&mut settings, &sources),
+ _ => panic!("expected Record command"),
+ }
+
+ assert!(settings.enable_semantic_context);
+ assert_eq!(
+ settings.semantic_context_mode,
+ screenpipe_config::SemanticContextMode::ComputerUse
+ );
+ }
+
+ #[test]
+ fn test_absent_app_context_arguments_preserve_persisted_settings() {
+ let args = ["screenpipe", "record", "--port", "4040"];
+ let cli = Cli::try_parse_from(args).unwrap();
+ let sources = record_sources(args);
+ let mut settings = screenpipe_config::RecordingSettings {
+ enable_semantic_context: true,
+ semantic_context_mode: screenpipe_config::SemanticContextMode::Both,
+ ..Default::default()
+ };
+
+ match cli.command {
+ Command::Record(args) => args.apply_explicit_overrides(&mut settings, &sources),
+ _ => panic!("expected Record command"),
+ }
+
+ assert!(settings.enable_semantic_context);
+ assert_eq!(
+ settings.semantic_context_mode,
+ screenpipe_config::SemanticContextMode::Both
+ );
+ assert!(!sources.app_context);
+ assert!(!sources.enable_semantic_context);
+ }
+
#[test]
fn test_audio_device_flag_enables_audio_over_persisted_disable() {
// issue #3648: passing --audio-device must override a persisted