Software factory (review phase): per-user Gitea/GitHub/GitLab connections, spec chat, project creation, factory page
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b5e2ef146c
commit
4000084560
18 files changed
+2771
-1
No files matched your search
+18
-1
@@ -189,6 +189,20 @@ impl App {
|
||||
std::fs::canonicalize(&ws).unwrap_or(ws)
|
||||
}
|
||||
|
||||
/// Separate area of the software factory (mounted outside the workspace); None when absent.
|
||||
pub fn factory_dir(&self) -> Option<PathBuf> {
|
||||
let p = std::env::var("CODECRAFT_FACTORY_DIR").ok().filter(|p| !p.is_empty()).unwrap_or_else(|| "/factory".into());
|
||||
let p = PathBuf::from(p);
|
||||
p.is_dir().then(|| std::fs::canonicalize(&p).unwrap_or(p))
|
||||
}
|
||||
|
||||
/// The user's own folder in the factory area (created on demand).
|
||||
pub fn factory_home(&self, user: &crate::store::User) -> Option<PathBuf> {
|
||||
let dir = self.factory_dir()?.join(&user.username);
|
||||
std::fs::create_dir_all(&dir).ok()?;
|
||||
Some(dir)
|
||||
}
|
||||
|
||||
/// Directories a session owner may work in: admins (and legacy sessions
|
||||
/// without owner) the whole workspace, users their own folder plus shared folders.
|
||||
pub fn user_roots(&self, owner_id: Option<&str>) -> Vec<PathBuf> {
|
||||
@@ -196,12 +210,15 @@ impl App {
|
||||
let Some(user) = owner_id.and_then(|id| self.store.user(id).ok().flatten()) else {
|
||||
return vec![ws];
|
||||
};
|
||||
// The user's factory folder (if the area is mounted) is an additional root.
|
||||
let factory = self.factory_dir().map(|d| d.join(&user.username)).filter(|d| d.is_dir());
|
||||
if user.is_admin() {
|
||||
return vec![ws];
|
||||
return std::iter::once(ws).chain(factory).collect();
|
||||
}
|
||||
let own = ws.join(&user.username);
|
||||
let _ = std::fs::create_dir_all(&own);
|
||||
let mut roots = vec![own];
|
||||
roots.extend(factory);
|
||||
for p in self.store.folders_for_user(&user.id).unwrap_or_default() {
|
||||
let p = PathBuf::from(p);
|
||||
if p.starts_with(&ws) && p.is_dir() {
|
||||
|
||||
Reference in new issue
Block a user