MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / start

Method start

atomic-cli/src/commands/git/agent_mode.rs:147–196  ·  view source on GitHub ↗
(requested: bool)

Source from the content-addressed store, hash-verified

145
146impl AgentAnimation {
147 pub fn start(requested: bool) -> Self {
148 if !requested
149 || !std::io::stderr().is_terminal()
150 || !std::io::stdout().is_terminal()
151 || std::env::var_os("TERM").is_none_or(|term| term == "dumb")
152 {
153 return Self::default();
154 }
155 let Some(output) = LiveOutput::start() else {
156 return Self::default();
157 };
158 let Ok(mut screen) = Screen::enter() else {
159 drop(output);
160 return Self::default();
161 };
162 let (stop, receiver) = mpsc::channel();
163 let worker = thread::Builder::new()
164 .name("atomic-agent-dance".into())
165 .spawn(move || {
166 let started = Instant::now();
167 loop {
168 let status = live::latest();
169 // Fullscreen draw handles erasure and resizes without a cursor
170 // position query (which may require a terminal response).
171 if screen
172 .0
173 .draw(|frame| draw(frame, started.elapsed(), &status))
174 .is_err()
175 {
176 break;
177 }
178 match receiver.recv_timeout(Duration::from_millis(100)) {
179 Err(mpsc::RecvTimeoutError::Timeout) => {}
180 _ => break,
181 }
182 }
183 });
184 match worker {
185 Ok(worker) => Self {
186 stop: Some(stop),
187 worker: Some(worker),
188 output: Some(output),
189 result: None,
190 },
191 Err(_) => {
192 drop(output);
193 Self::default()
194 }
195 }
196 }
197
198 pub fn finish(&mut self, success: bool) {
199 self.result = Some(success);

Callers

nothing calls this directly

Calls 6

stderrFunction · 0.85
stdoutFunction · 0.85
latestFunction · 0.85
spawnMethod · 0.80
drawFunction · 0.70
nameMethod · 0.45

Tested by

no test coverage detected