Skip to content

Commit 6a8cebe

Browse files
committed
Fix DID commit resolve, set default drive description
1 parent 6c6e284 commit 6a8cebe

File tree

16 files changed

+148
-53
lines changed

16 files changed

+148
-53
lines changed

.claude/settings.local.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,20 @@
2424
"Bash(npx tsc:*)",
2525
"mcp__charlotte__charlotte_screenshot",
2626
"Bash(npx vitest:*)",
27-
"mcp__charlotte__charlotte_navigate"
27+
"mcp__charlotte__charlotte_navigate",
28+
"Bash(npx playwright:*)",
29+
"Bash(npm run:*)",
30+
"Bash(xargs grep:*)",
31+
"Bash(find /Users/joep/dev/github/atomicdata-dev/atomic-server/browser/data-browser/src/components/Dialog -name *.ts -o -name *.tsx)",
32+
"mcp__charlotte__charlotte_tab_open",
33+
"mcp__charlotte__charlotte_click",
34+
"mcp__charlotte__charlotte_find",
35+
"Bash(pnpm exec:*)",
36+
"Bash(curl -s http://localhost:9883)",
37+
"Bash(curl -s http://localhost:5173)",
38+
"mcp__charlotte__charlotte_tools",
39+
"mcp__charlotte__charlotte_observe",
40+
"mcp__charlotte__charlotte_type"
2841
]
2942
}
3043
}

browser/data-browser/src/chunks/TablePage/EditorCells/SelectCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function SelectCellEdit({
150150
<Content onKeyDown={handleKeyDown}>
151151
<SearchInputWrapper>
152152
<InputStyled
153-
placeholder='Filter tags...'
153+
placeholder='filter tags'
154154
onChange={handleSearch}
155155
ref={inputRef}
156156
/>

browser/data-browser/src/chunks/TablePage/PropertyForm/EditPropertyDialog.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function EditPropertyDialog({
3131
resource.save();
3232
}, [resource]);
3333

34-
const [dialogProps, show, hide] = useDialog({ bindShow, onSuccess });
34+
const [dialogProps, show, hide, visible] = useDialog({ bindShow, onSuccess });
3535

3636
useEffect(() => {
3737
if (showDialog) {
@@ -52,12 +52,14 @@ export function EditPropertyDialog({
5252
<h1>Edit Column</h1>
5353
</DialogTitle>
5454
<DialogContent>
55-
<PropertyForm
56-
existingProperty
57-
resource={resource}
58-
category={category}
59-
onSubmit={handleSaveClick}
60-
/>
55+
{visible && (
56+
<PropertyForm
57+
existingProperty
58+
resource={resource}
59+
category={category}
60+
onSubmit={handleSaveClick}
61+
/>
62+
)}
6163
</DialogContent>
6264
<DialogActions>
6365
<Button onClick={handleSaveClick} disabled={!valid}>

browser/data-browser/src/chunks/TablePage/PropertyForm/NewPropertyDialog.tsx

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,20 @@ import {
99
useArray,
1010
useStore,
1111
} from '@tomic/react';
12-
import { useCallback, useEffect, type JSX } from 'react';
12+
import { useCallback, useEffect, useState, type JSX } from 'react';
1313
import { stringToSlug } from '@helpers/stringToSlug';
1414
import { PropertyFormCategory } from './categories';
1515
import { sortSubjectList } from '@views/OntologyPage/sortSubjectList';
16+
import {
17+
Dialog,
18+
DialogActions,
19+
DialogContent,
20+
DialogTitle,
21+
useDialog,
22+
} from '@components/Dialog';
23+
import { Button } from '@components/Button';
24+
import { FormValidationContextProvider } from '@components/forms/formValidation/FormValidationContextProvider';
25+
import { PropertyForm } from './PropertyForm';
1626

1727
interface NewPropertyDialogProps {
1828
showDialog: boolean;
@@ -70,12 +80,13 @@ export function NewPropertyDialog({
7080
bindShow,
7181
}: NewPropertyDialogProps): JSX.Element {
7282
const store = useStore();
83+
const [propertyResource, setPropertyResource] = useState<Resource | null>(null);
84+
const [valid, setValid] = useState(true);
85+
7386
const [_properties, _setProperties, pushProp] = useArray(
7487
tableClassResource,
7588
core.properties.recommends,
76-
{
77-
commit: true,
78-
},
89+
{ commit: true },
7990
);
8091

8192
const savePropertyToTable = useCallback(
@@ -103,10 +114,21 @@ export function NewPropertyDialog({
103114
[store, tableClassResource, pushProp],
104115
);
105116

117+
const onSuccess = useCallback(async () => {
118+
if (propertyResource) {
119+
await savePropertyToTable(propertyResource);
120+
}
121+
}, [propertyResource, savePropertyToTable]);
122+
123+
const [dialogProps, show, hide] = useDialog({ bindShow, onSuccess });
124+
106125
useEffect(() => {
107-
if (!showDialog) return;
126+
if (!showDialog) {
127+
setPropertyResource(null);
128+
return;
129+
}
108130

109-
const create = async () => {
131+
const init = async () => {
110132
// Determine the correct parent before signing the genesis commit, since
111133
// the parent is baked into the commit and controls authorization.
112134
const tableClassParent = await store.getResource(
@@ -121,7 +143,7 @@ export function NewPropertyDialog({
121143
selectedCategory as PropertyFormCategory,
122144
);
123145

124-
const propertyResource = await store.newResource({
146+
const resource = await store.newResource({
125147
parent: parentSubject,
126148
isA,
127149
propVals: {
@@ -131,12 +153,47 @@ export function NewPropertyDialog({
131153
...propVals,
132154
},
133155
});
134-
await savePropertyToTable(propertyResource);
135-
bindShow(false);
156+
157+
setPropertyResource(resource);
158+
// show() is called in a separate effect after propertyResource is set,
159+
// so the Dialog is already in the DOM when show() runs.
136160
};
137161

138-
create().catch(console.error);
162+
init().catch(console.error);
139163
}, [showDialog]);
140164

141-
return <></>;
165+
// Open dialog after propertyResource is set and Dialog is mounted.
166+
useEffect(() => {
167+
if (propertyResource && showDialog) {
168+
show();
169+
}
170+
}, [propertyResource]);
171+
172+
const handleCreateClick = useCallback(() => {
173+
hide(true);
174+
}, [hide]);
175+
176+
return (
177+
<FormValidationContextProvider onValidationChange={setValid}>
178+
<Dialog {...dialogProps}>
179+
<DialogTitle>
180+
<h1>New {selectedCategory ? selectedCategory[0].toUpperCase() + selectedCategory.slice(1) : ''} Column</h1>
181+
</DialogTitle>
182+
<DialogContent>
183+
{propertyResource && (
184+
<PropertyForm
185+
resource={propertyResource}
186+
category={selectedCategory as PropertyFormCategory}
187+
onSubmit={handleCreateClick}
188+
/>
189+
)}
190+
</DialogContent>
191+
<DialogActions>
192+
<Button onClick={handleCreateClick} disabled={!valid}>
193+
Create
194+
</Button>
195+
</DialogActions>
196+
</Dialog>
197+
</FormValidationContextProvider>
198+
);
142199
}

browser/data-browser/src/components/NewIdentitySection.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export function NewIdentitySection({
5858
noParent: true,
5959
propVals: {
6060
[core.properties.name]: driveName,
61+
[core.properties.description]: '# Welcome to your Drive\n\nThis is your personal Atomic Data drive. Edit this description to tell visitors what this space is about.',
6162
[core.properties.write]: [agentDID],
6263
[core.properties.read]: [agentDID],
6364
},

browser/data-browser/src/components/Tag/CreateTagRow.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ export function CreateTagRow({ parent, onNewTag }: CreateTagRowProps) {
2121
const [resetKey, setResetKey] = useState<number>(0);
2222

2323
const createNewTag = useCallback(async () => {
24-
const subject = await store.buildUniqueSubjectFromParts(
25-
['tag', tagName],
26-
parent,
27-
);
24+
// When the parent is a DID, subjects are derived from the genesis commit
25+
// signature and must not have a path appended. Only pre-compute a path-based
26+
// subject for HTTP parents.
27+
const subject = parent.startsWith('did:')
28+
? undefined
29+
: await store.buildUniqueSubjectFromParts(['tag', tagName], parent);
2830

2931
const tag = await store.newResource({
3032
subject,

browser/data-browser/src/helpers/navigation.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ export function constructOpenURL(
2424
return '#';
2525
}
2626

27-
const url = new URL(subject);
27+
let url: URL;
28+
29+
try {
30+
url = new URL(subject);
31+
} catch {
32+
// Non-URL subjects (e.g. DIDs) are always treated as remote resources
33+
return constructURL(paths.show, { subject, ...extraParams });
34+
}
2835

2936
if (isRemoteResource(url)) {
3037
return constructURL(paths.show, { subject, ...extraParams });

browser/data-browser/src/hooks/useDevDrive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export function useDevDrive() {
3636
noParent: true,
3737
propVals: {
3838
[core.properties.name]: 'dev',
39+
[core.properties.description]: '# Welcome to your Drive\n\nThis is your personal Atomic Data drive. Edit this description to tell visitors what this space is about.',
3940
[core.properties.write]: [agentDID],
4041
[core.properties.read]: [agentDID],
4142
},

browser/data-browser/src/locales/de.po

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ msgstr "Einladungstext (optional)"
116116
msgid "Limit Usages (optional)"
117117
msgstr "Nutzungen beschränken (optional)"
118118

119+
#: src/chunks/TablePage/PropertyForm/NewPropertyDialog.tsx
119120
#: src/components/InviteForm.tsx
120121
#: src/components/forms/NewForm/CustomCreateActions/CustomForms/NewArticleDialog.tsx
121122
#: src/components/forms/NewForm/CustomCreateActions/CustomForms/NewDriveDialog.tsx
@@ -2631,9 +2632,8 @@ msgstr "Öffne Bearbeitungsdialog"
26312632
msgid "Add resource"
26322633
msgstr "Ressource hinzufügen"
26332634

2634-
#: src/chunks/TablePage/EditorCells/SelectCell.tsx
2635-
msgid "Filter tags..."
2636-
msgstr "Filtere Tags..."
2635+
#~ msgid "Filter tags..."
2636+
#~ msgstr "Filtere Tags..."
26372637

26382638
#: src/views/OntologyPage/Property/PropertyCardRead.tsx
26392639
msgid "Allows only:"
@@ -3753,3 +3753,8 @@ msgstr ""
37533753
#: src/components/SideBar/AppMenu.tsx
37543754
msgid "Create a fresh agent + drive on localhost:9883"
37553755
msgstr ""
3756+
3757+
#. placeholder {0}: selectedCategory ? selectedCategory[0].toUpperCase() + selectedCategory.slice(1) : ''
3758+
#: src/chunks/TablePage/PropertyForm/NewPropertyDialog.tsx
3759+
msgid "New {0} Column"
3760+
msgstr ""

browser/data-browser/src/locales/en.po

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ msgstr "Name"
661661
msgid "Cancel"
662662
msgstr "Cancel"
663663

664+
#: src/chunks/TablePage/PropertyForm/NewPropertyDialog.tsx
664665
#: src/components/InviteForm.tsx
665666
#: src/components/forms/NewForm/CustomCreateActions/CustomForms/NewArticleDialog.tsx
666667
#: src/components/forms/NewForm/CustomCreateActions/CustomForms/NewDriveDialog.tsx
@@ -2373,9 +2374,8 @@ msgstr "No Type selected"
23732374
msgid "Add resource"
23742375
msgstr "Add resource"
23752376

2376-
#: src/chunks/TablePage/EditorCells/SelectCell.tsx
2377-
msgid "Filter tags..."
2378-
msgstr "Filter tags..."
2377+
#~ msgid "Filter tags..."
2378+
#~ msgstr "Filter tags..."
23792379

23802380
#: src/components/ParentPicker/ParentPicker.tsx
23812381
msgid "Enter a subject"
@@ -3784,3 +3784,8 @@ msgstr "Setting up dev drive..."
37843784
#: src/components/SideBar/AppMenu.tsx
37853785
msgid "Create a fresh agent + drive on localhost:9883"
37863786
msgstr "Create a fresh agent + drive on localhost:9883"
3787+
3788+
#. placeholder {0}: selectedCategory ? selectedCategory[0].toUpperCase() + selectedCategory.slice(1) : ''
3789+
#: src/chunks/TablePage/PropertyForm/NewPropertyDialog.tsx
3790+
msgid "New {0} Column"
3791+
msgstr "New {0} Column"

0 commit comments

Comments
 (0)