Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ like `## [0.4.16] - 2026-10-24`.
- Members: model pickers list models a member cannot use under Not available, so a fallback list no longer fails with "You can't use ... on this hub". The web app no longer calls the owner-only MCP, Preview and hub copy routes for a member.
- Pasting a copied picture (from a website, Snipping Tool or a screenshot) works on Windows, in the app and the browser

### Changed

- Pick a folder like in Codex: search, recent folders, and Open folder… with a folder browser; add a folder as a project in one step

## [0.4.103] - 2026-11-19

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
Expand All @@ -17,7 +18,11 @@ import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
Expand All @@ -33,6 +38,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import dev.conclave.app.data.CodeDefaults
Expand All @@ -47,10 +53,12 @@ import dev.conclave.client.folderGit
import dev.conclave.client.github
import dev.conclave.client.githubBranches
import dev.conclave.client.githubRepos
import dev.conclave.client.logic.Locations
import dev.conclave.client.logic.Panel
import dev.conclave.client.logic.Paths
import dev.conclave.client.logic.RepoWords
import dev.conclave.client.logic.Start
import dev.conclave.client.model.FileEntry
import dev.conclave.client.model.FolderGit
import dev.conclave.client.model.GithubBranches
import dev.conclave.client.model.GithubRepo
Expand Down Expand Up @@ -147,7 +155,11 @@ fun CodeWhereSheet(
var typed by remember { mutableStateOf("") }
var fromGithub by remember { mutableStateOf(github && (startGithub || d.repo != null)) }
val device = d.device
val folders = remember(sessions, device) { if (device == null) emptyList() else Panel.recentFolders(sessions, device) }
val home = devices.firstOrNull { it.id == device }?.info?.home?.ifBlank { null }
// Recent as in Codex: the folder's name over its muted path (Panel.recentRows)
val rows = remember(sessions, device, home) { if (device == null) emptyList() else Panel.recentRows(sessions, device, home) }
val folders = rows.map { it.path }
var browsing by remember { mutableStateOf(false) }
// the folder picked is asked of its device before Start; the hub refuses a missing one too (core machine/folder-check.ts)
val chosen = if (fromGithub) null else d.cwd
val online = device == Start.HUB || devices.firstOrNull { it.id == device }?.online == true
Expand Down Expand Up @@ -200,9 +212,10 @@ fun CodeWhereSheet(
HorizontalDivider(thickness = 1.dp, color = c.rule, modifier = Modifier.padding(top = 6.dp))
OptionLabel("Folder")
ChoiceRow("Home folder", selected = d.cwd == "~", onClick = { onChange(d.copy(cwd = "~", repo = null, base = null)) })
folders.forEach { f ->
ChoiceRow(Paths.folderName(f), selected = d.cwd == f, detail = Paths.shortPath(f, 3), onClick = { onChange(d.copy(cwd = f, repo = null, base = null)) })
rows.forEach { r ->
ChoiceRow(r.name, selected = d.cwd == r.path, detail = r.detail, onClick = { onChange(d.copy(cwd = r.path, repo = null, base = null)) })
}
ChoiceRow("Browse…", selected = false, onClick = { browsing = true })
Row(Modifier.fillMaxWidth().padding(horizontal = 20.dp, vertical = 6.dp), verticalAlignment = Alignment.CenterVertically) {
OutlinedTextField(
value = typed,
Expand Down Expand Up @@ -240,6 +253,12 @@ fun CodeWhereSheet(
if (!anyway) TextButton(onClick = { anyway = true }, modifier = Modifier.padding(horizontal = 12.dp)) { Text("Use anyway") }
}
}
if (browsing && device != null) {
BrowseFolderSheet(device, deviceName, home, start = d.cwd, onSelect = {
browsing = false
onChange(d.copy(cwd = it, repo = null, base = null))
}, onDismiss = { browsing = false })
}
Spacer(Modifier.height(8.dp))
Button(
onClick = onDone,
Expand All @@ -251,6 +270,59 @@ fun CodeWhereSheet(
}
}

/**
* Browse… in CodeWhereSheet: the device's folders over GET
* /api/devices/:device/files (as Choose folder does, FolderPickerSheet.kt).
* Tap a folder to go in, Up to go back, Select to use the folder shown.
*/
@Composable
private fun BrowseFolderSheet(device: String, deviceName: String, home: String?, start: String?, onSelect: (String) -> Unit, onDismiss: () -> Unit) {
val hub = LocalAppContainer.current.hub
val c = Conclave.colors
var path by remember { mutableStateOf(Locations.expandTilde(start?.takeIf { it.isNotBlank() } ?: "~", home).ifBlank { home ?: "/" }) }
var entries by remember { mutableStateOf<List<FileEntry>?>(null) }
var error by remember { mutableStateOf<String?>(null) }
LaunchedEffect(path) {
entries = null
error = null
try {
entries = hub.api { it.browse(device, path) }.filter { it.type == "dir" || it.type == "symlink" }.filter { !it.name.startsWith(".") }.sortedBy { it.name.lowercase() }
} catch (e: CancellationException) {
throw e
} catch (e: Exception) {
error = errorText(e)
}
}
val up = Locations.parentOf(path)
ModalBottomSheet(onDismissRequest = onDismiss, sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true), containerColor = c.bgRaise) {
Column(Modifier.fillMaxWidth().navigationBarsPadding().padding(bottom = 16.dp)) {
Text("Open folder on $deviceName", style = ConclaveType.title, color = c.fg, modifier = Modifier.padding(horizontal = 20.dp, vertical = 8.dp))
Row(Modifier.fillMaxWidth().padding(horizontal = 8.dp), verticalAlignment = Alignment.CenterVertically) {
IconButton(onClick = { up?.let { path = it } }, enabled = up != null) {
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Up one folder")
}
Text(Locations.tildePath(path, home), style = CodeStyle, color = c.fg2, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f))
}
HorizontalDivider(thickness = 1.dp, color = c.rule)
Column(Modifier.fillMaxWidth().heightIn(min = 120.dp, max = 420.dp).verticalScroll(rememberScrollState())) {
val list = entries
when {
error != null -> Text(error.orEmpty(), style = ConclaveType.meta, color = c.fault, modifier = Modifier.padding(horizontal = 20.dp, vertical = 10.dp))
list == null -> Text("Reading the folder", style = ConclaveType.meta, color = c.fg3, modifier = Modifier.padding(horizontal = 20.dp, vertical = 10.dp))
list.isEmpty() -> Text("No folders in here.", style = ConclaveType.meta, color = c.fg3, modifier = Modifier.padding(horizontal = 20.dp, vertical = 10.dp))
else -> list.forEach { e -> ChoiceRow(e.name, selected = false, onClick = { path = e.path.ifBlank { path.trimEnd('/') + "/" + e.name } }) }
}
}
Button(
onClick = { onSelect(Locations.tildePath(path, home)) },
enabled = error == null,
colors = solidButtonColors(),
modifier = Modifier.fillMaxWidth().padding(horizontal = 20.dp, vertical = 8.dp).height(52.dp),
) { Text("Select this folder") }
}
}
}

/** The folder picked in CodeWhereSheet: there (or not checkable: OK), being asked, or not on the device. */
private enum class FolderState { OK, CHECKING, MISSING }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ object Panel {
.map { it.cwd.trimEnd('/', '\\') }
.distinct()
.take(count)

/** One Recent row as in Codex: the folder's name over its muted path; [detail] is null when ~/<name> says nothing more. */
data class FolderRow(val path: String, val name: String, val detail: String?)

/**
* [recentFolders] as rows (web: FolderPicker.tsx withDetails). The path
* shows under the name when two rows share a name, or when it is more
* than ~/<name>.
*/
fun recentRows(sessions: List<Session>, device: String, home: String?, count: Int = 8): List<FolderRow> {
val folders = recentFolders(sessions, device, count)
val names = folders.map { Paths.folderName(Locations.tildePath(it, home)).ifEmpty { it } }
return folders.mapIndexed { i, f ->
val shown = Locations.tildePath(f, home)
val name = names[i]
val plain = shown == "~/$name" || shown == name
FolderRow(f, name, if (!plain || names.count { it.equals(name, ignoreCase = true) } > 1) shown else null)
}
}
}

object Lists {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,26 @@ class PanelTest {
assertEquals(listOf("/srv/app"), Panel.recentFolders(sessions, "local"))
}

@Test
fun recentRowsShowTheNameAndThePathOnlyWhenItSaysMore() {
val sessions = listOf(
agent("a", "x", at(20, 9)).copy(cwd = "/Users/sam/site"),
agent("b", "x", at(20, 10)).copy(cwd = "/Users/sam/work/site/"),
agent("c", "x", at(20, 8)).copy(cwd = "/Users/sam/conclave"),
agent("d", "x", at(20, 7)).copy(cwd = "/Users/sam/uni/Project-1"),
agent("e", "x", at(20, 6)).copy(cwd = "/Users/sam/conclave"),
)
assertEquals(
listOf(
Panel.FolderRow("/Users/sam/work/site", "site", "~/work/site"),
Panel.FolderRow("/Users/sam/site", "site", "~/site"),
Panel.FolderRow("/Users/sam/conclave", "conclave", null),
Panel.FolderRow("/Users/sam/uni/Project-1", "Project-1", "~/uni/Project-1"),
),
Panel.recentRows(sessions, "mac", "/Users/sam"),
)
}

@Test
fun listsAreChatsOrCodePinnedFirstThenByTime() {
val sessions = listOf(
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1962,6 +1962,8 @@ export class ConclaveClient {
identifyFolder = (input: { device: string; path: string; sessionId?: string; projectId?: string }) => this.request<IdentifyResult>('POST', '/api/projects/identify', input);
projects = () => this.request<ProjectDto[]>('GET', '/api/projects');
project = (id: string) => this.request<ProjectDto>('GET', `/api/projects/${id}`);
/** Add as project: the folder becomes a project named `name` (a plain folder gets a .conclave/project.json marker). */
addProject = (device: string, path: string, name: string) => this.request<ProjectDto>('POST', '/api/projects', { device, path, name });
/** Verify a folder is the project and pin it as its location on the device. */
pinLocation = (projectId: string, device: string, path: string) => this.request<ProjectDto>('PUT', `/api/projects/${projectId}/locations`, { device, path });
unpinLocation = (projectId: string, device: string, path: string) => this.request<ProjectDto>('DELETE', `/api/projects/${projectId}/locations`, undefined, { device, path });
Expand Down
49 changes: 49 additions & 0 deletions packages/core/src/projects/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,55 @@ export class ProjectsService {
return this.dto(this.store.get(p.id)!);
}

/**
* Add as project (the folder picker): make a folder the account's project
* under the name the owner gave. A git repository or synced folder is
* known by its history; a plain folder gets a marker
* (.conclave/project.json) so it can be told apart later. A folder that is
* already a project of the account answers that project.
*/
add(device: string, path: string, name: string, accountId: string = OWNER_ID): Promise<ProjectDto> {
// one add per device and path at a time: a second Select waits and finds the first one's project
const key = `${accountId}\n${device}\n${path}`;
const prev = this.adding.get(key) ?? Promise.resolve();
const run = prev.catch(() => undefined).then(() => this.addNow(device, path, name, accountId));
const tail = run.catch(() => undefined).finally(() => this.adding.get(key) === tail && this.adding.delete(key));
this.adding.set(key, tail);
return run;
}

private adding = new Map<string, Promise<unknown>>();

private async addNow(device: string, path: string, name: string, accountId: string): Promise<ProjectDto> {
const m = this.machine(device);
if (!m) throw new EngineError(409, `${this.deviceName(device)} is offline`);
const home = await this.engine.machineHome(m);
const abs = trimSlash(m.resolve(path, home ?? '/'));
// the home folder or the root as a project would make every folder under it that project
if (!abs || abs === '/' || /^[A-Za-z]:[\\/]?$/.test(abs) || (home && abs === trimSlash(home))) throw new EngineError(400, 'Pick a folder inside the home folder, not the home folder or the root');
let probe = await this.probe(device, abs);
if (!probe.exists) throw new EngineError(400, `${abs} does not exist on ${this.deviceName(device)}`);
const root = repoRoot(abs, probe);
const found = this.findProject(probe, device, root, accountId);
if (found) {
// the same history known from another place: this folder becomes one of its places too
if (!this.store.locations(found.id).some((l) => l.device === device && trimSlash(l.path) === root)) {
this.store.saveLocation(found.id, { device, path: root, via: 'pinned', pinned: true, head: probe.head });
this.emitProject(this.store.get(found.id)!);
}
return this.dto(this.store.get(found.id)!);
}
if (!this.identifiable(probe)) {
await m.writeFile(`${root}/.conclave/project.json`, `${JSON.stringify({ id: crypto.randomUUID() }, null, 2)}\n`);
probe = await this.probe(device, abs);
}
const p = this.store.create(name.trim() || probe.name, identityOf(probe), accountId);
this.store.saveLocation(p.id, { device, path: root, via: 'pinned', pinned: true, head: probe.head });
this.engine.audit(undefined, 'project.add', `${p.name}: ${device} ${root}`);
this.emitProject(p);
return this.dto(p);
}

unpin(projectId: string, device: string, path: string): ProjectDto {
const p = this.store.get(projectId);
if (!p) throw new EngineError(404, `unknown project ${projectId}`);
Expand Down
4 changes: 4 additions & 0 deletions packages/core/test/machine/private.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ describe('the CLIProxyAPI folder is out of reach of tools', () => {
await expect(m.readFile(join(work, 'link', 'auth', 'claude-me.json'))).rejects.toThrow(/Refused/);
await expect(m.readdir(join(home, 'cliproxy', 'auth'))).rejects.toThrow(/Refused/);
await expect(m.writeFile(join(home, 'cliproxy', 'auth', 'x.json'), '{}')).rejects.toThrow(/Refused/);
// New folder in the folder browser goes through mkdir (POST /api/devices/:device/folder)
await expect(m.mkdir(join(home, 'cliproxy', 'auth', 'new'))).rejects.toThrow(/Refused/);
await expect(m.mkdir(join(work, 'link', 'new'))).rejects.toThrow(/Refused/);
await m.mkdir(join(work, 'project', 'new'));
await expect(m.remove(home, { recursive: true })).rejects.toThrow(/Refused/);
await expect(m.rename(join(home, 'cliproxy', 'config.yaml'), join(work, 'stolen.yaml'))).rejects.toThrow(/Refused/);
expect(await m.readText(join(home, 'notes.txt'))).toContain('word');
Expand Down
36 changes: 35 additions & 1 deletion packages/core/test/projects/move.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* from test/engine/harness.ts: no paid calls.
*/
import { afterEach, describe, expect, test } from 'bun:test';
import { existsSync, readFileSync } from 'node:fs';
import { existsSync, mkdirSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
import { startTestEngine, toolResults, until, type Step, type TestEngine } from '../engine/harness';
import { projectsOf } from '../../src/projects/registry';
Expand Down Expand Up @@ -250,6 +250,40 @@ describe('the banner', () => {
});
});

describe('Add as project (the folder picker)', () => {
test('a plain folder gets a marker and a pinned location; a repository does not; adding again answers the same project', async () => {
const { d, svc } = await setup();
const plain = join(d.pc.home, 'notes');
mkdirSync(plain, { recursive: true });
const p = await svc.add('pc', plain, ' My notes ');
expect(p.name).toBe('My notes');
expect(JSON.parse(readFileSync(join(plain, '.conclave', 'project.json'), 'utf8')).id).toBeTruthy();
expect(p.locations).toMatchObject([{ device: 'pc', path: plain, pinned: true }]);
expect((await svc.add('pc', plain, 'Other name')).id).toBe(p.id);
expect(svc.list().map((x) => x.id)).toContain(p.id);

const repo = join(d.pc.home, 'code', 'site');
makeRepo(repo);
const r = await svc.add('pc', repo, '');
expect(r.name).toBe('site');
expect(existsSync(join(repo, '.conclave'))).toBe(false);
await expect(svc.add('pc', join(d.pc.home, 'nope'), 'x')).rejects.toThrow(/does not exist/);
await expect(svc.add('pc', d.pc.home, 'home')).rejects.toThrow(/not the home folder/);
await expect(svc.add('pc', '/', 'root')).rejects.toThrow(/not the home folder/);
// two Selects at once: one project, one marker
const twice = join(d.pc.home, 'twice');
mkdirSync(twice);
const [a, b] = await Promise.all([svc.add('pc', twice, 'Twice'), svc.add('pc', twice, 'Twice')]);
expect(a.id).toBe(b.id);
// the same history in another clone: that folder becomes another place of the project
const clone = join(d.pc.home, 'site-copy');
cloneRepo(repo, clone);
const again = await svc.add('pc', clone, 'ignored');
expect(again.id).toBe(r.id);
expect(again.locations.map((l) => l.path)).toContain(clone);
});
});

describe('the resumed context', () => {
test('an offline device parks the turn; it continues when the device is back', async () => {
const { t, d, svc } = await setup();
Expand Down
14 changes: 14 additions & 0 deletions packages/daemon-rs/src/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,20 @@ pub mod tests {
done(&home);
}

/// New folder in the folder browser: the "mkdir" RPC checks the path, then makes it (server.rs).
#[test]
fn mkdir_keeps_out_of_it() {
let (home, work) = fixture("mkdir");
let mk = |p: String| check(&p).and_then(|_| crate::fsops::mkdir_p(&p));
assert_eq!(mk(format!("{home}/cliproxy/auth/new")).unwrap_err().code.as_deref(), Some("EACCES"));
#[cfg(unix)]
assert!(mk(format!("{work}/link/new")).is_err());
assert!(mk(format!("{work}/project/new")).is_ok());
assert!(std::path::Path::new(&format!("{work}/project/new")).is_dir());
assert!(crate::fsops::mkdir_p("").is_err());
done(&home);
}

#[test]
fn a_shell_command_that_names_it() {
let (home, _) = fixture("commands");
Expand Down
2 changes: 2 additions & 0 deletions packages/server/src/route-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ export const ROUTE_POLICY: Record<string, Rule> = {
// ----- folders across devices -----
'POST /api/projects/identify': 'self',
'GET /api/projects': 'self',
// the route checks the device is the caller's own (scope.ts ownDevice)
'POST /api/projects': 'self',
'GET /api/projects/:id': own({ id: 'project' }),
'PUT /api/projects/:id/locations': own({ id: 'project' }),
'DELETE /api/projects/:id/locations': own({ id: 'project' }),
Expand Down
Loading
Loading