kankaku 1.4.2 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kankaku",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Terminal app that shows today's kankaku work across every project on disk",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"ink": "^7.1.1",
|
|
41
|
-
"kankaku-claude": "^1.
|
|
41
|
+
"kankaku-claude": "^1.5.1",
|
|
42
42
|
"kankaku-hub": "^0.5.1",
|
|
43
|
-
"kankaku-pi": "^1.
|
|
43
|
+
"kankaku-pi": "^1.5.1",
|
|
44
44
|
"react": "^19.3.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
@@ -35,6 +35,10 @@ const SUBAGENT_NOTE = "Subagent session: the billing target is inherited from th
|
|
|
35
35
|
const USE_DEFAULTS_VALUE = "__kankaku_use_defaults__";
|
|
36
36
|
const NO_PROJECT_VALUE = "__kankaku_no_project__";
|
|
37
37
|
const NO_TASK_VALUE = "__kankaku_no_task__";
|
|
38
|
+
const CREATE_TASK_VALUE = "__kankaku_create_task__";
|
|
39
|
+
/** Same wording as the `/kankaku target pick` picker's own option (`adapters/target-picker.ts`). */
|
|
40
|
+
const CREATE_TASK_LABEL = "+ create task +";
|
|
41
|
+
const NO_OPEN_TASKS_NOTE = "No open tasks for this project in the hub";
|
|
38
42
|
const MAX_VISIBLE = 10;
|
|
39
43
|
|
|
40
44
|
/** `WorkTargetSourceName` ("session" | "project" | "repoPaths"), formatted for the read-only `source` row ("session" | "config" | "repoPaths"). */
|
|
@@ -164,6 +168,103 @@ class LegacyLabelComponent implements Component {
|
|
|
164
168
|
}
|
|
165
169
|
}
|
|
166
170
|
|
|
171
|
+
/**
|
|
172
|
+
* The task submenu: the project's open tasks, `+ create task +` and
|
|
173
|
+
* `— none —`. Choosing `+ create task +` swaps the list for a title
|
|
174
|
+
* `Input` in place; Escape there returns to the list, and a submitted
|
|
175
|
+
* title is handed to `onCreate`. Like the legacy-label field, the title
|
|
176
|
+
* field needs `PanelHost.setBodyWantsText` so `q` types instead of closing
|
|
177
|
+
* the panel; it is cleared on every path out of the field.
|
|
178
|
+
*/
|
|
179
|
+
class TaskSubmenuComponent implements Component {
|
|
180
|
+
private readonly theme: SettingsListTheme;
|
|
181
|
+
private readonly host: PanelHost;
|
|
182
|
+
private readonly list: SelectList;
|
|
183
|
+
private readonly showEmptyNote: boolean;
|
|
184
|
+
private readonly onCreate: (title: string) => Promise<void>;
|
|
185
|
+
private input: Input | undefined;
|
|
186
|
+
private titleError: string | undefined;
|
|
187
|
+
private creating = false;
|
|
188
|
+
|
|
189
|
+
constructor(
|
|
190
|
+
theme: SettingsListTheme,
|
|
191
|
+
host: PanelHost,
|
|
192
|
+
options: Array<{ label: string; task: HubTask }>,
|
|
193
|
+
handlers: { onPick: (taskId: string) => void; onClear: () => void; onCreate: (title: string) => Promise<void>; onCancel: () => void },
|
|
194
|
+
) {
|
|
195
|
+
this.theme = theme;
|
|
196
|
+
this.host = host;
|
|
197
|
+
this.showEmptyNote = options.length === 0;
|
|
198
|
+
this.onCreate = handlers.onCreate;
|
|
199
|
+
const items: SelectItem[] = [
|
|
200
|
+
...options.map((option) => ({ value: option.task.id, label: option.label })),
|
|
201
|
+
{ value: CREATE_TASK_VALUE, label: CREATE_TASK_LABEL },
|
|
202
|
+
{ value: NO_TASK_VALUE, label: "— none —" },
|
|
203
|
+
];
|
|
204
|
+
this.list = new SelectList(items, MAX_VISIBLE, buildSelectListTheme(host.theme));
|
|
205
|
+
this.list.onSelect = (item) => {
|
|
206
|
+
if (item.value === CREATE_TASK_VALUE) this.openTitleField();
|
|
207
|
+
else if (item.value === NO_TASK_VALUE) handlers.onClear();
|
|
208
|
+
else handlers.onPick(item.value);
|
|
209
|
+
};
|
|
210
|
+
this.list.onCancel = () => handlers.onCancel();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
private openTitleField(): void {
|
|
214
|
+
const input = new Input();
|
|
215
|
+
input.onSubmit = (value) => this.submitTitle(value);
|
|
216
|
+
input.onEscape = () => this.closeTitleField();
|
|
217
|
+
this.input = input;
|
|
218
|
+
this.titleError = undefined;
|
|
219
|
+
this.host.setBodyWantsText(true);
|
|
220
|
+
this.host.requestRender();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
private closeTitleField(): void {
|
|
224
|
+
this.input = undefined;
|
|
225
|
+
this.titleError = undefined;
|
|
226
|
+
this.host.setBodyWantsText(false);
|
|
227
|
+
this.host.requestRender();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
private submitTitle(rawValue: string): void {
|
|
231
|
+
const title = rawValue.trim();
|
|
232
|
+
if (title.length === 0) {
|
|
233
|
+
this.titleError = "the title is required";
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
this.creating = true;
|
|
237
|
+
this.host.setBodyWantsText(false);
|
|
238
|
+
this.host.requestRender();
|
|
239
|
+
void this.onCreate(title);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
invalidate(): void {
|
|
243
|
+
this.list.invalidate();
|
|
244
|
+
this.input?.invalidate();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
render(width: number): string[] {
|
|
248
|
+
if (this.creating) return [this.theme.hint("Creating task…")];
|
|
249
|
+
if (this.input) {
|
|
250
|
+
const lines = [this.theme.hint("New task title (Enter to create, Esc to go back)"), ...this.input.render(width)];
|
|
251
|
+
return this.titleError === undefined ? lines : [...lines, this.theme.hint(`error: ${this.titleError}`)];
|
|
252
|
+
}
|
|
253
|
+
const lines = this.list.render(width);
|
|
254
|
+
return this.showEmptyNote ? [this.theme.hint(NO_OPEN_TASKS_NOTE), ...lines] : lines;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
handleInput(data: string): void {
|
|
258
|
+
if (this.creating) return;
|
|
259
|
+
if (this.input) {
|
|
260
|
+
this.titleError = undefined;
|
|
261
|
+
this.input.handleInput(data);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
this.list.handleInput(data);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
167
268
|
class TargetScreenComponent implements Component {
|
|
168
269
|
readonly searchable = false;
|
|
169
270
|
private readonly deps: TargetScreenDeps;
|
|
@@ -306,24 +407,34 @@ class TargetScreenComponent implements Component {
|
|
|
306
407
|
}
|
|
307
408
|
|
|
308
409
|
const tasks = (this.deps.catalog?.read()?.tasks ?? []).filter((task) => task.status !== "done" && task.projectId === target.projectId);
|
|
309
|
-
|
|
310
|
-
return new NoteComponent(this.settingsTheme, "No open tasks for this project in the hub", done);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const options = labelTasks(tasks);
|
|
314
|
-
const items: SelectItem[] = [...options.map((option) => ({ value: option.task.id, label: option.label })), { value: NO_TASK_VALUE, label: "— none —" }];
|
|
315
|
-
const list = new SelectList(items, MAX_VISIBLE, buildSelectListTheme(this.host.theme));
|
|
316
|
-
list.onSelect = (item) => {
|
|
317
|
-
if (item.value === NO_TASK_VALUE) {
|
|
318
|
-
this.deps.sessionTarget?.clearTask(this.deps.pi);
|
|
319
|
-
} else {
|
|
320
|
-
this.deps.sessionTarget?.setTask(this.deps.pi, item.value);
|
|
321
|
-
}
|
|
410
|
+
const finish = (): void => {
|
|
322
411
|
done();
|
|
323
412
|
this.applyChange("task");
|
|
324
413
|
};
|
|
325
|
-
|
|
326
|
-
|
|
414
|
+
return new TaskSubmenuComponent(this.settingsTheme, this.host, labelTasks(tasks), {
|
|
415
|
+
onPick: (taskId) => {
|
|
416
|
+
this.deps.sessionTarget?.setTask(this.deps.pi, taskId);
|
|
417
|
+
finish();
|
|
418
|
+
},
|
|
419
|
+
onClear: () => {
|
|
420
|
+
this.deps.sessionTarget?.clearTask(this.deps.pi);
|
|
421
|
+
finish();
|
|
422
|
+
},
|
|
423
|
+
// `SessionTarget.newTask` creates, caches and links the task and
|
|
424
|
+
// reports the outcome (success or failure) through `ctx.ui.notify`,
|
|
425
|
+
// exactly as `/kankaku task new <title>` does; the row is rebuilt
|
|
426
|
+
// from the resulting state either way.
|
|
427
|
+
onCreate: async (title) => {
|
|
428
|
+
try {
|
|
429
|
+
await this.deps.sessionTarget?.newTask(this.deps.pi, this.deps.ctx, title);
|
|
430
|
+
} catch (error) {
|
|
431
|
+
// `newTask` reports hub failures itself; only a missing task creator reaches here.
|
|
432
|
+
if (this.deps.ctx.hasUI) this.deps.ctx.ui.notify(`kankaku: ${error instanceof Error ? error.message : String(error)}`, "error");
|
|
433
|
+
}
|
|
434
|
+
finish();
|
|
435
|
+
},
|
|
436
|
+
onCancel: () => done(),
|
|
437
|
+
});
|
|
327
438
|
}
|
|
328
439
|
|
|
329
440
|
private buildRememberItem(row: PanelRow): SettingItem {
|