Skip to content

🌱 feat: Create an Explicit Default Workspace - #93

Merged
danny-avila merged 1 commit into
mainfrom
danny-avila/code-default-workspace
Sep 3, 2026
Merged

🌱 feat: Create an Explicit Default Workspace#93
danny-avila merged 1 commit into
mainfrom
danny-avila/code-default-workspace

Conversation

@danny-avila

Copy link
Copy Markdown
Collaborator

Summary

I added an explicit application-owned workspace for BYOM workers that start without an existing repository or project directory.

  • Create a stable workspace below the worker user's application-data directory with owner-only permissions.
  • Keep default workspaces isolated by worker and public workspace identifiers.
  • Require explicit --default-workspace or LIBRECHAT_CODE_DEFAULT_WORKSPACE=true opt-in.
  • Reject ambiguous configuration that combines a default workspace with --worker-dir.
  • Document the from-scratch workflow and persistence boundary.

Change Type

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Testing

  • Ran npm test in packages/code (129 tests passed).
  • Verified the CLI creates and registers the default workspace in a temporary home directory.
  • Verified storage paths remain stable, collision resistant, and owner-only.

Test Configuration:

  • macOS
  • Node.js package test runner
  • Temporary isolated home and workspace directories

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in any complex areas of my code
  • I have made pertinent documentation changes
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes

@danny-avila
danny-avila force-pushed the danny-avila/code-default-workspace branch from e6252a3 to 4f1886d Compare September 2, 2026 19:02
@danny-avila
danny-avila force-pushed the danny-avila/code-default-workspace branch from 4f1886d to 4971e70 Compare September 3, 2026 00:09
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current PR head 4971e70. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-03T00:44:50.661672Z ad6130f Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danny-avila
danny-avila force-pushed the danny-avila/code-default-workspace branch from 4971e70 to f2c1447 Compare September 3, 2026 00:12
@danny-avila

danny-avila commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review exact commit f2c1447. The prior requested review became stale because prerequisite PR #90 was squash-merged and #92/#93 were restacked onto the merged history; feature behavior is unchanged.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f2c1447a83

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/code/src/storage.ts Outdated
Comment on lines +35 to +37
return readableName === value
? readableName
: `${readableName}-${createHash('sha256')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make encoded storage names unambiguously distinct

When a valid ID contains :, the encoded result can itself be another valid ID that takes the unhashed branch. For example, vm:a and vm_a-2d4fcea9e21e004d both pass the bridge ID pattern and both map to vm_a-2d4fcea9e21e004d, so workers under the same home—or workspace IDs under one worker—can unexpectedly share the same persistent default workspace. Use disjoint encodings, such as hashing every value or prefixing encoded names.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in fbcba99. Default workspace components now use disjoint raw- and exact base64url encoded- namespaces, while the pre-existing bridge identity filename behavior remains unchanged. Added the reported collision pair as a regression test.

Comment thread packages/code/src/cli.ts Outdated
Comment on lines +221 to +224
const workerDirectory =
explicitWorkerDirectory ??
(useDefaultWorkspace
? defaultWorkspacePath(workerId, workspaceId)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat an empty worker directory as absent

When LIBRECHAT_CODE_WORKER_DIR is exported as an empty or whitespace-only placeholder (or --worker-dir= is supplied), explicitWorkerDirectory becomes ''. The conflict check treats that as absent, but this nullish coalescing still selects it, so --default-workspace/LIBRECHAT_CODE_DEFAULT_WORKSPACE=true silently creates and registers no workspace. Normalize the empty value to undefined before choosing the default path.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in fbcba99. Worker-directory input is normalized so empty and whitespace-only CLI/environment values are absent and --default-workspace can select the application-owned path. The CLI integration test now covers a whitespace-only environment value.

@danny-avila
danny-avila force-pushed the danny-avila/code-default-workspace branch from f2c1447 to fbcba99 Compare September 3, 2026 00:17
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review exact commit fbcba99. The two findings on f2c1447 are addressed with regression coverage; confirm this exact head and ignore earlier revisions.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fbcba99587

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/code/src/storage.ts Outdated
Comment on lines +41 to +43
return /^[A-Za-z0-9._-]+$/.test(value)
? `raw-${value}`
: `encoded-${Buffer.from(value, 'utf8').toString('base64url')}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Encode case to avoid aliases on case-insensitive filesystems

On case-insensitive filesystems such as the default macOS setup supported by this package, distinct valid IDs like VM-1 and vm-1 produce raw-VM-1 and raw-vm-1, which resolve to the same directory and can share persistent workspace contents under one home. Fresh evidence in this exact head is that the replacement raw- namespace still preserves letter case, while BRIDGE_WORKER_ID_PATTERN treats these IDs as distinct; use a case-independent encoding or digest for every component.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 47d4832. Every default workspace component now uses a full lowercase SHA-256 digest, so case-insensitive filesystems cannot alias distinct case-sensitive IDs. Coverage includes the VM-1/vm-1 case-folded comparison.

Comment thread packages/code/src/cli.ts
Comment on lines +72 to +74
function nonEmpty(value: string | undefined): string | undefined {
return value?.trim().length ? value : undefined;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep trimming configured worker directories

When LIBRECHAT_CODE_WORKER_DIR contains incidental leading or trailing whitespace, nonEmpty now verifies the trimmed value but returns the original string, so LocalWorkspaceTools.create calls realpath on a different path and rejects registration. The parent implementation trimmed this environment variable, so this commit regresses previously valid configurations such as LIBRECHAT_CODE_WORKER_DIR=' /srv/project '; return the normalized value for environment input while retaining the intended empty-value handling.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 47d4832. Environment-provided worker directories are trimmed before empty-value normalization, preserving the prior behavior; CLI-provided paths retain their literal spelling. Added a CLI regression test with leading/trailing environment whitespace.

@danny-avila
danny-avila force-pushed the danny-avila/code-default-workspace branch from fbcba99 to f8f8dc3 Compare September 3, 2026 00:22
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review exact commit f8f8dc3. This is the already-fixed #93 feature restacked without conflict on the reviewed #92 fixes; confirm this exact head and ignore earlier revisions.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f8f8dc3e00

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/code/README.md Outdated

The directory is created with owner-only permissions below
`~/.local/share/librechat/code/workspaces/<worker>/<workspace>`. It persists
across worker restarts so tools can create a project from scratch. The worker

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove the unsupported project-creation promise

When an operator follows this new workflow with an empty home, the registered workspace remains empty because LocalWorkspaceTools.capabilities in packages/code/src/workspace.ts only exposes read_file, search_text, and list_files; there is no operation that can create a directory or write a file. Consequently, bridge tools cannot create a project from scratch as documented here. Either add a write/create capability or state that the operator must seed the directory externally.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 38d0d50. The documentation now explicitly states that the current workspace surface is read-only and an empty default directory must be populated by a local process until write-capable coding tools are enabled.

Comment on lines +58 to +59
workspaceStorageName(workerId),
workspaceStorageName(workspaceId),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Namespace default workspaces by bridge identity

When the same host account re-pairs a worker ID for another tenant, this path remains identical because it includes only the public worker and workspace IDs. RedisBridgePairingStore.redeem creates a new stable identityId and tenant binding on every pairing, but the newly bound worker will advertise the previous identity's persisted files through read_file, search_text, and list_files; the same leak occurs when an ID is reused against another Code API deployment. Include the paired identity/deployment in the storage namespace, or explicitly clear the workspace when the security identity changes.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 38d0d50. Default paths now include a deployment/security-identity namespace derived from the normalized Code API URL plus the paired public key (or static credential), ahead of the worker/workspace digests. Credential refresh within one pairing remains stable; re-pairing or changing deployments produces an isolated path. Tests cover both identity and deployment changes.

@danny-avila
danny-avila force-pushed the danny-avila/code-default-workspace branch from f8f8dc3 to 47d4832 Compare September 3, 2026 00:29
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current PR head 47d4832. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads. Before this request I completed the cross-seam review of stable path identity, case-insensitive filesystems, input normalization, restart persistence, confinement, and both mixed-version registration directions.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 47d4832d2f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila
danny-avila force-pushed the danny-avila/code-default-workspace branch from 47d4832 to f30de0f Compare September 3, 2026 00:31
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current PR head f30de0f. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads. This is the case-safe, input-normalized default-workspace change restacked without conflict on #92 head 1dce623.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: f30de0f59d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila
danny-avila force-pushed the danny-avila/code-default-workspace branch from f30de0f to 38d0d50 Compare September 3, 2026 00:36
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current PR head 38d0d50. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads. The previous P1 is addressed by deployment/security-identity namespace isolation, and the docs now state the current read-only behavior accurately.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 38d0d50603

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila
danny-avila force-pushed the danny-avila/code-default-workspace branch from 38d0d50 to ad6130f Compare September 3, 2026 00:41
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current PR head ad6130f. Confirm that this exact commit is the reviewed commit and ignore findings that apply only to earlier heads. This is the same default-workspace feature and deployment/security-identity isolation fix, restacked onto #92 head d0383e8 after its canonical listing fix.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: ad6130f426

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila
danny-avila force-pushed the danny-avila/code-default-workspace branch 2 times, most recently from a8ab8e9 to a26f086 Compare September 3, 2026 00:55
Base automatically changed from danny-avila/code-workspace-list to main September 3, 2026 01:04
@danny-avila
danny-avila force-pushed the danny-avila/code-default-workspace branch from a26f086 to af1b6e5 Compare September 3, 2026 01:04
@danny-avila
danny-avila merged commit 578c8a1 into main Sep 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants