-
Notifications
You must be signed in to change notification settings - Fork 684
fix: derive default owner from workspaceDir instead of hardcoding agent:main #1374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,30 @@ | ||||||||
| import * as path from "path"; | ||||||||
|
|
||||||||
| /** | ||||||||
| * Derive the default owner from the workspace directory name. | ||||||||
| * | ||||||||
| * Convention: a workspace directory named "workspace-<agentName>" maps to | ||||||||
| * "agent:<agentName>". If the directory name does not follow that pattern | ||||||||
| * (or no workspaceDir is provided) the fallback is "agent:main". | ||||||||
| */ | ||||||||
| export function resolveDefaultOwner(workspaceDir?: string): string { | ||||||||
| if (workspaceDir) { | ||||||||
| const base = path.basename(workspaceDir); | ||||||||
| const match = base.match(/^workspace-(.+)$/); | ||||||||
| if (match) { | ||||||||
| return `agent:${match[1]}`; | ||||||||
| } | ||||||||
| } | ||||||||
| return "agent:main"; | ||||||||
| } | ||||||||
|
Comment on lines
+3
to
+19
|
||||||||
|
|
||||||||
| /** | ||||||||
| * Build the owner filter array used for queries. | ||||||||
| * | ||||||||
| * If the caller supplied an explicit `owner` value it takes precedence; | ||||||||
| * otherwise the `defaultOwner` (derived from workspace context) is used. | ||||||||
| */ | ||||||||
| export function resolveOwnerFilter(owner: unknown, defaultOwner: string = "agent:main"): string[] { | ||||||||
| const resolvedOwner = typeof owner === "string" && owner.trim().length > 0 ? owner : defaultOwner; | ||||||||
|
||||||||
| const resolvedOwner = typeof owner === "string" && owner.trim().length > 0 ? owner : defaultOwner; | |
| const trimmedOwner = typeof owner === "string" ? owner.trim() : ""; | |
| const resolvedOwner = trimmedOwner.length > 0 ? trimmedOwner : defaultOwner; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolveDefaultOwnerreturnsagent:${match[1]}directly from the directory name capture. If the workspace directory name has leading/trailing whitespace (or other unexpected characters), this can create an owner value that will never match DB rows. Consider trimming/sanitizing the captured agent name (and optionally constraining it to an allowed character set) before building the owner string.