mirror of
https://github.com/openai/codex.git
synced 2026-11-05 16:29:31 +00:00
feat: memories menu (#17632)
Add menu that: 1. If memories feature is not enabled, propose to enable it 2. Let you choose if you want to generate memories and to use memories
This commit is contained in:
1 parent
544b4e39e3
commit
9402347f34
13 files changed
+718
-1
No files matched your search
@@ -251,6 +251,11 @@ const MULTI_AGENT_ENABLE_TITLE: &str = "Enable subagents?";
|
||||
const MULTI_AGENT_ENABLE_YES: &str = "Yes, enable";
|
||||
const MULTI_AGENT_ENABLE_NO: &str = "Not now";
|
||||
const MULTI_AGENT_ENABLE_NOTICE: &str = "Subagents will be enabled in the next session.";
|
||||
const MEMORIES_DOC_URL: &str = "https://developers.openai.com/codex/memories";
|
||||
const MEMORIES_ENABLE_TITLE: &str = "Enable memories?";
|
||||
const MEMORIES_ENABLE_YES: &str = "Yes, enable";
|
||||
const MEMORIES_ENABLE_NO: &str = "Not now";
|
||||
const MEMORIES_ENABLE_NOTICE: &str = "Memories will be enabled in the next session.";
|
||||
const PLAN_MODE_REASONING_SCOPE_TITLE: &str = "Apply reasoning change";
|
||||
const PLAN_MODE_REASONING_SCOPE_PLAN_ONLY: &str = "Apply to Plan mode override";
|
||||
const PLAN_MODE_REASONING_SCOPE_ALL_MODES: &str = "Apply to global default and Plan mode override";
|
||||
@@ -311,6 +316,7 @@ use crate::bottom_pane::ExperimentalFeaturesView;
|
||||
use crate::bottom_pane::InputResult;
|
||||
use crate::bottom_pane::LocalImageAttachment;
|
||||
use crate::bottom_pane::McpServerElicitationFormRequest;
|
||||
use crate::bottom_pane::MemoriesSettingsView;
|
||||
use crate::bottom_pane::MentionBinding;
|
||||
use crate::bottom_pane::QUIT_SHORTCUT_TIMEOUT;
|
||||
use crate::bottom_pane::SelectionAction;
|
||||
@@ -2588,6 +2594,61 @@ impl ChatWidget {
|
||||
});
|
||||
}
|
||||
|
||||
pub(crate) fn open_memories_popup(&mut self) {
|
||||
if !self.config.features.enabled(Feature::MemoryTool) {
|
||||
self.open_memories_enable_prompt();
|
||||
return;
|
||||
}
|
||||
|
||||
let view = MemoriesSettingsView::new(
|
||||
self.config.memories.use_memories,
|
||||
self.config.memories.generate_memories,
|
||||
self.app_event_tx.clone(),
|
||||
);
|
||||
self.bottom_pane.show_view(Box::new(view));
|
||||
}
|
||||
|
||||
pub(crate) fn open_memories_enable_prompt(&mut self) {
|
||||
let items = vec![
|
||||
SelectionItem {
|
||||
name: MEMORIES_ENABLE_YES.to_string(),
|
||||
description: Some(
|
||||
"Save the setting now. You will need a new session to use it.".to_string(),
|
||||
),
|
||||
actions: vec![Box::new(|tx| {
|
||||
tx.send(AppEvent::UpdateFeatureFlags {
|
||||
updates: vec![(Feature::MemoryTool, true)],
|
||||
});
|
||||
})],
|
||||
dismiss_on_select: true,
|
||||
..Default::default()
|
||||
},
|
||||
SelectionItem {
|
||||
name: MEMORIES_ENABLE_NO.to_string(),
|
||||
description: Some("Keep memories disabled.".to_string()),
|
||||
dismiss_on_select: true,
|
||||
..Default::default()
|
||||
},
|
||||
];
|
||||
|
||||
self.bottom_pane.show_selection_view(SelectionViewParams {
|
||||
title: Some(MEMORIES_ENABLE_TITLE.to_string()),
|
||||
subtitle: Some("Memories are currently disabled in your config.".to_string()),
|
||||
footer_note: Some(Line::from(vec![
|
||||
"Learn more: ".dim(),
|
||||
MEMORIES_DOC_URL.cyan().underlined(),
|
||||
])),
|
||||
footer_hint: Some(standard_popup_hint_line()),
|
||||
items,
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
|
||||
pub(crate) fn set_memory_settings(&mut self, use_memories: bool, generate_memories: bool) {
|
||||
self.config.memories.use_memories = use_memories;
|
||||
self.config.memories.generate_memories = generate_memories;
|
||||
}
|
||||
|
||||
pub(crate) fn set_token_info(&mut self, info: Option<TokenUsageInfo>) {
|
||||
match info {
|
||||
Some(info) => self.apply_token_info(info),
|
||||
@@ -9693,6 +9754,13 @@ impl ChatWidget {
|
||||
self.request_redraw();
|
||||
}
|
||||
|
||||
pub(crate) fn add_memories_enable_notice(&mut self) {
|
||||
self.add_to_history(history_cell::new_warning_event(
|
||||
MEMORIES_ENABLE_NOTICE.to_string(),
|
||||
));
|
||||
self.request_redraw();
|
||||
}
|
||||
|
||||
pub(crate) fn add_plain_history_lines(&mut self, lines: Vec<Line<'static>>) {
|
||||
self.add_boxed_history(Box::new(PlainHistoryCell::new(lines)));
|
||||
self.request_redraw();
|
||||
@@ -10372,6 +10440,7 @@ impl ChatWidget {
|
||||
self.config.features = config.features.clone();
|
||||
self.config.config_layer_stack = config.config_layer_stack.clone();
|
||||
self.config.realtime = config.realtime.clone();
|
||||
self.config.memories = config.memories.clone();
|
||||
}
|
||||
|
||||
pub(crate) fn open_review_popup(&mut self) {
|
||||
|
||||
Reference in new issue
Block a user