MCPcopy Create free account
hub / github.com/JaredStewart/coderlm / create_session

Function create_session

server/src/server/routes.rs:158–197  ·  view source on GitHub ↗
(
    State(state): State<AppState>,
    Json(body): Json<CreateSessionBody>,
)

Source from the content-addressed store, hash-verified

156}
157
158async fn create_session(
159 State(state): State<AppState>,
160 Json(body): Json<CreateSessionBody>,
161) -> Result<Json<Value>, AppError> {
162 let cwd_path = PathBuf::from(&body.cwd);
163
164 // Index the project (or return existing)
165 let project = state.get_or_create_project(&cwd_path)?;
166
167 let id = uuid::Uuid::new_v4().to_string();
168 let session = Session::new(id.clone(), project.root.clone());
169 let created_at = session.created_at;
170 state.inner.sessions.insert(id.clone(), session);
171
172 // Load annotations from disk after project is indexed
173 let ft = project.file_tree.clone();
174 let st = project.symbol_table.clone();
175 let root = project.root.clone();
176 tokio::spawn(async move {
177 // Small delay to let symbol extraction start first
178 tokio::time::sleep(std::time::Duration::from_millis(500)).await;
179 let _ = annotations::load_annotations(&root, &ft, &st);
180 });
181
182 // Return L1 structure in the session creation response
183 let structure_result = structure::get_structure_with_detail(
184 &project.root,
185 &project.file_tree,
186 &project.symbol_table,
187 0,
188 1,
189 );
190
191 Ok(Json(json!({
192 "session_id": id,
193 "created_at": created_at.to_rfc3339(),
194 "project": project.root.display().to_string(),
195 "structure": serde_json::to_value(&structure_result).unwrap_or(json!(null)),
196 })))
197}
198
199#[derive(Deserialize)]
200struct SessionPath {

Callers

nothing calls this directly

Calls 4

get_or_create_projectMethod · 0.80
load_annotationsFunction · 0.70
insertMethod · 0.45

Tested by

no test coverage detected