@saadnvd1/agent-os 0.3.839 → 0.3.845
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/app/api/health/route.ts +4 -2
- package/components/SessionList/GroupShelves.tsx +8 -3
- package/components/SessionList/OrchestratorPinRow.tsx +2 -2
- package/components/SessionList/RowParts.tsx +39 -35
- package/components/SessionList/RowRename.test.ts +86 -17
- package/components/SessionList/RowShell.tsx +2 -5
- package/components/SessionList/SessionRow.tsx +0 -1
- package/components/Settings/SettingRow.tsx +82 -45
- package/components/Settings/settings-fields.tsx +11 -10
- package/components/Workspaces/HqFolderForm.tsx +21 -19
- package/components/Workspaces/McpServersForm.tsx +20 -28
- package/components/Workspaces/ProjectTiersForm.tsx +25 -12
- package/components/Workspaces/RuleEditor.tsx +86 -0
- package/components/Workspaces/RulesForm.test.ts +58 -31
- package/components/Workspaces/RulesForm.tsx +129 -58
- package/components/Workspaces/WorkspaceModeForm.tsx +3 -3
- package/components/Workspaces/WorkspaceModelsForm.tsx +40 -41
- package/components/Workspaces/WorkspacePanel.tsx +73 -0
- package/components/Workspaces/WorkspacePicker.tsx +44 -0
- package/components/Workspaces/WorkspaceSettings.test.ts +153 -0
- package/components/Workspaces/WorkspaceSettings.tsx +51 -77
- package/components/Workspaces/useSettingsWorkspace.ts +47 -0
- package/content/whats-new.json +24 -0
- package/lib/away/deploy.ts +34 -7
- package/lib/models/plan-fresh.ts +61 -0
- package/lib/models/plan-step.ts +40 -24
- package/lib/orchestrator/scope.ts +10 -0
- package/lib/updates/banner.ts +2 -0
- package/lib/updates/run.ts +9 -0
- package/lib/updates/view.ts +28 -6
- package/lib/worktree-deps/paths.ts +9 -4
- package/lib/worktrees.ts +3 -0
- package/package.json +1 -1
- package/scripts/autodeploy +11 -0
- package/scripts/autodeploy.test.ts +30 -0
- package/scripts/lib/update-verify.mjs +11 -0
- package/scripts/update-run.mjs +29 -0
- package/scripts/update-run.test.ts +62 -4
package/app/api/health/route.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { NextResponse } from "next/server";
|
|
2
|
+
import { buildId } from "@/lib/build";
|
|
2
3
|
|
|
3
4
|
const startedAt = new Date(Date.now() - process.uptime() * 1000).toISOString();
|
|
4
5
|
|
|
5
6
|
// GET /api/health - the server is up and answering; when it started, so a
|
|
6
|
-
// deploy check can tell it restarted after a merge
|
|
7
|
+
// deploy check can tell it restarted after a merge, and the build it runs, so
|
|
8
|
+
// a merge is only "deployed" when that build contains it (lib/away/deploy.ts).
|
|
7
9
|
export function GET() {
|
|
8
|
-
return NextResponse.json({ ok: true, startedAt });
|
|
10
|
+
return NextResponse.json({ ok: true, startedAt, build: buildId() });
|
|
9
11
|
}
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
DropdownMenuTrigger,
|
|
18
18
|
} from "@/components/ui/dropdown-menu";
|
|
19
19
|
import { cn } from "@/lib/utils";
|
|
20
|
+
import { keepRenameFocus, useRenameInput } from "./RowParts";
|
|
20
21
|
import { SessionRow } from "./SessionRow";
|
|
21
22
|
import { useDropZone } from "./useGroupDrag";
|
|
22
23
|
|
|
@@ -48,18 +49,18 @@ function GroupHeader({
|
|
|
48
49
|
update.mutate({ id: group.id, name: next });
|
|
49
50
|
else setName(group.name);
|
|
50
51
|
};
|
|
52
|
+
const renameInput = useRenameInput(() => commit());
|
|
51
53
|
|
|
52
54
|
if (renaming)
|
|
53
55
|
return (
|
|
54
56
|
<div className="px-2.5 pt-3.5 pb-1.5">
|
|
55
57
|
<Input
|
|
56
|
-
|
|
58
|
+
{...renameInput}
|
|
57
59
|
value={name}
|
|
58
60
|
maxLength={60}
|
|
59
61
|
aria-label="Group name"
|
|
60
62
|
className="h-11 md:h-8"
|
|
61
63
|
onChange={(e) => setName(e.target.value)}
|
|
62
|
-
onBlur={commit}
|
|
63
64
|
onKeyDown={(e) => {
|
|
64
65
|
if (e.key === "Enter") commit();
|
|
65
66
|
if (e.key === "Escape") {
|
|
@@ -112,7 +113,11 @@ function GroupHeader({
|
|
|
112
113
|
<MoreHorizontal className="h-4 w-4" />
|
|
113
114
|
</button>
|
|
114
115
|
</DropdownMenuTrigger>
|
|
115
|
-
<DropdownMenuContent
|
|
116
|
+
<DropdownMenuContent
|
|
117
|
+
align="end"
|
|
118
|
+
className="w-44"
|
|
119
|
+
onCloseAutoFocus={keepRenameFocus}
|
|
120
|
+
>
|
|
116
121
|
<DropdownMenuItem
|
|
117
122
|
className="min-h-11 md:min-h-8"
|
|
118
123
|
onSelect={() => setRenaming(true)}
|
|
@@ -160,7 +160,7 @@ export const OrchestratorPinRow = memo(function OrchestratorPinRow({
|
|
|
160
160
|
<DM.DropdownMenuContent
|
|
161
161
|
align="end"
|
|
162
162
|
className={ROW_MENU_CONTENT}
|
|
163
|
-
onCloseAutoFocus={keepRenameFocus
|
|
163
|
+
onCloseAutoFocus={keepRenameFocus}
|
|
164
164
|
onClick={(e) => e.stopPropagation()}
|
|
165
165
|
>
|
|
166
166
|
{menu("dropdown")}
|
|
@@ -175,7 +175,7 @@ export const OrchestratorPinRow = memo(function OrchestratorPinRow({
|
|
|
175
175
|
<CM.ContextMenuTrigger asChild>{content}</CM.ContextMenuTrigger>
|
|
176
176
|
<CM.ContextMenuContent
|
|
177
177
|
className={ROW_MENU_CONTENT}
|
|
178
|
-
onCloseAutoFocus={keepRenameFocus
|
|
178
|
+
onCloseAutoFocus={keepRenameFocus}
|
|
179
179
|
>
|
|
180
180
|
{menu("context")}
|
|
181
181
|
</CM.ContextMenuContent>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { Lightbulb } from "lucide-react";
|
|
4
|
-
import {
|
|
4
|
+
import { useCallback, useRef, useState, type ReactNode } from "react";
|
|
5
5
|
import type { SidebarRow } from "@/lib/sidebar/shelves";
|
|
6
6
|
import { cn } from "@/lib/utils";
|
|
7
7
|
|
|
@@ -61,12 +61,44 @@ export function CardBadge({ count }: { count: number }) {
|
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
const RENAME_INPUT = "input[data-rename-input]";
|
|
65
|
+
|
|
66
|
+
function focusRename(el: HTMLInputElement) {
|
|
67
|
+
el.focus();
|
|
68
|
+
el.select();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// For a menu's onCloseAutoFocus: while a rename input is open it takes the
|
|
72
|
+
// focus the menu would hand back to its trigger. Reads the DOM, not state, so
|
|
73
|
+
// it can't see a render that hasn't landed yet.
|
|
74
|
+
export const keepRenameFocus = (e: Event) => {
|
|
75
|
+
const el = document.querySelector<HTMLInputElement>(RENAME_INPUT);
|
|
76
|
+
if (!el) return;
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
focusRename(el);
|
|
68
79
|
};
|
|
69
80
|
|
|
81
|
+
// Props for a rename input that was opened from a menu. While the menu is
|
|
82
|
+
// still on screen it traps focus, so the input waits for keepRenameFocus; a
|
|
83
|
+
// blur before the input has held focus once is never a commit.
|
|
84
|
+
export function useRenameInput(onDone: () => void) {
|
|
85
|
+
const hadFocus = useRef(false);
|
|
86
|
+
const ref = useCallback((el: HTMLInputElement | null) => {
|
|
87
|
+
hadFocus.current = false;
|
|
88
|
+
if (el && !document.querySelector('[role="menu"]')) focusRename(el);
|
|
89
|
+
}, []);
|
|
90
|
+
return {
|
|
91
|
+
ref,
|
|
92
|
+
"data-rename-input": "",
|
|
93
|
+
onFocus: () => {
|
|
94
|
+
hadFocus.current = true;
|
|
95
|
+
},
|
|
96
|
+
onBlur: () => {
|
|
97
|
+
if (hadFocus.current) onDone();
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
70
102
|
export function RowRename({
|
|
71
103
|
initial,
|
|
72
104
|
onDone,
|
|
@@ -75,41 +107,13 @@ export function RowRename({
|
|
|
75
107
|
onDone: (name: string | null) => void;
|
|
76
108
|
}) {
|
|
77
109
|
const [value, setValue] = useState(initial);
|
|
78
|
-
const
|
|
79
|
-
const hadFocus = useRef(false);
|
|
80
|
-
// The menu closing hands focus back to its trigger (RowShell stops that
|
|
81
|
-
// while renaming); keep taking it until we hold it, then leave it alone.
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
const take = () => {
|
|
84
|
-
const el = ref.current;
|
|
85
|
-
if (!el || hadFocus.current) return;
|
|
86
|
-
el.focus();
|
|
87
|
-
if (document.activeElement === el) {
|
|
88
|
-
hadFocus.current = true;
|
|
89
|
-
el.select();
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
take();
|
|
93
|
-
const t = setInterval(take, 50);
|
|
94
|
-
const stop = setTimeout(() => clearInterval(t), 1000);
|
|
95
|
-
return () => {
|
|
96
|
-
clearInterval(t);
|
|
97
|
-
clearTimeout(stop);
|
|
98
|
-
};
|
|
99
|
-
}, []);
|
|
110
|
+
const input = useRenameInput(() => onDone(value.trim() || null));
|
|
100
111
|
return (
|
|
101
112
|
<input
|
|
102
|
-
|
|
113
|
+
{...input}
|
|
103
114
|
value={value}
|
|
104
115
|
aria-label="Session name"
|
|
105
116
|
onChange={(e) => setValue(e.target.value)}
|
|
106
|
-
onFocus={() => {
|
|
107
|
-
hadFocus.current = true;
|
|
108
|
-
}}
|
|
109
|
-
onBlur={() => {
|
|
110
|
-
// Only once we've held focus: the menu closing hands it to its trigger.
|
|
111
|
-
if (hadFocus.current) onDone(value.trim() || null);
|
|
112
|
-
}}
|
|
113
117
|
onKeyDown={(e) => {
|
|
114
118
|
e.stopPropagation();
|
|
115
119
|
if (e.key === "Enter") onDone(value.trim() || null);
|
|
@@ -2,12 +2,16 @@ import "@/components/Chat/composer/test-dom";
|
|
|
2
2
|
import { act, createElement, useState } from "react";
|
|
3
3
|
import { createRoot, type Root } from "react-dom/client";
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
-
import
|
|
5
|
+
import * as DM from "@/components/ui/dropdown-menu";
|
|
6
|
+
import { keepRenameFocus, RowRename, useRenameInput } from "./RowParts";
|
|
6
7
|
|
|
7
8
|
(
|
|
8
9
|
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
|
|
9
10
|
).IS_REACT_ACT_ENVIRONMENT = true;
|
|
10
11
|
|
|
12
|
+
// Radix dispatches CustomEvents; node's own class is rejected by jsdom.
|
|
13
|
+
(globalThis as { CustomEvent?: unknown }).CustomEvent = window.CustomEvent;
|
|
14
|
+
|
|
11
15
|
let root: Root;
|
|
12
16
|
let host: HTMLElement;
|
|
13
17
|
const input = () => host.querySelector("input")!;
|
|
@@ -28,23 +32,87 @@ function mount(onDone: (n: string | null) => void, initial = "old") {
|
|
|
28
32
|
act(() => root.render(createElement(RowRename, { initial, onDone })));
|
|
29
33
|
}
|
|
30
34
|
|
|
35
|
+
// A row whose menu has a Rename item, wired like RowShell / GroupShelves.
|
|
36
|
+
function Row({ group = false }: { group?: boolean }) {
|
|
37
|
+
const [renaming, setRenaming] = useState(false);
|
|
38
|
+
const [name, setName] = useState("old");
|
|
39
|
+
const rename = useRenameInput(() => setRenaming(false));
|
|
40
|
+
const menu = createElement(
|
|
41
|
+
DM.DropdownMenu,
|
|
42
|
+
{ defaultOpen: true },
|
|
43
|
+
createElement(
|
|
44
|
+
DM.DropdownMenuTrigger,
|
|
45
|
+
{ asChild: true },
|
|
46
|
+
createElement("button", { "aria-label": "menu" })
|
|
47
|
+
),
|
|
48
|
+
createElement(
|
|
49
|
+
DM.DropdownMenuContent,
|
|
50
|
+
{ onCloseAutoFocus: keepRenameFocus },
|
|
51
|
+
createElement(
|
|
52
|
+
DM.DropdownMenuItem,
|
|
53
|
+
{ onSelect: () => setRenaming(true) },
|
|
54
|
+
"Rename"
|
|
55
|
+
)
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
return createElement(
|
|
59
|
+
"div",
|
|
60
|
+
null,
|
|
61
|
+
menu,
|
|
62
|
+
renaming
|
|
63
|
+
? group
|
|
64
|
+
? createElement("input", {
|
|
65
|
+
...rename,
|
|
66
|
+
value: name,
|
|
67
|
+
onChange: (e: { target: { value: string } }) =>
|
|
68
|
+
setName(e.target.value),
|
|
69
|
+
})
|
|
70
|
+
: createElement(RowRename, {
|
|
71
|
+
initial: name,
|
|
72
|
+
onDone: () => setRenaming(false),
|
|
73
|
+
})
|
|
74
|
+
: null
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
describe.each([
|
|
79
|
+
["session row", false],
|
|
80
|
+
["group header", true],
|
|
81
|
+
])("rename from the menu on a fresh mount (%s)", (_n, group) => {
|
|
82
|
+
it("keeps the input open, focused, and accepting typing", async () => {
|
|
83
|
+
vi.useRealTimers();
|
|
84
|
+
act(() => root.render(createElement(Row, { group })));
|
|
85
|
+
const item = [...document.querySelectorAll('[role="menuitem"]')].find(
|
|
86
|
+
(el) => el.textContent === "Rename"
|
|
87
|
+
) as HTMLElement;
|
|
88
|
+
expect(item).toBeTruthy();
|
|
89
|
+
await act(async () => {
|
|
90
|
+
item.click();
|
|
91
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
92
|
+
});
|
|
93
|
+
const el = input();
|
|
94
|
+
expect(el).toBeTruthy();
|
|
95
|
+
expect(document.activeElement).toBe(el);
|
|
96
|
+
const set = Object.getOwnPropertyDescriptor(
|
|
97
|
+
window.HTMLInputElement.prototype,
|
|
98
|
+
"value"
|
|
99
|
+
)!.set!;
|
|
100
|
+
act(() => {
|
|
101
|
+
set.call(el, "typed");
|
|
102
|
+
el.dispatchEvent(new window.Event("input", { bubbles: true }));
|
|
103
|
+
});
|
|
104
|
+
expect(input()).toBe(el);
|
|
105
|
+
expect(input().value).toBe("typed");
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
31
109
|
describe("RowRename", () => {
|
|
32
|
-
it("
|
|
33
|
-
const real = window.HTMLElement.prototype.focus;
|
|
34
|
-
let calls = 0;
|
|
35
|
-
// The first focus attempts land while the menu still traps focus.
|
|
36
|
-
vi.spyOn(window.HTMLElement.prototype, "focus").mockImplementation(
|
|
37
|
-
function (this: HTMLElement) {
|
|
38
|
-
if (++calls > 2) real.call(this);
|
|
39
|
-
}
|
|
40
|
-
);
|
|
110
|
+
it("ignores a blur that comes before it was ever focused", () => {
|
|
41
111
|
const done = vi.fn();
|
|
42
112
|
mount(done);
|
|
113
|
+
// an open menu keeps the input from taking focus on mount
|
|
43
114
|
act(() => input().dispatchEvent(new window.FocusEvent("blur")));
|
|
44
115
|
expect(done).not.toHaveBeenCalled();
|
|
45
|
-
act(() => vi.advanceTimersByTime(150));
|
|
46
|
-
expect(document.activeElement).toBe(input());
|
|
47
|
-
vi.restoreAllMocks();
|
|
48
116
|
});
|
|
49
117
|
|
|
50
118
|
it("keeps typed text across a parent re-render (list refresh)", () => {
|
|
@@ -75,7 +143,6 @@ describe("RowRename", () => {
|
|
|
75
143
|
it("saves on Enter, cancels on Escape, saves on blur once focused", () => {
|
|
76
144
|
const done = vi.fn();
|
|
77
145
|
mount(done);
|
|
78
|
-
act(() => vi.advanceTimersByTime(60));
|
|
79
146
|
const key = (k: string) =>
|
|
80
147
|
act(() => {
|
|
81
148
|
input().dispatchEvent(
|
|
@@ -92,11 +159,13 @@ describe("RowRename", () => {
|
|
|
92
159
|
});
|
|
93
160
|
|
|
94
161
|
describe("keepRenameFocus", () => {
|
|
95
|
-
it("
|
|
162
|
+
it("takes the focus the menu would return, only while a rename input is open", () => {
|
|
96
163
|
const e = { preventDefault: vi.fn() } as unknown as Event;
|
|
97
|
-
keepRenameFocus(
|
|
164
|
+
keepRenameFocus(e);
|
|
98
165
|
expect(e.preventDefault).not.toHaveBeenCalled();
|
|
99
|
-
|
|
166
|
+
mount(() => {});
|
|
167
|
+
keepRenameFocus(e);
|
|
100
168
|
expect(e.preventDefault).toHaveBeenCalled();
|
|
169
|
+
expect(document.activeElement).toBe(input());
|
|
101
170
|
});
|
|
102
171
|
});
|
|
@@ -42,7 +42,6 @@ export function RowShell({
|
|
|
42
42
|
menu,
|
|
43
43
|
menuLabel,
|
|
44
44
|
menuButton = true,
|
|
45
|
-
renaming = false,
|
|
46
45
|
}: {
|
|
47
46
|
title: string;
|
|
48
47
|
tipKey?: string;
|
|
@@ -62,8 +61,6 @@ export function RowShell({
|
|
|
62
61
|
menuLabel: string;
|
|
63
62
|
// False keeps the right-click menu but hides the ⋯ (while selecting).
|
|
64
63
|
menuButton?: boolean;
|
|
65
|
-
// A rename input is open: closing the menu mustn't move focus off it.
|
|
66
|
-
renaming?: boolean;
|
|
67
64
|
}) {
|
|
68
65
|
const content = (
|
|
69
66
|
<div
|
|
@@ -118,7 +115,7 @@ export function RowShell({
|
|
|
118
115
|
<DM.DropdownMenuContent
|
|
119
116
|
align="end"
|
|
120
117
|
className={ROW_MENU_CONTENT}
|
|
121
|
-
onCloseAutoFocus={keepRenameFocus
|
|
118
|
+
onCloseAutoFocus={keepRenameFocus}
|
|
122
119
|
onClick={(e) => e.stopPropagation()}
|
|
123
120
|
>
|
|
124
121
|
{menu("dropdown")}
|
|
@@ -133,7 +130,7 @@ export function RowShell({
|
|
|
133
130
|
<CM.ContextMenuTrigger asChild>{content}</CM.ContextMenuTrigger>
|
|
134
131
|
<CM.ContextMenuContent
|
|
135
132
|
className={ROW_MENU_CONTENT}
|
|
136
|
-
onCloseAutoFocus={keepRenameFocus
|
|
133
|
+
onCloseAutoFocus={keepRenameFocus}
|
|
137
134
|
>
|
|
138
135
|
{menu("context")}
|
|
139
136
|
</CM.ContextMenuContent>
|
|
@@ -8,6 +8,14 @@ import { cn } from "@/lib/utils";
|
|
|
8
8
|
// What the Settings search box holds; a row that doesn't match hides.
|
|
9
9
|
export const SettingsQueryContext = createContext("");
|
|
10
10
|
|
|
11
|
+
/** Whether a row with this text shows for the search box's words. */
|
|
12
|
+
export function matchesQuery(query: string, ...text: (string | undefined)[]) {
|
|
13
|
+
const q = query.trim().toLowerCase();
|
|
14
|
+
if (!q) return true;
|
|
15
|
+
const haystack = text.join(" ").toLowerCase();
|
|
16
|
+
return q.split(/\s+/).every((w) => haystack.includes(w));
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
/**
|
|
12
20
|
* One setting on a Settings page, 44px at least: label and one-line help on
|
|
13
21
|
* the left, the control on the right (below the label on a phone), and a meta
|
|
@@ -40,10 +48,8 @@ export function SettingRow({
|
|
|
40
48
|
onReset?: () => void;
|
|
41
49
|
below?: ReactNode;
|
|
42
50
|
}) {
|
|
43
|
-
const query = useContext(SettingsQueryContext)
|
|
44
|
-
|
|
45
|
-
if (query && !query.split(/\s+/).every((w) => haystack.includes(w)))
|
|
46
|
-
return null;
|
|
51
|
+
const query = useContext(SettingsQueryContext);
|
|
52
|
+
if (!matchesQuery(query, label, help)) return null;
|
|
47
53
|
return (
|
|
48
54
|
<div
|
|
49
55
|
data-setting={id}
|
|
@@ -65,47 +71,49 @@ export function SettingRow({
|
|
|
65
71
|
>
|
|
66
72
|
{control}
|
|
67
73
|
</div>
|
|
68
|
-
|
|
69
|
-
<span
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
74
|
+
{(error || hint || onReset || status !== "idle") && (
|
|
75
|
+
<div className="text-muted-foreground col-span-2 flex min-h-5 items-center justify-end gap-3 text-xs">
|
|
76
|
+
<span
|
|
77
|
+
id={`${id}-hint`}
|
|
78
|
+
className={cn("min-w-0 flex-1", error && "text-destructive")}
|
|
79
|
+
role={error ? "alert" : undefined}
|
|
80
|
+
>
|
|
81
|
+
{error ?? hint}
|
|
82
|
+
</span>
|
|
83
|
+
<span className="flex shrink-0 items-center gap-3" aria-live="polite">
|
|
84
|
+
{status === "saving" && (
|
|
85
|
+
<span className="inline-flex items-center gap-1">
|
|
86
|
+
<Loader2 className="size-3 animate-spin" />
|
|
87
|
+
Saving…
|
|
88
|
+
</span>
|
|
89
|
+
)}
|
|
90
|
+
{(status === "saved" || status === "undo") && (
|
|
91
|
+
<span className="inline-flex items-center gap-1 text-emerald-600 dark:text-emerald-400">
|
|
92
|
+
<Check className="size-3" />
|
|
93
|
+
Saved
|
|
94
|
+
</span>
|
|
95
|
+
)}
|
|
96
|
+
{status === "undo" && onUndo && (
|
|
97
|
+
<button
|
|
98
|
+
type="button"
|
|
99
|
+
onClick={onUndo}
|
|
100
|
+
className="text-primary -my-3 -mr-1 min-h-11 px-1 hover:underline"
|
|
101
|
+
>
|
|
102
|
+
Undo
|
|
103
|
+
</button>
|
|
104
|
+
)}
|
|
105
|
+
{onReset && status !== "undo" && (
|
|
106
|
+
<button
|
|
107
|
+
type="button"
|
|
108
|
+
onClick={onReset}
|
|
109
|
+
className="text-primary -my-3 -mr-1 min-h-11 px-1 hover:underline"
|
|
110
|
+
>
|
|
111
|
+
Reset
|
|
112
|
+
</button>
|
|
113
|
+
)}
|
|
114
|
+
</span>
|
|
115
|
+
</div>
|
|
116
|
+
)}
|
|
109
117
|
{below && <div className="col-span-2">{below}</div>}
|
|
110
118
|
</div>
|
|
111
119
|
);
|
|
@@ -129,3 +137,32 @@ export function SettingSection({
|
|
|
129
137
|
</section>
|
|
130
138
|
);
|
|
131
139
|
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* A row whose control is a block of its own (a list, a segmented control):
|
|
143
|
+
* the label sits above it, and the search box filters it like any row.
|
|
144
|
+
*/
|
|
145
|
+
export function SettingBlock({
|
|
146
|
+
id,
|
|
147
|
+
label,
|
|
148
|
+
help,
|
|
149
|
+
children,
|
|
150
|
+
}: {
|
|
151
|
+
id: string;
|
|
152
|
+
label?: string;
|
|
153
|
+
help?: string;
|
|
154
|
+
children: ReactNode;
|
|
155
|
+
}) {
|
|
156
|
+
const query = useContext(SettingsQueryContext);
|
|
157
|
+
if (!matchesQuery(query, label, help)) return null;
|
|
158
|
+
return (
|
|
159
|
+
<div
|
|
160
|
+
data-setting={id}
|
|
161
|
+
className="border-foreground/5 space-y-1.5 border-t px-3 py-2 first:border-t-0"
|
|
162
|
+
>
|
|
163
|
+
{label && <p className="text-sm font-medium">{label}</p>}
|
|
164
|
+
{children}
|
|
165
|
+
{help && <p className="text-muted-foreground text-xs">{help}</p>}
|
|
166
|
+
</div>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
@@ -58,16 +58,16 @@ export function SwitchSetting({
|
|
|
58
58
|
status={auto.status}
|
|
59
59
|
onUndo={auto.undo}
|
|
60
60
|
hint={
|
|
61
|
-
defaultValue === undefined
|
|
61
|
+
defaultValue === undefined || auto.value === defaultValue
|
|
62
62
|
? undefined
|
|
63
|
-
: `
|
|
63
|
+
: `Default: ${defaultValue ? "on" : "off"}`
|
|
64
64
|
}
|
|
65
65
|
onReset={
|
|
66
66
|
defaultValue !== undefined && auto.value !== defaultValue
|
|
67
67
|
? () => void auto.commit(defaultValue, { undoable: true })
|
|
68
68
|
: undefined
|
|
69
69
|
}
|
|
70
|
-
controlClassName="max-sm:col-span-1 max-sm:row-start-1 max-sm:mt-0"
|
|
70
|
+
controlClassName="max-sm:col-span-1 max-sm:col-start-2 max-sm:row-start-1 max-sm:mt-0 max-sm:justify-end"
|
|
71
71
|
control={
|
|
72
72
|
<Switch
|
|
73
73
|
id={id}
|
|
@@ -150,12 +150,8 @@ export function NumberSetting({
|
|
|
150
150
|
const shown = (off ? optional!.on : auto.value) / scale;
|
|
151
151
|
const defOff = optional ? defaultValue === optional.off : false;
|
|
152
152
|
const hint =
|
|
153
|
-
error === null
|
|
154
|
-
? `
|
|
155
|
-
max === undefined
|
|
156
|
-
? `${min / scale}${short}+`
|
|
157
|
-
: `${min / scale}–${max / scale}${short}`
|
|
158
|
-
}`
|
|
153
|
+
error === null && auto.value !== defaultValue
|
|
154
|
+
? `Default: ${defOff ? "off" : `${defaultValue / scale}${short}`}`
|
|
159
155
|
: undefined;
|
|
160
156
|
|
|
161
157
|
const finish = () => {
|
|
@@ -277,7 +273,12 @@ export function SelectSetting({
|
|
|
277
273
|
help={help}
|
|
278
274
|
status={auto.status}
|
|
279
275
|
onUndo={auto.undo}
|
|
280
|
-
hint={
|
|
276
|
+
hint={
|
|
277
|
+
hint ??
|
|
278
|
+
(def && auto.value !== defaultValue
|
|
279
|
+
? `Default: ${def.label}`
|
|
280
|
+
: undefined)
|
|
281
|
+
}
|
|
281
282
|
onReset={
|
|
282
283
|
defaultValue !== undefined && auto.value !== defaultValue
|
|
283
284
|
? () => void auto.commit(defaultValue, { undoable: true })
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { SettingBlock } from "@/components/Settings/SettingRow";
|
|
4
4
|
import { TextSetting } from "@/components/Settings/settings-fields";
|
|
5
5
|
import { useSetWorkspaceHq, useWorkspaceHqQuery } from "@/data/session-logs";
|
|
6
6
|
|
|
@@ -13,26 +13,28 @@ export function HqFolderForm({ workspaceId }: { workspaceId: string }) {
|
|
|
13
13
|
const save = useSetWorkspaceHq(workspaceId);
|
|
14
14
|
|
|
15
15
|
if (isPending)
|
|
16
|
-
return <div className="bg-muted/60 h-11 animate-pulse rounded-md" />;
|
|
16
|
+
return <div className="bg-muted/60 m-3 h-11 animate-pulse rounded-md" />;
|
|
17
17
|
if (isError)
|
|
18
|
-
return
|
|
18
|
+
return (
|
|
19
|
+
<SettingBlock id={`hq-folder-${workspaceId}`} label="HQ folder">
|
|
20
|
+
<p className="text-destructive text-xs">{error.message}</p>
|
|
21
|
+
</SettingBlock>
|
|
22
|
+
);
|
|
19
23
|
|
|
20
24
|
return (
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/>
|
|
36
|
-
</SettingSection>
|
|
25
|
+
<TextSetting
|
|
26
|
+
id={`hq-folder-${workspaceId}`}
|
|
27
|
+
label="HQ folder"
|
|
28
|
+
help={`Session logs go to docs/sessions/<project>/ in this repo, one commit per file. ${
|
|
29
|
+
data.hq?.visibility === "private"
|
|
30
|
+
? "The repo is private, so each commit is pushed."
|
|
31
|
+
: data.hq
|
|
32
|
+
? "Commits stay local: the repo isn't a private GitHub repository."
|
|
33
|
+
: "It must be a private git repo outside the workspace's projects."
|
|
34
|
+
}`}
|
|
35
|
+
placeholder="~/path/to/a/private/git/repo"
|
|
36
|
+
value={data.hq?.folder ?? ""}
|
|
37
|
+
onSave={(folder) => save.mutateAsync(folder)}
|
|
38
|
+
/>
|
|
37
39
|
);
|
|
38
40
|
}
|