MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / defaultTagFor

Function defaultTagFor

ui/src/hooks/useCreateWorkspace.ts:12–23  ·  view source on GitHub ↗
(template: string, workspaces: readonly Workspace[])

Source from the content-addressed store, hash-verified

10 * Truncates the template part so the result always fits TAG_RE's 33 chars.
11 */
12export function defaultTagFor(template: string, workspaces: readonly Workspace[]): string {
13 const now = new Date()
14 const month = now.toLocaleString('en-US', { month: 'short' }).toLowerCase()
15 const date = `${month}${now.getDate()}`
16 const head = template.slice(0, 33 - date.length - 4) // room for "-" + date + "-NN"
17 const base = `${head}-${date}`
18 const taken = new Set(workspaces.map((w) => w.tag))
19 if (!taken.has(base)) return base
20 let i = 2
21 while (taken.has(`${base}-${i}`)) i++
22 return `${base}-${i}`
23}
24
25interface UseCreateWorkspaceOpts {
26 /** Workspace template to create from. Empty string = not yet selected. */

Callers 1

CreateWorkspaceFormFunction · 0.90

Calls 1

hasMethod · 0.65

Tested by

no test coverage detected