Keep automatic group discovery scoped to shared project clients
This commit is contained in:
@@ -33,16 +33,14 @@ Sessions capture their project path and abort signal. `readJson` returns an auth
|
|||||||
|
|
||||||
## Project start screen
|
## Project start screen
|
||||||
|
|
||||||
Use `sharedProjectsFolder: true` with `filesystem: appInfo.filesystem` for the shared group overview. Declare `group_projects_read` and `filesystem_read` in the extension manifest. The host advertises `supportsSharedGroupProjects` and `filesystem_list_group_projects` when the launch group supports automatic project access. The client lists direct `/shared/*.isap` projects returned for the group and validates their manifests. Members can open these projects on their first visit. A writable extension with `filesystem_write` uses `filesystem_create_group_project` to create or import into the same group. Opening a writable project provisions the extension's namespace, where it can initialize its own data. Older hosts display an update instruction.
|
Use `sharedProjectsFolder: true` with `filesystem: appInfo.filesystem` for the shared group overview. Declare `group_projects_read` and `filesystem_read` in the extension manifest. The host advertises `supportsSharedGroupProjects` and `filesystem_list_group_projects` when the launch group supports automatic project access. The catalog lists projects created for the launch group through `filesystem_create_group_project`. Each has a direct `/shared/*.isap` path and a manifest that the client verifies. Members can open these projects on their first visit. Earlier projects retain their existing folder access. A writable extension with `filesystem_write` uses `filesystem_create_group_project` to create or import into the same group. Opening a writable project provisions the extension's namespace, where it can initialize its own data. Older hosts display an update instruction.
|
||||||
|
|
||||||
### Other client configurations
|
### Other client configurations
|
||||||
|
|
||||||
Project extensions can declare `group_projects_read` alongside `filesystem_read` and pass the command list from `get_app_info` to the client. On a host advertising `filesystem_list_group_projects`, `client.list()` reads the launch group's catalog on every refresh. The host determines which project folders are available to the launch group and authorizes operations against their folder IDs. The same workspace can have many independent group catalogs. Writable extensions create projects in the group's extension root. ZIP import creates a new project identity and appears in the list once its contents have been written.
|
The default client uses the user's selected folders for listing and creation, including on hosts that advertise the group project catalog.
|
||||||
|
|
||||||
Use `client.withListedProject(row, action)` for project-specific background initialization. The callback receives a temporary session and leaves the active project and recent activity intact. ISA Projects initializes its first planning board with a stable ID when a writable shared project opens.
|
Use `client.withListedProject(row, action)` for project-specific background initialization. The callback receives a temporary session and leaves the active project and recent activity intact. ISA Projects initializes its first planning board with a stable ID when a writable shared project opens.
|
||||||
|
|
||||||
### Older hosts
|
|
||||||
|
|
||||||
Pass `groupFolder: true` to `createProjectClient` to use the extension’s folder for the current launch group as its default project location. This mode requires the host command `filesystem_ensure_group_folder`. The client lists projects from that folder and any additional folders the user has selected. New projects and project imports use the group folder.
|
Pass `groupFolder: true` to `createProjectClient` to use the extension’s folder for the current launch group as its default project location. This mode requires the host command `filesystem_ensure_group_folder`. The client lists projects from that folder and any additional folders the user has selected. New projects and project imports use the group folder.
|
||||||
|
|
||||||
### Project overview
|
### Project overview
|
||||||
|
|||||||
+7
-7
@@ -24,9 +24,9 @@ export function createProjectClient({ bridge, extensionId, scope, filesystem, fi
|
|||||||
const captured = Object.freeze({ workspaceId: scope.workspaceId, groupId: scope.groupId });
|
const captured = Object.freeze({ workspaceId: scope.workspaceId, groupId: scope.groupId });
|
||||||
const supportsFilesystem = command => !filesystemCommands || filesystemCommands.includes(command);
|
const supportsFilesystem = command => !filesystemCommands || filesystemCommands.includes(command);
|
||||||
if (groupFolder && sharedProjectsFolder) throw new TypeError('Choose one project storage location');
|
if (groupFolder && sharedProjectsFolder) throw new TypeError('Choose one project storage location');
|
||||||
const groupCatalog = filesystemCommands?.includes('filesystem_list_group_projects') === true;
|
const supportsSharedGroupProjects = sharedProjectsFolder && filesystem?.supportsSharedGroupProjects === true
|
||||||
const supportsSharedGroupProjects = filesystem?.supportsSharedGroupProjects === true;
|
&& filesystemCommands?.includes('filesystem_list_group_projects') === true;
|
||||||
const canCreateSharedProject = supportsSharedGroupProjects && groupCatalog && filesystemCommands.includes('filesystem_create_group_project');
|
const canCreateSharedProject = supportsSharedGroupProjects && filesystemCommands.includes('filesystem_create_group_project');
|
||||||
const canWrite = supportsFilesystem('filesystem_upload_files');
|
const canWrite = supportsFilesystem('filesystem_upload_files');
|
||||||
let active = null, recents = [], generation = 0, closed = false;
|
let active = null, recents = [], generation = 0, closed = false;
|
||||||
let preferenceWrites = Promise.resolve();
|
let preferenceWrites = Promise.resolve();
|
||||||
@@ -68,7 +68,7 @@ export function createProjectClient({ bridge, extensionId, scope, filesystem, fi
|
|||||||
}
|
}
|
||||||
const read = (path, sessionGuard = guard) => readAuthoritativeFile(invoke,path,sessionGuard);
|
const read = (path, sessionGuard = guard) => readAuthoritativeFile(invoke,path,sessionGuard);
|
||||||
const projectFiles = createProjectFilesystem({
|
const projectFiles = createProjectFilesystem({
|
||||||
invoke, invokePrivateStorage: invokeCurrent, read, canWrite, groupFolder: groupFolder || groupCatalog, groupCatalog, sharedProjectsFolder, supportsSharedGroupProjects, canCreateSharedProject
|
invoke, invokePrivateStorage: invokeCurrent, read, canWrite, groupFolder, sharedProjectsFolder, supportsSharedGroupProjects, canCreateSharedProject
|
||||||
});
|
});
|
||||||
async function loadProject(value, check) {
|
async function loadProject(value, check) {
|
||||||
check();
|
check();
|
||||||
@@ -290,12 +290,12 @@ export function createProjectClient({ bridge, extensionId, scope, filesystem, fi
|
|||||||
supports(action) {
|
supports(action) {
|
||||||
if (sharedProjectsFolder) {
|
if (sharedProjectsFolder) {
|
||||||
if (action === 'create') return canWrite && canCreateSharedProject;
|
if (action === 'create') return canWrite && canCreateSharedProject;
|
||||||
return action === 'archive' && canWrite && supportsSharedGroupProjects && groupCatalog;
|
return action === 'archive' && canWrite && supportsSharedGroupProjects;
|
||||||
}
|
}
|
||||||
if (action === 'create') return canWrite && supportsFilesystem('filesystem_create_folder')
|
if (action === 'create') return canWrite && supportsFilesystem('filesystem_create_folder')
|
||||||
&& (!groupCatalog || supportsFilesystem('filesystem_ensure_group_folder'));
|
&& (!groupFolder || supportsFilesystem('filesystem_ensure_group_folder'));
|
||||||
if (action === 'archive') return canWrite;
|
if (action === 'archive') return canWrite;
|
||||||
return action === 'pickFolder' && !groupCatalog && supportsFilesystem('open_workspace_folder');
|
return action === 'pickFolder' && supportsFilesystem('open_workspace_folder');
|
||||||
},
|
},
|
||||||
get active() { return active; }, get state() { return state(); },
|
get active() { return active; }, get state() { return state(); },
|
||||||
provideSwitchConfirmation(handler) {
|
provideSwitchConfirmation(handler) {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export function manifestFromSnapshot(snapshot) {
|
|||||||
return parseProjectManifest(JSON.parse(text));
|
return parseProjectManifest(JSON.parse(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createProjectFilesystem({ invoke, invokePrivateStorage, read, canWrite, groupFolder, groupCatalog, sharedProjectsFolder, supportsSharedGroupProjects, canCreateSharedProject }) {
|
export function createProjectFilesystem({ invoke, invokePrivateStorage, read, canWrite, groupFolder, sharedProjectsFolder, supportsSharedGroupProjects, canCreateSharedProject }) {
|
||||||
let selecting;
|
let selecting;
|
||||||
|
|
||||||
async function selectedRoots() {
|
async function selectedRoots() {
|
||||||
@@ -111,7 +111,7 @@ export function createProjectFilesystem({ invoke, invokePrivateStorage, read, ca
|
|||||||
}
|
}
|
||||||
|
|
||||||
function requireSharedCatalog() {
|
function requireSharedCatalog() {
|
||||||
if (supportsSharedGroupProjects && groupCatalog) return;
|
if (supportsSharedGroupProjects) return;
|
||||||
const error = new ProjectUnavailableError('Update ISA Warden and the dashboard to use shared group projects.');
|
const error = new ProjectUnavailableError('Update ISA Warden and the dashboard to use shared group projects.');
|
||||||
error.code = 'SHARED_GROUP_PROJECTS_UNAVAILABLE';
|
error.code = 'SHARED_GROUP_PROJECTS_UNAVAILABLE';
|
||||||
throw error;
|
throw error;
|
||||||
@@ -124,13 +124,12 @@ export function createProjectFilesystem({ invoke, invokePrivateStorage, read, ca
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function projectFolders() {
|
async function projectFolders() {
|
||||||
if (sharedProjectsFolder) requireSharedCatalog();
|
if (sharedProjectsFolder) {
|
||||||
if (groupCatalog) {
|
requireSharedCatalog();
|
||||||
const result = await invoke('filesystem_list_group_projects', {});
|
const result = await invoke('filesystem_list_group_projects', {});
|
||||||
if (result?.authoritative !== true || result.error || !Array.isArray(result.folders)) {
|
if (result?.authoritative !== true || result.error || !Array.isArray(result.folders)) {
|
||||||
throw new ProjectUnavailableError('Group project inventory unavailable');
|
throw new ProjectUnavailableError('Group project inventory unavailable');
|
||||||
}
|
}
|
||||||
if (!sharedProjectsFolder) return result.folders.map(folderReference);
|
|
||||||
return result.folders.filter(row => isSharedProject(row?.path)).map(row =>
|
return result.folders.filter(row => isSharedProject(row?.path)).map(row =>
|
||||||
folderReference({ fileId: row.fileId ?? row.id, path: row.path, canWrite: row.canWrite, archivedAt: row.archivedAt }));
|
folderReference({ fileId: row.fileId ?? row.id, path: row.path, canWrite: row.canWrite, archivedAt: row.archivedAt }));
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-9
@@ -5,6 +5,8 @@ import { importProject } from '../src/transfer.js';
|
|||||||
import { strToU8, zipSync } from 'fflate';
|
import { strToU8, zipSync } from 'fflate';
|
||||||
|
|
||||||
const project = id => ({id,folderId:id,name:id,path:`/projects/${id}.isap`,projectIdentity:id,formatVersion:1});
|
const project = id => ({id,folderId:id,name:id,path:`/projects/${id}.isap`,projectIdentity:id,formatVersion:1});
|
||||||
|
const sharedCommands = ['filesystem_list_group_projects', 'filesystem_create_group_project'];
|
||||||
|
const ordinaryCommands = ['open_workspace_folder', 'filesystem_create_folder', 'filesystem_upload_files', 'filesystem_list_dir', 'filesystem_get_files'];
|
||||||
function fixture(options = {}) {
|
function fixture(options = {}) {
|
||||||
const writes = [];
|
const writes = [];
|
||||||
const files = new Map(['one','two','three'].map(id => [`${project(id).path}/project.json`,{
|
const files = new Map(['one','two','three'].map(id => [`${project(id).path}/project.json`,{
|
||||||
@@ -43,26 +45,28 @@ function fixture(options = {}) {
|
|||||||
},
|
},
|
||||||
subscribeKv: options.subscribeKv
|
subscribeKv: options.subscribeKv
|
||||||
};
|
};
|
||||||
const client = createProjectClient({bridge,extensionId:'contracts',scope:{workspaceId:'workspace',groupId:'group'},filesystemCommands:options.filesystemCommands,groupFolder:options.groupFolder,sharedProjectsFolder:options.sharedProjectsFolder,beforeSwitch:options.beforeSwitch});
|
const client = createProjectClient({bridge,extensionId:'contracts',scope:{workspaceId:'workspace',groupId:'group'},filesystem:options.filesystem,filesystemCommands:options.filesystemCommands,groupFolder:options.groupFolder,sharedProjectsFolder:options.sharedProjectsFolder,beforeSwitch:options.beforeSwitch});
|
||||||
return {client,writes,bridge,files};
|
return {client,writes,bridge,files};
|
||||||
}
|
}
|
||||||
|
|
||||||
test('the launch group catalog excludes picker history and respects legacy folder archive state', async () => {
|
test('the shared group catalog excludes picker history and preserves the archived state', async () => {
|
||||||
let available = true;
|
let available = true;
|
||||||
const {client} = fixture({
|
const {client,files} = fixture({
|
||||||
filesystemCommands: ['filesystem_list_group_projects', 'filesystem_get_files'],
|
sharedProjectsFolder: true,
|
||||||
|
filesystem: {supportsSharedGroupProjects:true, commands:['filesystem_list_group_projects', 'filesystem_get_files']},
|
||||||
invoke(command, args) {
|
invoke(command, args) {
|
||||||
if (command === 'filesystem_list_group_projects') {
|
if (command === 'filesystem_list_group_projects') {
|
||||||
assert.deepEqual(args, {workspaceId: 'workspace', groupId: 'group'});
|
assert.deepEqual(args, {workspaceId: 'workspace', groupId: 'group'});
|
||||||
if (!available) throw new Error('Dashboard unavailable');
|
if (!available) throw new Error('Dashboard unavailable');
|
||||||
return {authoritative: true, folders: [
|
return {authoritative: true, folders: [
|
||||||
{...project('one'), canWrite: false},
|
{fileId:'one', path:'/shared/one.isap', canWrite:false},
|
||||||
{...project('two'), canWrite: false, archivedAt: '2026-11-03T12:00:00Z'}
|
{fileId:'two', path:'/shared/two.isap', canWrite:false, archivedAt:'2026-11-03T12:00:00Z'}
|
||||||
]};
|
]};
|
||||||
}
|
}
|
||||||
if (command === 'localstorage_get' || command === 'open_workspace_folder') assert.fail(command);
|
if (command === 'localstorage_get' || command === 'open_workspace_folder') assert.fail(command);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
for (const id of ['one','two']) files.set(`/shared/${id}.isap/project.json`, files.get(project(id).path + '/project.json'));
|
||||||
assert.deepEqual((await client.list()).map(row => row.id), ['one']);
|
assert.deepEqual((await client.list()).map(row => row.id), ['one']);
|
||||||
const all = await client.list(true);
|
const all = await client.list(true);
|
||||||
assert.equal(all.find(row => row.id === 'two').archived, true);
|
assert.equal(all.find(row => row.id === 'two').archived, true);
|
||||||
@@ -165,9 +169,10 @@ test('successful transport cannot confirm pending or conflicted project writes',
|
|||||||
await client.close();
|
await client.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('a selected container lists valid project manifests and opens them through its existing grant', async () => {
|
test('a picker client lists, opens and creates in the selected container on a group-catalog host', async () => {
|
||||||
let picks = 0;
|
let picks = 0;
|
||||||
const {client,files} = fixture({invoke(command, args) {
|
const filesystem = {supportsSharedGroupProjects:true, commands:[...ordinaryCommands, ...sharedCommands]};
|
||||||
|
const {client,files} = fixture({filesystem, invoke(command, args) {
|
||||||
if (command === 'open_workspace_folder') { picks++; return; }
|
if (command === 'open_workspace_folder') { picks++; return; }
|
||||||
if (command === 'filesystem_list_dir' && args.path === '/projects') {
|
if (command === 'filesystem_list_dir' && args.path === '/projects') {
|
||||||
return {authoritative:true,files:[
|
return {authoritative:true,files:[
|
||||||
@@ -178,6 +183,8 @@ test('a selected container lists valid project manifests and opens them through
|
|||||||
]};
|
]};
|
||||||
}
|
}
|
||||||
}});
|
}});
|
||||||
|
assert.equal(client.supports('pickFolder'), true);
|
||||||
|
assert.equal(client.supports('create'), true);
|
||||||
assert.deepEqual(await client.list(),[]);
|
assert.deepEqual(await client.list(),[]);
|
||||||
await client.pickFolder();
|
await client.pickFolder();
|
||||||
const [listed] = await client.list();
|
const [listed] = await client.list();
|
||||||
@@ -189,6 +196,8 @@ test('a selected container lists valid project manifests and opens them through
|
|||||||
files.set(listed.manifestPath,{...manifest,id:'one'});
|
files.set(listed.manifestPath,{...manifest,id:'one'});
|
||||||
await assert.rejects(client.openListed(listed),/identity/);
|
await assert.rejects(client.openListed(listed),/identity/);
|
||||||
assert.equal(client.active,selected);
|
assert.equal(client.active,selected);
|
||||||
|
const created = await client.create('Ordinary', 'ordinary');
|
||||||
|
assert.equal(created.project.path, '/projects/ordinary-ordinary.isap');
|
||||||
assert.equal(picks,1);
|
assert.equal(picks,1);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -307,13 +316,16 @@ test('replaced and revoked roots do not hide accessible projects or conceal dash
|
|||||||
|
|
||||||
test('group creation uses the launch group and opening a listed project creates no namespace', async () => {
|
test('group creation uses the launch group and opening a listed project creates no namespace', async () => {
|
||||||
const commands = [];
|
const commands = [];
|
||||||
const {client} = fixture({groupFolder:true, invoke(command) {
|
const filesystem = {supportsSharedGroupProjects:true, commands:[...ordinaryCommands, ...sharedCommands, 'filesystem_ensure_group_folder']};
|
||||||
|
const {client} = fixture({groupFolder:true, filesystem, invoke(command) {
|
||||||
commands.push(command);
|
commands.push(command);
|
||||||
if (command === 'filesystem_ensure_group_folder') return {folderId:'parent',path:'/projects'};
|
if (command === 'filesystem_ensure_group_folder') return {folderId:'parent',path:'/projects'};
|
||||||
if (command === 'open_workspace_folder') assert.fail('Unexpected folder picker');
|
if (command === 'open_workspace_folder') assert.fail('Unexpected folder picker');
|
||||||
}});
|
}});
|
||||||
const session = await client.create('Example', 'sample');
|
const session = await client.create('Example', 'sample');
|
||||||
assert.equal(session.project.path, '/projects/example-sample.isap');
|
assert.equal(session.project.path, '/projects/example-sample.isap');
|
||||||
|
assert.equal(client.supports('pickFolder'), true);
|
||||||
|
assert.deepEqual((await client.list()).map(row => row.path), [session.project.path]);
|
||||||
await client.leave();
|
await client.leave();
|
||||||
commands.length = 0;
|
commands.length = 0;
|
||||||
await client.openListed(session.project);
|
await client.openListed(session.project);
|
||||||
|
|||||||
Reference in New Issue
Block a user