Skip to content

Commit 947d170

Browse files
Jing-yilinclaude
andcommitted
Keep newer PRD text across a save, date a project by its PRD, and open a hosted kit index
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 4cbd18a commit 947d170

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎canvas/server/sp.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,11 @@ export function createSpServer(options: {
200200
name,
201201
url: `/p/${encodeURIComponent(name)}/`,
202202
path: dir,
203-
// A project with no board yet was last edited when it was made.
203+
// A project with no board yet was last edited when it was made. Its documents count.
204204
updated: Math.max(
205205
fs.statSync(dir).mtimeMs,
206206
...canvases.map((c) => c.updated),
207+
...DOCS.map((doc) => fs.statSync(path.join(dir, doc), { throwIfNoEntry: false })?.mtimeMs ?? 0),
207208
),
208209
canvases,
209210
cover: projectCover(boards, readProjectJson(dir).cover),

‎canvas/src/AppShell.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ declare global {
4343
* What the window's address opened on: the home page, or a view of this project's, whose tab is
4444
* worked out here from the address until the canvas has loaded and said which it landed on.
4545
* The hosted build is on Cloudflare Pages, which answers `home.html` with a 308 to `home`, so
46-
* the home page is either. A build has no project, only examples, so its bare address is home.
46+
* the home page is either. A build has no project, only examples, so its bare address is home,
47+
* but not its index of kits, `?brand=`, which is the same project view with an empty slug too.
4748
*/
4849
const openedTab = tabFor(tabFromUrl(location.href));
4950
const opened =
5051
/\/home(\.html)?$/.test(location.pathname) ||
51-
(!canvasIndex().served && openedTab.kind === "project")
52+
(!canvasIndex().served && openedTab.kind === "project" && openedTab.view.kind === "canvas")
5253
? null
5354
: { tab: openedTab, href: frameUrl(location.href) };
5455

‎canvas/src/DocTab.tsx‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ export function DocTab({ slug }: { slug: string }) {
9999
const d = draftOf(slug);
100100
draft.set(undefined);
101101
saveError.set(undefined);
102-
if (d) void save(d, keepalive).then((saved) => saved || draft.set(d));
102+
// Kept on failure, unless it has been reopened and edited again since.
103+
if (d) void save(d, keepalive).then((saved) => saved || draft.get() || draft.set(d));
103104
};
104105
const hide = () => leave(true);
105106
window.addEventListener(DOCS_CHANGED, redraw);
@@ -133,8 +134,12 @@ export function DocTab({ slug }: { slug: string }) {
133134
if ((e.metaKey || e.ctrlKey) && e.key === "s") {
134135
e.preventDefault();
135136
const d = draftOf(slug)!;
136-
// Saved, the file is the text now, and the next save checks against it.
137-
void save(d).then((saved) => saved && draft.set({ ...d, base: d.text }));
137+
// Saved, the file is the text now, and the next save checks against it. The text
138+
// stays the current one, which may have been typed on while this was in flight.
139+
void save(d).then((saved) => {
140+
const now = draftOf(slug);
141+
if (saved && now) draft.set({ ...now, base: d.text });
142+
});
138143
}
139144
}}
140145
/>

0 commit comments

Comments
 (0)