MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / new

Method new

crates/opencode-tui/src/components/prompt.rs:98–187  ·  view source on GitHub ↗
(context: Arc<AppContext>)

Source from the content-addressed store, hash-verified

96
97impl Prompt {
98 pub fn new(context: Arc<AppContext>) -> Self {
99 let state_dir = prompt_state_dir();
100 let history_path = state_dir.join("prompt-history.json");
101 let frecency_path = state_dir.join("prompt-frecency.json");
102 let stash_path = state_dir.join("prompt-stash.json");
103
104 let history = load_history(&history_path);
105 let frecency = load_frecency(&frecency_path);
106 let stash = load_stash(&stash_path);
107
108 let spinner_color = {
109 let theme = context.theme.read();
110 let agent = context.current_agent.read();
111 prompt_agent_color(&theme, agent.as_str())
112 };
113
114 let mut spinner = KnightRiderSpinner::with_color(spinner_color);
115 spinner.set_mode(spinner_mode_from_env());
116
117 let mut prompt = Self {
118 context,
119 input: String::new(),
120 cursor_position: 0,
121 focused: true,
122 placeholder: "Ask anything...".to_string(),
123 history,
124 history_index: None,
125 history_draft: None,
126 frecency,
127 stash,
128 suggestions: Vec::new(),
129 suggestion_index: None,
130 known_commands: vec![
131 "/help".to_string(),
132 "/model".to_string(),
133 "/agent".to_string(),
134 "/status".to_string(),
135 "/session".to_string(),
136 "/sessions".to_string(),
137 "/mcp".to_string(),
138 "/mcps".to_string(),
139 "/skill".to_string(),
140 "/export".to_string(),
141 "/stash".to_string(),
142 "/new".to_string(),
143 "/clear".to_string(),
144 "/share".to_string(),
145 "/unshare".to_string(),
146 "/rename".to_string(),
147 "/fork".to_string(),
148 "/compact".to_string(),
149 "/timeline".to_string(),
150 "/undo".to_string(),
151 "/redo".to_string(),
152 "/copy".to_string(),
153 "/themes".to_string(),
154 "/timestamps".to_string(),
155 "/tips.toggle".to_string(),

Callers

nothing calls this directly

Calls 11

prompt_state_dirFunction · 0.85
load_historyFunction · 0.85
load_frecencyFunction · 0.85
load_stashFunction · 0.85
prompt_agent_colorFunction · 0.85
spinner_mode_from_envFunction · 0.85
newFunction · 0.85
readMethod · 0.80
recompute_suggestionsMethod · 0.80
as_strMethod · 0.45
set_modeMethod · 0.45

Tested by

no test coverage detected