Skip to content

Commit 2baef04

Browse files
committed
refactor(appkit): trim ui-variants choice-sink to minimal helper adoption
Route the ui-variants choices JSONL path through getEphemeralStateDir() without the incidental churn: keep the single UI_CHOICES_FILE constant and the original constructor signature, and restore the main docstrings (with only the accuracy fix the now-absolute path requires). Co-authored-by: Isaac Signed-off-by: Atila Fassina <atila@fassina.eu>
1 parent 8682403 commit 2baef04

1 file changed

Lines changed: 16 additions & 24 deletions

File tree

packages/appkit/src/plugins/ui-variants/choice-sink.ts

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,22 @@ import path from "node:path";
33
import { getEphemeralStateDir } from "shared/cli/commands/cache-paths";
44

55
/**
6-
* Filename of the JSONL choices file. The agent skill discovers this file at
7-
* the ephemeral state directory (under node_modules/).
8-
*/
9-
const UI_CHOICES_FILENAME = ".appkit-ui-choices.jsonl";
10-
11-
/**
12-
* Default absolute path to the JSONL choices file: ephemeral state dir
13-
* (node_modules/.databricks/appkit/) + the contract filename. Kept
14-
* ephemeral & gitignored; NOT part of the committed .appkit/ relocation.
15-
*
6+
* Absolute path of the JSONL choices file, under `node_modules/`.
167
* A coding agent reads it to pick up the developer's in-browser confirmation
17-
* and finalize the chosen variant. Each line is spent on read — the agent
18-
* removes it once the choice is finalized.
8+
* and finalize the chosen variant.
9+
*
10+
* Under `node_modules/`, so it's gitignored and cleared on a clean install.
11+
* Each line is spent on read — the agent removes it once the choice is
12+
* finalized.
1913
*
2014
* CONTRACT: the `databricks-app-variants` agent skill (in the
21-
* databricks-agent-skills repo) discovers the choices file at this absolute
22-
* path. Changing this value silently breaks that skill's file discovery —
23-
* update the skill's `find` path in the same change.
15+
* databricks-agent-skills repo) discovers the choices file at this path.
16+
* Changing this value silently breaks that skill's file discovery — update the
17+
* skill's `find` path in the same change.
2418
*/
25-
const DEFAULT_UI_CHOICES_PATH = path.join(
19+
const UI_CHOICES_FILE = path.join(
2620
getEphemeralStateDir(),
27-
UI_CHOICES_FILENAME,
21+
".appkit-ui-choices.jsonl",
2822
);
2923

3024
/**
@@ -51,16 +45,14 @@ export interface UiChoiceRecord {
5145

5246
/**
5347
* File store for confirmed variant choices: upserts choices into
54-
* {@link DEFAULT_UI_CHOICES_PATH}, one line per `<Variants>` id.
48+
* {@link UI_CHOICES_FILE}, one line per `<Variants>` id.
5549
*
5650
* The store is **keyed and latest-wins**: at most one record per `blockId`, and
5751
* recording an existing `blockId` replaces it rather than appending, so the file
5852
* always reflects the current choice for each block.
5953
*
60-
* By default, the file lands at the ephemeral state directory under
61-
* `node_modules/.databricks/appkit/`. Callers may override the path (e.g., for
62-
* testing), in which case it is resolved against `process.cwd()`; absolute
63-
* paths are passed through unchanged. Concurrent confirms are serialized behind
54+
* The file is resolved against `process.cwd()`, so it lands under whatever
55+
* directory the dev server runs from. Concurrent confirms are serialized behind
6456
* an internal queue so their read-modify-write can't interleave and lose an
6557
* update.
6658
*
@@ -70,8 +62,8 @@ export class FileChoiceStore {
7062
private readonly filePath: string;
7163
private writeQueue: Promise<void> = Promise.resolve();
7264

73-
constructor(pathArg: string = DEFAULT_UI_CHOICES_PATH) {
74-
this.filePath = path.resolve(process.cwd(), pathArg);
65+
constructor(relativePath: string = UI_CHOICES_FILE) {
66+
this.filePath = path.resolve(process.cwd(), relativePath);
7567
}
7668

7769
record(record: UiChoiceRecord): Promise<void> {

0 commit comments

Comments
 (0)