@cyber-dash-tech/revela 0.8.1 → 0.8.2
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/lib/edit/deck-state.ts +2 -8
- package/lib/edit/open.ts +1 -4
- package/lib/edit/server.ts +11 -0
- package/package.json +1 -1
- package/plugin.ts +3 -0
package/lib/edit/deck-state.ts
CHANGED
|
@@ -6,18 +6,15 @@ import {
|
|
|
6
6
|
DECKS_STATE_FILE,
|
|
7
7
|
normalizeWorkspaceDeckState,
|
|
8
8
|
readOrCreateDecksState,
|
|
9
|
-
reviewDeckState,
|
|
10
9
|
upsertDeck,
|
|
11
10
|
upsertSlides,
|
|
12
11
|
writeDecksState,
|
|
13
|
-
type DeckStateReadinessResult,
|
|
14
12
|
type SlideSpec,
|
|
15
13
|
} from "../decks-state"
|
|
16
14
|
import type { EditableDeck } from "./resolve-deck"
|
|
17
15
|
|
|
18
16
|
export interface EditDeckStatePreflightResult {
|
|
19
17
|
changed: boolean
|
|
20
|
-
readiness: DeckStateReadinessResult
|
|
21
18
|
}
|
|
22
19
|
|
|
23
20
|
export function ensureEditableDeckState(workspaceRoot: string, deck: EditableDeck): EditDeckStatePreflightResult {
|
|
@@ -27,7 +24,6 @@ export function ensureEditableDeckState(workspaceRoot: string, deck: EditableDec
|
|
|
27
24
|
throw new Error(`${DECKS_STATE_FILE} already points to ${active.outputPath}. Revela 0.8 expects one deck per workspace; move extra decks to a separate workspace.`)
|
|
28
25
|
}
|
|
29
26
|
const existing = state.decks[deck.slug]
|
|
30
|
-
const existingReady = existing?.writeReadiness?.status === "ready" && existing.writeReadiness.blockers.length === 0
|
|
31
27
|
let changed = !existing || existing.outputPath !== deck.file
|
|
32
28
|
|
|
33
29
|
state = upsertDeck(state, {
|
|
@@ -64,12 +60,10 @@ export function ensureEditableDeckState(workspaceRoot: string, deck: EditableDec
|
|
|
64
60
|
changed = true
|
|
65
61
|
}
|
|
66
62
|
|
|
67
|
-
|
|
68
|
-
writeDecksState(workspaceRoot, reviewed.state)
|
|
63
|
+
writeDecksState(workspaceRoot, state)
|
|
69
64
|
|
|
70
65
|
return {
|
|
71
|
-
changed
|
|
72
|
-
readiness: reviewed.result,
|
|
66
|
+
changed,
|
|
73
67
|
}
|
|
74
68
|
}
|
|
75
69
|
|
package/lib/edit/open.ts
CHANGED
|
@@ -66,9 +66,6 @@ function openEditableDeckInternal(
|
|
|
66
66
|
): EnsureEditableDeckOpenResult {
|
|
67
67
|
const deck = resolveEditableDeck(options.workspaceRoot, target)
|
|
68
68
|
const preflight = ensureEditableDeckState(options.workspaceRoot, deck)
|
|
69
|
-
if (!preflight.readiness.ready) {
|
|
70
|
-
throw new Error(preflight.readiness.blocker || "Deck is not ready for HTML edits.")
|
|
71
|
-
}
|
|
72
69
|
|
|
73
70
|
ctx.enabled = true
|
|
74
71
|
if (!existsSync(ACTIVE_PROMPT_FILE)) {
|
|
@@ -88,7 +85,7 @@ function openEditableDeckInternal(
|
|
|
88
85
|
if (shouldOpen) (options.openUrl ?? openUrl)(url)
|
|
89
86
|
|
|
90
87
|
const source = deck.source === "decks-state" ? "DECKS.json" : deck.source === "file-path" ? "file path" : "fallback path"
|
|
91
|
-
const stateNote = preflight.changed ? "Deck state was prepared in DECKS.json
|
|
88
|
+
const stateNote = preflight.changed ? "Deck state was prepared in DECKS.json for visual editing." : "Deck state already points to this visual edit target."
|
|
92
89
|
|
|
93
90
|
return {
|
|
94
91
|
deck,
|
package/lib/edit/server.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { randomBytes } from "crypto"
|
|
2
2
|
import { readFileSync, statSync } from "fs"
|
|
3
|
+
import { resolve, sep } from "path"
|
|
3
4
|
import type { EditableDeck } from "./resolve-deck"
|
|
4
5
|
import { buildEditPrompt, type EditCommentPayload } from "./prompt"
|
|
5
6
|
|
|
@@ -85,6 +86,16 @@ export function hasLiveEditorSession(deck: EditableDeck, maxIdleMs = LIVE_EDITOR
|
|
|
85
86
|
return existing ? isSessionLive(existing.session, maxIdleMs) : false
|
|
86
87
|
}
|
|
87
88
|
|
|
89
|
+
export function hasLiveEditorSessionForFile(workspaceRoot: string, filePath: string, maxIdleMs = LIVE_EDITOR_IDLE_MS): boolean {
|
|
90
|
+
if (!filePath) return false
|
|
91
|
+
const root = resolve(workspaceRoot)
|
|
92
|
+
const absoluteFile = resolve(root, filePath)
|
|
93
|
+
if (absoluteFile !== root && !absoluteFile.startsWith(root.endsWith(sep) ? root : root + sep)) return false
|
|
94
|
+
cleanupExpiredSessions()
|
|
95
|
+
const existing = findSessionForDeck(absoluteFile)
|
|
96
|
+
return existing ? isSessionLive(existing.session, maxIdleMs) : false
|
|
97
|
+
}
|
|
98
|
+
|
|
88
99
|
export function stopEditServer(): void {
|
|
89
100
|
if (idleTimer) clearTimeout(idleTimer)
|
|
90
101
|
idleTimer = undefined
|
package/package.json
CHANGED
package/plugin.ts
CHANGED
|
@@ -47,6 +47,7 @@ import { handlePdf } from "./lib/commands/pdf"
|
|
|
47
47
|
import { handlePptx } from "./lib/commands/pptx"
|
|
48
48
|
import { handleEdit } from "./lib/commands/edit"
|
|
49
49
|
import { ensureEditableDeckOpenForChange } from "./lib/edit/open"
|
|
50
|
+
import { hasLiveEditorSessionForFile } from "./lib/edit/server"
|
|
50
51
|
import { handleDesignsPreview } from "./lib/commands/designs-preview"
|
|
51
52
|
import {
|
|
52
53
|
parseDesignsNewArgs,
|
|
@@ -540,6 +541,7 @@ Next step: use \`revela-decks\` with action \`init\`, \`upsertDeck\`, \`upsertSl
|
|
|
540
541
|
return
|
|
541
542
|
}
|
|
542
543
|
if (!isDeckHtmlPath(filePath)) return
|
|
544
|
+
if (hasLiveEditorSessionForFile(workspaceRoot, filePath)) return
|
|
543
545
|
|
|
544
546
|
const readiness = checkDeckStateWriteReadiness(workspaceRoot, filePath) ?? {
|
|
545
547
|
ready: false,
|
|
@@ -595,6 +597,7 @@ Next step: use \`revela-decks\` or \`/revela review\` to update ${DECKS_STATE_FI
|
|
|
595
597
|
|
|
596
598
|
const targets = extractDeckHtmlTargetsFromPatch(patchText)
|
|
597
599
|
if (targets.length === 0) return
|
|
600
|
+
if (targets.every((target) => hasLiveEditorSessionForFile(workspaceRoot, target))) return
|
|
598
601
|
|
|
599
602
|
const blocked = targets
|
|
600
603
|
.map((target) => ({
|