Transition D6 (#86) : retrait de Forge — « Editer » seul éditeur (2.94.0, #236) #94

Merged
bruno merged 2 commits from feat/transition-d6-retrait-forge into main 2026-11-28 12:47:04 -05:00
24 changed files with 127 additions and 2599 deletions
-9
View File
@@ -42,7 +42,6 @@ jobs:
node tests/frontend/desktop-roots.test.mjs
node tests/frontend/image-viewer.test.mjs
node tests/frontend/pdf-viewer.test.mjs
node tests/frontend/forge-completion.test.mjs
node tests/frontend/config-mobile.test.mjs
node tests/frontend/settings-order-avatar.test.mjs
node tests/frontend/mobile-toolbar.test.mjs
@@ -57,8 +56,6 @@ jobs:
node pane-manager.test.mjs
node excalidraw-viewer.test.mjs
node plugins.test.mjs
node ai.test.mjs
node ai-sidebar.test.mjs
node sidebar-filters.test.mjs
node search-facets.test.mjs
node sw.test.mjs
@@ -68,9 +65,7 @@ jobs:
node desktop.test.mjs
node toolbar-order.test.mjs
node editor-inline.test.mjs
node ai-quick-actions.test.mjs
node upload.test.mjs
node config-ai-keys.test.mjs
node xlsx-viewer.test.mjs
node filechat.test.mjs
else
@@ -79,8 +74,6 @@ jobs:
node pane-manager.test.mjs
node excalidraw-viewer.test.mjs
node plugins.test.mjs
node ai.test.mjs
node ai-sidebar.test.mjs
node sidebar-filters.test.mjs
node search-facets.test.mjs
node sw.test.mjs
@@ -90,9 +83,7 @@ jobs:
node desktop.test.mjs
node toolbar-order.test.mjs
node editor-inline.test.mjs
node ai-quick-actions.test.mjs
node upload.test.mjs
node config-ai-keys.test.mjs
node xlsx-viewer.test.mjs
node filechat.test.mjs
fi
+9 -1
View File
@@ -6,7 +6,7 @@ Format basé sur [Keep a Changelog](https://keepachangelog.com/fr/1.1.0/),
et [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
> **En cours de développement** : les changements à venir sont listés dans la section
> [Unreleased](#unreleased). La dernière version livrée est **2.93.0**.
> [Unreleased](#unreleased). La dernière version livrée est **2.94.0**.
---
@@ -14,6 +14,14 @@ et [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
---
## [2.94.0] — 2026-11-28
### Supprimé
- **Forge, l'éditeur avancé (#236, carte D6 #86, épopée fusion #195)** : la page `editor-poc.html` (éditeur avancé, panneau IA propre, complétion Ctrl+J), sa plomberie iframe dans le parent (délégations d'enregistrement/suppression/rechargement, handlers postMessage) et son bouton d'ouverture sont retirés. L'éditeur classique « Editer » est le seul éditeur. Les URL `/editor-poc` redirigent (302) vers l'application. Aucune donnée propre à Forge n'existait — mêmes fichiers et mêmes API que l'éditeur classique. **Redéploiement Docker requis.**
---
## [2.93.0] — 2026-11-28
### Supprimé
+3 -3
View File
@@ -4,7 +4,7 @@
**Porte d'entrée web ultra-léger pour vos vaults Obsidian** — Accédez, naviguez et recherchez dans toutes vos notes Obsidian depuis n'importe quel appareil via une interface web moderne et responsive.
[![Version](https://img.shields.io/badge/Version-2.93.0-blue.svg)]()
[![Version](https://img.shields.io/badge/Version-2.94.0-blue.svg)]()
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Docker](https://img.shields.io/badge/Docker-Ready-blue.svg)](https://www.docker.com/)
[![Python](https://img.shields.io/badge/Python-3.11+-green.svg)](https://www.python.org/)
@@ -981,8 +981,8 @@ Ce projet est sous licence **MIT** — voir le fichier [LICENSE](LICENSE) pour l
## 📝 Changelog
Consultez le [CHANGELOG.md](./CHANGELOG.md) pour l'historique complet de toutes les versions (v1.0.0 → v2.93.0).
Consultez le [CHANGELOG.md](./CHANGELOG.md) pour l'historique complet de toutes les versions (v1.0.0 → v2.94.0).
---
*Projet : ObsiGate | Version : 2.93.0 | Dernière mise à jour : Septembre 2026*
*Projet : ObsiGate | Version : 2.94.0 | Dernière mise à jour : Septembre 2026*
+3 -3
View File
@@ -2,7 +2,7 @@
**Ultra-light web gateway for your Obsidian vaults** — Access, browse, and search all your Obsidian notes from any device via a modern, responsive web interface.
[![Version](https://img.shields.io/badge/Version-2.93.0-blue.svg)]()
[![Version](https://img.shields.io/badge/Version-2.94.0-blue.svg)]()
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Docker](https://img.shields.io/badge/Docker-Ready-blue.svg)](https://www.docker.com/)
[![Python](https://img.shields.io/badge/Python-3.11+-green.svg)](https://www.python.org/)
@@ -1156,8 +1156,8 @@ This project is licensed under the **MIT License** - see the [LICENSE](LICENSE)
## 📝 Changelog
See [CHANGELOG.md](./CHANGELOG.md) for the complete version history (v1.0.0 → v2.93.0).
See [CHANGELOG.md](./CHANGELOG.md) for the complete version history (v1.0.0 → v2.94.0).
---
*Project: ObsiGate | Version: 2.93.0 | Last updated: September 2026*
*Project: ObsiGate | Version: 2.94.0 | Last updated: September 2026*
+1 -1
View File
@@ -1 +1 @@
2.93.0
2.94.0
+1 -1
View File
@@ -2,7 +2,7 @@
Chaque réponse HTTP reçoit un nonce frais (``request.state.csp_nonce``)
injecté dans ``script-src``. Les routes servant du HTML avec des scripts
inline (index, popout, admin, editor-poc, excalidraw, page de partage)
inline (index, popout, admin, excalidraw, page de partage)
l'injectent dans le balisage via :func:`inject_csp_nonce` — mêmes
emplacements, aucun script déplacé.
+5 -6
View File
@@ -7,7 +7,7 @@ from contextlib import asynccontextmanager
from pathlib import Path
from fastapi import Depends, FastAPI, HTTPException, Request
from fastapi.responses import FileResponse, HTMLResponse, JSONResponse
from fastapi.responses import FileResponse, HTMLResponse, JSONResponse, RedirectResponse
from fastapi.staticfiles import StaticFiles
from starlette.middleware.base import BaseHTTPMiddleware
@@ -988,11 +988,10 @@ if FRONTEND_DIR.exists():
@app.get("/editor-poc")
async def serve_editor_poc(request: Request):
"""Serve the standalone Editor POC page (multi-zone toolbar demo)."""
poc_file = FRONTEND_DIR / "editor-poc.html"
if poc_file.exists():
return HTMLResponse(content=_html_with_nonce(request, "editor-poc.html"), headers={"Cache-Control": "no-cache"})
raise HTTPException(status_code=404, detail="Editor POC not found")
# #236 (D6, #86) — Forge (l'éditeur avancé « editor-poc ») est
# retiré : ses URL redirigent vers l'application, où l'éditeur
# classique « Editer » est le seul éditeur.
return RedirectResponse(url="/", status_code=302)
@app.get("/excalidraw-editor.html", include_in_schema=False)
async def serve_excalidraw_editor(request: Request):
+1 -1
View File
@@ -2626,7 +2626,7 @@ dependencies = [
[[package]]
name = "obsigate-desktop"
version = "2.93.0"
version = "2.94.0"
dependencies = [
"chrono",
"env_logger",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "obsigate-desktop"
version = "2.93.0"
version = "2.94.0"
description = "ObsiGate Desktop — Porte d'entrée native pour vos vaults Obsidian"
authors = ["Bruno Charest"]
edition = "2021"
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/nicedoc/obsigate/main/desktop/tauri.conf.schema.json",
"productName": "ObsiGate",
"version": "2.93.0",
"version": "2.94.0",
"identifier": "com.obsigate.desktop",
"build": {
"frontendDist": "../frontend",
+11 -1
View File
@@ -1,6 +1,6 @@
# ObsiGate — Roadmap
> **Version :** 2.93.0 | **Dernière mise à jour :** 2026-11-28
> **Version :** 2.94.0 | **Dernière mise à jour :** 2026-11-28
> **Ce fichier ne contient que le travail à venir** (🔵 En cours + ⚪ Backlog) et un index compact
> vers les fonctionnalités livrées.
> - **Méthode de livraison à appliquer pour toute tâche : [DELIVERY_WORKFLOW.md](./DELIVERY_WORKFLOW.md)**
@@ -30,6 +30,16 @@
## 🔵 En cours
### 236. Fusion — retrait de Forge (transition D6)
- **Effort :** ~0,5 jour | **Impact :** 🟡 | **Ouvert :** 2026-11-28 | **Statut :** 🔵 en cours — PR sur `feat/transition-d6-retrait-forge` (carte Gitea #86 ; fusion et redéploiement Docker = geste de Bruno)
- **Fiche :** [features/fusion-retrait-forge-d6-236.md](./features/fusion-retrait-forge-d6-236.md)
- **Description :** vague D6 de la transition ObsiGate → Spark (épopée fusion #195). Forge — l'éditeur avancé `editor-poc.html`, son panneau IA et sa complétion Ctrl+J — est retiré ; l'éditeur classique « Editer » reste le seul éditeur. `/editor-poc` redirige (302) vers l'application. La plomberie iframe du parent (délégations `utils.js`, handlers postMessage `sync.js`) et le bouton d'ouverture disparaissent. Aucune donnée propre à Forge n'existait : mêmes fichiers, mêmes API que l'éditeur classique.
- **Sous-tâches :**
- [x] Page Forge supprimée, `/editor-poc` en redirection 302, plomberie parent retirée
- [x] Aide rapide nettoyée (Ctrl+J, Alt+I, F1, conseil Forge) ; tests Forge retirés ou mis à jour (`editor-inline` 31/31, contrat `test_retrait_forge_d6_236`)
- [ ] Fusion de la PR, CI verte, redéploiement Docker (geste de Bruno)
### 235. Fusion — retrait de l'assistant intégré (transition D5)
- **Effort :** ~1 jour | **Impact :** 🔴 | **Ouvert :** 2026-11-28 | **Statut :** 🔵 en cours — PR sur `feat/transition-d5-retrait-assistant` (carte Gitea #85 ; fusion et redéploiement Docker = geste de Bruno)
@@ -0,0 +1,49 @@
# #236 — Fusion : retrait de Forge (transition D6)
**Carte Gitea :** ObsiGate #86 (vague D6 de l'épopée fusion-trois-apps #195).
**Prérequis :** D1 (#232, bouton Forge remplacé par Spark), D5 (#235,
retrait de l'assistant intégré).
## Ce qui est retiré
- **`frontend/editor-poc.html`** — la page de l'éditeur avancé « Forge »
(2 109 lignes : éditeur, panneau IA propre, complétion fantôme Ctrl+J).
- **La plomberie iframe dans le parent** : délégations de
`utils.js` (`saveFile`, `deleteFile`, `reloadExternalWrite`,
fermetures d'éditeur — « si l'iframe Forge est ouverte, lui
déléguer ») et les handlers postMessage de `sync.js`
(`forge-renamed`, `forge-close`, `forge-open-ai`).
- **Le bouton d'ouverture** : `initEditorPocBtn` dans `config.js`.
- **L'aide rapide** (index.html) : les lignes Ctrl+J (complétion IA
inline), Alt+I et F1 propres à Forge, et le conseil qui renvoyait
vers Forge — réécrit pour « Editer » et Spark.
- **Tests** : `forge-completion.test.mjs` supprimé ; les vérifications
Forge/BooksLM de `editor-inline.test.mjs` retirées (le reste du
câblage d'édition inline, classique, est conservé : 31/31).
## Redirection des URL Forge
`GET /editor-poc` répond désormais **302 vers `/`** (l'application, où
l'éditeur classique « Editer » est le seul éditeur) au lieu de servir
la page. Aucune donnée propre à Forge n'existait hors de la page :
Forge éditait les mêmes fichiers du vault par les mêmes API que
l'éditeur classique — rien à migrer, rien de perdu.
## Ce qui reste
- L'éditeur classique « Editer » (CodeMirror, édition inline #93,
collaboration Yjs, barre Spark) — inchangé.
- Le bouton « popout » du visualiseur (fenêtre détachée de lecture),
dont les libellés vivent encore sous les clés `forge.popout*` des
locales — renommage cosmétique laissé au nettoyage D7.
- Le monolithe historique `frontend/app.js` (pré-modulaire) n'est pas
chargé par l'interface actuelle ; son sort relève de l'inventaire D7.
## Vérification
- Contrat `test_retrait_forge_d6_236` (redirection 302 comprise) ;
`test_csp_nonce` à jour (page retirée de la liste) ; contrat D5 mis
à jour (sync.js ne connaît plus forge-open-ai).
- ruff, `validate-imports.mjs` (0 erreur), `unit.test.mjs` 13/13,
`editor-inline.test.mjs` 31/31. E2E Playwright laissés à la CI.
- **Redéploiement Docker requis** après fusion.
File diff suppressed because it is too large Load Diff
+5 -29
View File
@@ -1402,26 +1402,6 @@
>Fermer l'editeur / modale</span
>
</div>
<div class="qh-row">
<span class="qh-kbd">Ctrl+J</span>
<span class="qh-desc"
>Completion IA inline (dans
l'editeur)</span
>
</div>
<div class="qh-row">
<span class="qh-kbd">Alt+I</span>
<span class="qh-desc"
>Insertion rapide (editeur
Forge)</span
>
</div>
<div class="qh-row">
<span class="qh-kbd">F1</span>
<span class="qh-desc"
>Aide de l'editeur Forge</span
>
</div>
<div class="qh-divider"></div>
<div class="qh-tip">
<i
@@ -1434,16 +1414,12 @@
<span
>Survolez un document avec
<strong>Ctrl</strong> pour un
apercu rapide. Cliquez sur
<strong>Forge</strong> dans la
barre d'outils pour l'editeur
avance. <strong>Editer</strong> et
<strong>Forge</strong> remplacent
le document en mode lecture
(retour par ✓, ✕ ou
apercu rapide. <strong>Editer</strong>
remplace le document en mode
lecture (retour par ✓, ✕ ou
<strong>Echap</strong>) : le
panneau de l'assistant IA reste
accessible a cote.</span
panneau Spark reste accessible
a cote.</span
>
</div>
</div>
-9
View File
@@ -364,14 +364,6 @@ async function downloadGuide(format) {
}
}
function initEditorPocBtn() {
var btn = document.getElementById("editor-poc-btn");
if (!btn) return;
btn.addEventListener("click", function() {
window.open("/editor-poc", "_blank");
});
}
function initHelpNavigation() {
const helpBody = document.getElementById("help-body");
const navList = document.getElementById("help-nav-list");
@@ -1906,7 +1898,6 @@ export {
initHelpModal,
closeHelpModal,
initRecentTab,
initEditorPocBtn,
loadAbout as initAboutSection,
loadHiddenFilesSettings as initHiddenFilesConfig,
initThemePicker,
-50
View File
@@ -658,54 +658,4 @@ export function init() {
}
}, 3000);
initDashboardTabs();
// Listen for Forge editor rename events
window.addEventListener('message', function(e) {
if (!e.data || !e.data.type) return;
if (e.data.type === 'forge-renamed') {
var vault = e.data.vault;
var oldPath = e.data.oldPath;
var newPath = e.data.newPath;
console.log('[Forge] File renamed:', vault, oldPath, '->', newPath);
var titleEl = document.getElementById('editor-title');
if (titleEl && titleEl.textContent.indexOf('Forge:') === 0) {
titleEl.textContent = 'Forge: ' + newPath.split('/').pop();
}
refreshSidebarTreePreservingState(vault);
if (state.currentVault === vault && state.currentPath === oldPath) {
import('./viewer.js').then(function(m) { m.openFile(vault, newPath); });
}
}
if (e.data.type === 'forge-close') {
// #93 — shared close path: hands the editor container back to the modal
// (inline mode) and re-renders the document read view.
closeEditor();
}
if (e.data.type === 'forge-open-ai') {
// #101 — Forge has no AI panel of its own: its AI button asks the
// parent to open the Spark panel.
var openForgeAssistant = function() {
// Transition Spark (D5, #85) : l'assistant intégré est retiré,
// le bouton IA de Forge ouvre le panneau Spark.
import('./spark-panneau.js').then(function(sp) {
return sp.ouvrirSparkOuMessage();
}).catch(function(err) {
console.warn('[Forge] Unable to open Spark panel', err);
});
};
// BUG-056 — the assistant panel is mounted in this document. The native
// fullscreen may be owned by the parent (Forge iframe) rather than by the
// iframe itself, so the parent must also leave fullscreen before the
// panel can be seen.
if (document.fullscreenElement && document.exitFullscreen) {
try {
document.exitFullscreen().catch(function() {}).then(openForgeAssistant, openForgeAssistant);
} catch (err) {
openForgeAssistant();
}
} else {
openForgeAssistant();
}
}
});
}
-33
View File
@@ -57,8 +57,6 @@ export function detachInlineEditor() {
}
state.fallbackEditorEl = null;
clearTimeout(window._obsigateAutoSaveTimer);
var forgeFrame = document.getElementById("forge-iframe");
if (forgeFrame) forgeFrame.remove();
if (modal) {
modal.classList.remove("active");
var brand = modal.querySelector('.editor-brand');
@@ -601,9 +599,6 @@ function closeEditor() {
}
state.fallbackEditorEl = null;
clearTimeout(window._obsigateAutoSaveTimer);
// Remove forge iframe if present
var forgeFrame = document.getElementById("forge-iframe");
if (forgeFrame) forgeFrame.remove();
// #93 — hand the editor container back to the modal BEFORE restoring the
// header/footer/brand: they live inside the container and therefore travel
// with it in inline mode (a `modal.querySelector` would miss them).
@@ -659,12 +654,6 @@ async function reloadExternalWrite(vault, path, force = false) {
if (!vault || !path) return;
const isEdited = state.editorVault === vault && state.editorPath === path;
if (isEdited) {
// Forge hosts its own buffer inside an iframe: ask it to reload from disk.
var forgeFrame = document.getElementById("forge-iframe");
if (forgeFrame && forgeFrame.contentWindow) {
forgeFrame.contentWindow.postMessage({ type: 'parent-reload', force: !!force }, '*');
return;
}
if (!state.editorView) return;
// BUG-055 — a non-forced reload (SSE `index_updated`) is often caused by the
// editor's own autosave: reloading then would clobber edits made after the
@@ -743,20 +732,6 @@ function resetSaveButton() {
}
async function saveFile(silent = false) {
// If Forge is open, delegate save to the iframe
var forgeFrame = document.getElementById("forge-iframe");
if (forgeFrame && forgeFrame.contentWindow) {
if (!state.editorVault || !state.editorPath) return;
var fSaveBtn = document.getElementById("editor-save");
var fSaveDot = document.getElementById("editor-save-dot");
var fSaveLabel = document.getElementById("editor-save-label");
if (fSaveDot) { fSaveDot.className = 'editor-save-dot saving'; }
if (fSaveLabel) fSaveLabel.textContent = 'Saving...';
if (fSaveBtn) { fSaveBtn.disabled = true; }
forgeFrame.contentWindow.postMessage({ type: 'parent-save' }, '*');
return;
}
if ((!state.editorView && !state.fallbackEditorEl) || !state.editorVault || !state.editorPath) return;
const content = state.editorView ? state.editorView.state.doc.toString() : state.fallbackEditorEl.value;
@@ -840,14 +815,6 @@ async function saveFile(silent = false) {
}
async function deleteFile() {
// If Forge is open, delegate delete to the iframe
var forgeFrame = document.getElementById("forge-iframe");
if (forgeFrame && forgeFrame.contentWindow) {
if (!state.editorVault || !state.editorPath) return;
forgeFrame.contentWindow.postMessage({ type: 'parent-delete' }, '*');
return;
}
if (!state.editorVault || !state.editorPath) return;
const deleteBtn = document.getElementById("editor-delete");
+5 -6
View File
@@ -7211,12 +7211,11 @@ export function renderFile(data) {
openEditor(data.vault, data.path);
});
// Transition Spark D1 (#81) — le bouton « Forge » est retiré de la
// toolbar et remplacé par « Spark » : il ouvre le panneau Spark avec
// le document courant en contexte (déclaration D2 ci-dessous). Le
// code Forge lui-même reste en place (retrait = carte D6, après
// validation de la bascule) ; l'éditeur classique « Editer » est
// conservé tel quel.
// Transition Spark D1 (#81) — le bouton « Forge » a été remplacé
// par « Spark » : il ouvre le panneau Spark avec le document
// courant en contexte (déclaration D2 ci-dessous). Forge a depuis
// été retiré (D6, #86) ; l'éditeur classique « Editer » est le
// seul éditeur.
const sparkBtn = el("button", { class: "btn-action btn-spark", title: t("viewer.spark_title") }, [icon("sparkles", 14), document.createTextNode("Spark")]);
sparkBtn.addEventListener("click", () => {
if (window.DRACO_PANNEAU && typeof window.DRACO_PANNEAU.toggle === "function") {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "obsigate",
"version": "2.93.0",
"version": "2.94.0",
"description": "**Porte d'entr\u00e9e web ultra-l\u00e9ger pour vos vaults Obsidian** \u2014 Acc\u00e9dez, naviguez et recherchez dans toutes vos notes Obsidian depuis n'importe quel appareil via une interface web moderne et responsive.",
"main": "patch.js",
"directories": {
+9 -96
View File
@@ -2,15 +2,15 @@
/**
* ObsiGate — Inline edition tests (ROADMAP #93).
*
* « Editer » and « Forge » must replace the document read view instead of
* opening an overlay on top of it (`#editor-container` is moved into the
* content area, so the AI assistant sidebar stays usable while editing).
* « Editer » must replace the document read view instead of opening an
* overlay on top of it (`#editor-container` is moved into the content
* area, so the Spark panel stays usable while editing). Forge, the
* former second editor, was removed in D6 (#236).
*
* Covers:
* - frontend/js/editor-inline.js — DOM behaviour (mount/unmount/classes)
* - the wiring of that module in viewer.js / utils.js / sync.js / bookslm.js
* - the wiring of that module in viewer.js / utils.js / sync.js
* (static checks, like tests/frontend/toolbar-order.test.mjs)
* - the Forge iframe reload hook (frontend/editor-poc.html)
* - the CSS that makes the editor fill the content area (frontend/style.css)
*
* Usage: node tests/frontend/editor-inline.test.mjs
@@ -198,10 +198,8 @@ const read = (...parts) => readFileSync(path.join(REPO_ROOT, ...parts), "utf8");
const viewerSrc = read("frontend", "js", "viewer.js");
const utilsSrc = read("frontend", "js", "utils.js");
const syncSrc = read("frontend", "js", "sync.js");
const bookslmSrc = read("frontend", "js", "bookslm.js");
const indexSrc = read("frontend", "index.html");
const cssSrc = read("frontend", "style.css");
const forgeSrc = read("frontend", "editor-poc.html");
console.log("Inline edition (#93) — wiring");
@@ -241,15 +239,6 @@ test("viewer.js mounts the editor inline when rendering is taken over", () => {
assert.match(guard[1], /if \(isInlineEditorActive\(\)\) detachInlineEditor\(\);/);
});
test("viewer.js Forge button mounts inline and sizes the iframe accordingly", () => {
assert.match(viewerSrc, /var inline = activateInlineEditor\(data\.vault, data\.path\);/);
assert.ok(viewerSrc.includes('var brand = queryEditor(".editor-brand");'), "header query must follow the container");
assert.equal(viewerSrc.includes('modal.querySelector(".editor-brand")'), false, "modal-scoped brand query would break inline mode");
assert.match(
viewerSrc,
/iframe\.style\.cssText = "width:100%;height:" \+ \(inline \? "100%" : "82vh"\) \+ ";border:none;display:block;";/,
);
});
test("utils.js activateInlineEditor only takes over the displayed document", () => {
const fn = utilsSrc.match(/export function activateInlineEditor\(([\s\S]*?)\n\}/);
@@ -274,10 +263,12 @@ test("utils.js detachInlineEditor tears the session down without re-rendering",
assert.match(fn[1], /unmountEditorInline\(\)/);
});
test("utils.js reloads the displayed document after an AI write", () => {
test("utils.js reloads the displayed document after an external write", () => {
const fn = utilsSrc.match(/async function reloadExternalWrite\(vault, path, force = false\) \{([\s\S]*?)\n\}/);
assert.ok(fn, "reloadExternalWrite not found");
assert.match(fn[1], /postMessage\(\{ type: 'parent-reload', force: !!force \}, '\*'\)/);
// Forge (iframe, parent-reload) a été retiré en D6 (#236) : seul le
// rechargement CodeMirror subsiste.
assert.doesNotMatch(fn[1], /parent-reload/);
assert.match(fn[1], /suppressAutoSaveOnce = true;/);
assert.match(utilsSrc, /window\.addEventListener\("obsigate:file-written"/);
assert.match(utilsSrc, /if \(suppressAutoSaveOnce\) \{/, "autosave skipped on programmatic reload");
@@ -292,20 +283,7 @@ test("utils.js does not clobber unsaved edits on a non-forced reload (BUG-055)",
assert.match(utilsSrc, /reloadExternalWrite\(detail\.vault, detail\.path, true\);/);
});
test("sync.js forge-close goes through the shared close path", () => {
assert.ok(syncSrc.includes("import { closeEditor, reloadExternalWrite } from './utils.js';"), "utils import missing");
const handler = syncSrc.match(/if \(e\.data\.type === 'forge-close'\) \{([\s\S]*?)\n \}/);
assert.ok(handler, "forge-close handler not found");
assert.match(handler[1], /closeEditor\(\);/);
});
test("sync.js leaves fullscreen before opening the Forge assistant (BUG-056)", () => {
const handler = syncSrc.match(/if \(e\.data\.type === 'forge-open-ai'\) \{([\s\S]*?)\n \}/);
assert.ok(handler, "forge-open-ai handler not found");
assert.match(handler[1], /document\.fullscreenElement/);
assert.match(handler[1], /document\.exitFullscreen\(\)/);
assert.match(handler[1], /openForCurrentContext\(\)/);
});
test("sync.js keeps an open edition session alive on external file changes", () => {
const sse = syncSrc.match(/const changed = \(data\.changes \|\| \[\]\)([\s\S]*?)\n \}/);
@@ -327,37 +305,8 @@ test("pane activation releases an inline edition session first", () => {
assert.match(paneActivate[1], /detachInlineEditor\(\);/);
});
test("bookslm.js reports the edited document and the assistant writes", () => {
assert.match(bookslmSrc, /const editing = this\._editingDocument\(\);/);
assert.match(bookslmSrc, /if \(editing\) ctx\.editing = editing;/);
assert.match(bookslmSrc, /this\._notifyFileWritten\(data\);/);
const notify = bookslmSrc.match(/_notifyFileWritten\(data\) \{([\s\S]*?)\n \}/);
assert.ok(notify, "_notifyFileWritten not found");
// BUG-076: the write-tool list is a module-level set (documents included).
assert.match(notify[1], /FILE_WRITE_TOOLS\.has\(data\.name\)/);
const writeSet = bookslmSrc.match(/const FILE_WRITE_TOOLS = new Set\(\[([\s\S]*?)\]\);/);
assert.ok(writeSet, "FILE_WRITE_TOOLS not found");
for (const tool of ["edit_file", "append_to_file", "create_file", "restore_backup",
"create_xlsx", "create_docx", "create_csv", "create_pdf"]) {
assert.ok(writeSet[1].includes(`'${tool}'`), `${tool} missing from the write tools`);
}
assert.match(notify[1], /new CustomEvent\('obsigate:file-written'/);
});
test("editor-poc.html reloads Forge buffer on parent-reload", () => {
assert.match(forgeSrc, /if \(e\.data\.type === 'parent-reload'\) \{/);
const handler = forgeSrc.match(/if \(e\.data\.type === 'parent-reload'\) \{([\s\S]*?)\n \}/);
assert.ok(handler, "parent-reload handler not found");
assert.match(handler[1], /clearTimeout\(saveTimer\);/);
assert.match(handler[1], /loadFile\(\);/);
});
test("editor-poc.html inserts assistant text on parent-insert (BUG-057)", () => {
assert.match(forgeSrc, /if \(e\.data\.type === 'parent-insert' && typeof e\.data\.text === 'string'\) \{/);
const handler = forgeSrc.match(/if \(e\.data\.type === 'parent-insert' && typeof e\.data\.text === 'string'\) \{([\s\S]*?)\n \}/);
assert.ok(handler, "parent-insert handler not found");
assert.match(handler[1], /insertAtCursor\(/);
});
test("style.css lets the inline editor fill the content area", () => {
assert.match(cssSrc, /\.editor-modal\.editor-inline-mode \{/);
@@ -423,48 +372,12 @@ test("utils.js saveFile restores the save button when the request fails", () =>
assert.match(utilsSrc, /console\.error\("Save error:", err\);\s*\n\s*resetSaveButton\(\);/);
});
// ── #101: Forge uses the shared AI assistant + native fullscreen ──
test("editor-poc.html opens the shared AI assistant from its AI button", () => {
assert.ok(!/id="ai-panel"/.test(forgeSrc), "Forge mini AI panel markup must be gone");
assert.match(forgeSrc, /postMessage\(\{ type: 'forge-open-ai' \}, '\*'\)/);
assert.match(forgeSrc, /btnAI\.addEventListener\('click', openAssistant\)/);
});
test("sync.js routes forge-open-ai to the BooksLM assistant", () => {
const handler = syncSrc.match(/if \(e\.data\.type === 'forge-open-ai'\) \{([\s\S]*?)\n \}/);
assert.ok(handler, "forge-open-ai handler not found");
assert.match(handler[1], /import\('\.\/bookslm\.js'\)/);
assert.match(handler[1], /openForCurrentContext\(\)/);
});
test("editor-poc.html AI calls use the assistant's configured provider/model", () => {
const pick = forgeSrc.match(/function aiPickerSelection\(\) \{([\s\S]*?)\n \}/);
assert.ok(pick, "aiPickerSelection not found");
assert.match(pick[1], /obsigate_ai_picker/);
assert.match(forgeSrc, /var pick = aiPickerSelection\(\);/);
assert.match(forgeSrc, /Object\.keys\(pick\)\.forEach/);
});
test("editor-poc.html fixes AI endpoint names and translate param", () => {
assert.match(forgeSrc, /'ai-longer':\s*\{ ep: 'make-longer'/);
assert.match(forgeSrc, /'ai-shorter':\s*\{ ep: 'make-shorter'/);
assert.match(forgeSrc, /'ai-translate':\s*\{ ep: 'translate', extra: \{ target_lang: 'en' \}/);
});
test("editor-poc.html ghost completion follows the configured provider", () => {
assert.match(forgeSrc, /ghostBody\.provider = ghostPick\.provider \|\| 'ollama';/);
assert.match(forgeSrc, /ghostBody\.model = ghostPick\.model;/);
});
test("editor-poc.html has a native fullscreen button", () => {
assert.match(forgeSrc, /id="btn-fullscreen"/);
assert.match(forgeSrc, /document\.documentElement\.requestFullscreen/);
assert.match(forgeSrc, /document\.addEventListener\('fullscreenchange'/);
});
test("viewer.js allows fullscreen in the Forge iframe", () => {
assert.match(viewerSrc, /iframe\.setAttribute\("allow", "fullscreen"\)/);
});
test("index.html has an editor fullscreen button with i18n title", () => {
assert.match(indexSrc, /id="editor-fullscreen"/);
-234
View File
@@ -1,234 +0,0 @@
#!/usr/bin/env node
/**
* ObsiGate — Forge autocomplete tests (BUG-055).
*
* The Forge editor (`frontend/editor-poc.html`) shares its pure completion
* helpers with CodeMirror through `frontend/js/autocomplete.js`. This suite
* pins the behaviour that fixes the « Tab adds a stray space » bug:
*
* - getWordFragment / findWordCompletions — document word completion
* - normalizeGhost — AI inline prediction cleanup
* - chooseTabAction — single action per Tab press
*
* Usage: node tests/frontend/forge-completion.test.mjs
*/
import { strict as assert } from "node:assert";
import { fileURLToPath, pathToFileURL } from "node:url";
import path from "node:path";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const REPO_ROOT = path.resolve(__dirname, "..", "..");
const mod = await import(
pathToFileURL(path.join(REPO_ROOT, "frontend", "js", "autocomplete.js")).href
);
const {
isWordChar,
getWordFragment,
findWordCompletions,
normalizeGhost,
chooseTabAction,
} = mod;
let testCount = 0;
let failCount = 0;
function test(name, fn) {
testCount++;
try {
fn();
console.log(` ✓ ${name}`);
} catch (err) {
failCount++;
console.error(` ✗ ${name}\n ${err.message}`);
process.exitCode = 1;
}
}
// ── isWordChar ─────────────────────────────────────────────────────────────
test("isWordChar accepts letters, digits, _ - . /", () => {
for (const ch of ["a", "Z", "0", "_", "-", ".", "/"]) {
assert.equal(isWordChar(ch), true, `expected ${JSON.stringify(ch)} to be a word char`);
}
});
test("isWordChar rejects spaces and punctuation", () => {
for (const ch of [" ", "\n", "!", "@", "#", "(", "\t"]) {
assert.equal(isWordChar(ch), false, `expected ${JSON.stringify(ch)} not to be a word char`);
}
assert.equal(isWordChar(""), false);
assert.equal(isWordChar(undefined), false);
});
// ── getWordFragment ────────────────────────────────────────────────────────
test("getWordFragment returns the fragment before the cursor", () => {
const text = "hello wor";
assert.deepEqual(getWordFragment(text, text.length), { start: 6, fragment: "wor" });
});
test("getWordFragment stops at non-word characters", () => {
const text = "a (tabl";
assert.deepEqual(getWordFragment(text, text.length), { start: 3, fragment: "tabl" });
});
test("getWordFragment returns an empty fragment at a word boundary", () => {
const text = "hello ";
assert.deepEqual(getWordFragment(text, text.length), { start: 6, fragment: "" });
});
test("getWordFragment handles a mid-document cursor", () => {
const text = "one two three";
// cursor right after "tw"
assert.deepEqual(getWordFragment(text, 6), { start: 4, fragment: "tw" });
});
// ── findWordCompletions ────────────────────────────────────────────────────
test("findWordCompletions returns prefix matches from the document", () => {
const text = "table tableau tab\n";
const cursor = text.length;
assert.deepEqual(findWordCompletions(text, cursor, "tab", 8), ["table", "tableau"]);
});
test("findWordCompletions ignores the occurrence being typed", () => {
const text = "table and tab";
const cursor = text.length; // typing the trailing "tab"
assert.deepEqual(findWordCompletions(text, cursor, "tab", 8), ["table"]);
});
test("findWordCompletions is case-insensitive and unique", () => {
const text = "Table TABLE table\n";
const cursor = text.length;
assert.deepEqual(findWordCompletions(text, cursor, "tab", 8), ["Table"]);
});
test("findWordCompletions completes file-like tokens", () => {
const text = "docs/guide.md docs/guide\n";
const cursor = text.length;
assert.deepEqual(findWordCompletions(text, cursor, "docs/", 8), ["docs/guide.md", "docs/guide"]);
});
test("findWordCompletions honours the limit", () => {
const text = "abc abd abe abf abg\n";
const cursor = text.length;
assert.equal(findWordCompletions(text, cursor, "ab", 3).length, 3);
});
test("findWordCompletions needs at least two characters", () => {
const text = "apple apricot\n";
assert.deepEqual(findWordCompletions(text, text.length, "a", 8), []);
assert.deepEqual(findWordCompletions(text, text.length, "", 8), []);
});
// ── normalizeGhost ─────────────────────────────────────────────────────────
test("normalizeGhost strips an echoed prefix (mid-word)", () => {
assert.equal(normalizeGhost("familial", "famil", true), "ial");
});
test("normalizeGhost keeps only the first token for a word completion", () => {
// A word completion must never introduce a space.
assert.equal(normalizeGhost("familial and more", "famil", true), "ial");
});
test("normalizeGhost tolerates a leading space from the model", () => {
assert.equal(normalizeGhost(" monde", "bonjour", false), "monde");
});
test("normalizeGhost strips a repeated full context", () => {
assert.equal(normalizeGhost("Bonjour le monde", "Bonjour", false), " le monde".trim());
});
test("normalizeGhost returns an empty string for empty input", () => {
assert.equal(normalizeGhost("", "abc", true), "");
assert.equal(normalizeGhost(null, "abc", true), "");
assert.equal(normalizeGhost(" ", "abc", false), "");
});
test("normalizeGhost keeps a phrase continuation intact", () => {
assert.equal(normalizeGhost("la suite de la phrase.", "Voici", false), "la suite de la phrase.");
});
// ── chooseTabAction ────────────────────────────────────────────────────────
test("chooseTabAction prioritises the open list", () => {
assert.equal(chooseTabAction({ dropdownOpen: true, ghost: true }), "dropdown");
});
test("chooseTabAction accepts a ghost prediction before word completion", () => {
assert.equal(chooseTabAction({ ghost: true, candidates: ["table"] }), "ghost");
});
test("chooseTabAction inserts a single word match", () => {
assert.equal(chooseTabAction({ candidates: ["table"] }), "word");
});
test("chooseTabAction opens the list for several matches", () => {
assert.equal(chooseTabAction({ candidates: ["table", "tableau"] }), "word-list");
});
test("chooseTabAction indents when nothing matches", () => {
assert.equal(chooseTabAction({ candidates: [] }), "indent");
assert.equal(chooseTabAction({}), "indent");
});
test("chooseTabAction dedents on Shift+Tab", () => {
assert.equal(chooseTabAction({ shiftKey: true }), "dedent");
assert.equal(chooseTabAction({ shiftKey: true, candidates: ["table"] }), "dedent");
});
test("chooseTabAction indents when a selection exists", () => {
assert.equal(chooseTabAction({ hasSelection: true, candidates: ["table"] }), "indent");
});
// ── Static wiring of frontend/editor-poc.html ──────────────────────────────
import { readFileSync } from "node:fs";
const FORGE_HTML = readFileSync(
path.join(REPO_ROOT, "frontend", "editor-poc.html"),
"utf-8",
);
test("Forge uses the shared completion helpers", () => {
for (const call of ["ac.getWordFragment(", "ac.findWordCompletions(", "ac.chooseTabAction("]) {
assert.ok(FORGE_HTML.includes(call), `editor-poc.html must call ${call}`);
}
});
test("Forge has a single indentation call site (no double Tab handling)", () => {
const indentCalls = FORGE_HTML.match(/indentLine\(\);/g) || [];
assert.equal(indentCalls.length, 1, "indentLine() must only be called from the unified Tab handler");
});
test("Forge ghost text no longer mirrors the whole document", () => {
assert.ok(!FORGE_HTML.includes("ghostOverlay.innerHTML"), "the mirror overlay must be gone");
});
test("Forge ignores its own autosave reload while the buffer is dirty (BUG-055)", () => {
assert.ok(
FORGE_HTML.includes("if (!e.data.force && isDirty) return;"),
"parent-reload must not clobber unsaved local edits",
);
});
test("Forge cancels a pending ghost request when the prediction is accepted", () => {
const fn = FORGE_HTML.match(/function acceptGhost\(\) \{([\s\S]*?)\n \}/);
assert.ok(fn, "acceptGhost not found");
assert.match(fn[1], /clearTimeout\(_ghostTimer\)/);
});
test("Forge autosave keeps the buffer dirty if edits arrive during the request", () => {
const fn = FORGE_HTML.match(/function autoSave\(\) \{([\s\S]*?)\n \}/);
assert.ok(fn, "autoSave not found");
assert.match(fn[1], /if \(val\(\) !== content\) \{ scheduleAutoSave\(\); return; \}/);
});
test("Forge leaves fullscreen before opening the shared assistant", () => {
const fn = FORGE_HTML.match(/function openAssistant\(\) \{([\s\S]*?)\n \}/);
assert.ok(fn, "openAssistant not found");
assert.match(fn[1], /document\.fullscreenElement/);
assert.match(fn[1], /document\.exitFullscreen\(\)/);
assert.match(fn[1], /postMessage\(\{ type: 'forge-open-ai' \}, '\*'\)/);
});
// ── Summary ────────────────────────────────────────────────────────────────
console.log(`\n${testCount} passed, ${failCount} failed`);
process.exit(failCount > 0 ? 1 : 0);
+1 -1
View File
@@ -213,7 +213,7 @@ class TestFrontendStepsHaveTheirDeps:
l'étape JSDOM (les deux branches)."""
text = CI_YML.read_text(encoding="utf-8")
jsdom_part = text.split("Frontend JSDOM tests", 1)[1]
for suite in ("node upload.test.mjs", "node config-ai-keys.test.mjs"):
for suite in ("node upload.test.mjs", "node editor-inline.test.mjs"):
assert jsdom_part.count(suite) >= 2, (
f"BUG-082 : `{suite}` attendu dans les deux branches de "
"l'étape JSDOM"
+1 -1
View File
@@ -49,7 +49,7 @@ def test_all_pages_fully_nonced():
"""Aucun script inline exécutable sans nonce après injection (sauf src=)."""
from backend.csp import inject_csp_nonce
for name in ("index.html", "popout.html", "admin.html", "editor-poc.html", "excalidraw-editor.html"):
for name in ("index.html", "popout.html", "admin.html", "excalidraw-editor.html"):
out = inject_csp_nonce(_read(name), NONCE)
bare = re.findall(r"<script>", out)
assert not bare, f"{name} : scripts sans nonce restants"
+20 -1
View File
@@ -478,7 +478,7 @@ def test_retrait_assistant_d5_235():
assert "creerBarreSpark(container)" in utils # barre d'édition = Spark
sync = (FRONTEND / "js" / "sync.js").read_text(encoding="utf-8")
assert "sp.ouvrirSparkOuMessage()" in sync # bouton IA de Forge
assert "forge-open-ai" not in sync # Forge retiré en D6 (#236)
racine = FRONTEND.parent
for module in ("ai.py", "ai_chat.py", "ai_history.py", "ai_routes.py",
@@ -495,3 +495,22 @@ def test_retrait_assistant_d5_235():
panneau = (FRONTEND / "draco-panneau.js").read_text(encoding="utf-8")
assert "draco-contexte" in panneau and "DOCUMENT OUVERT" in panneau
assert "MODE GÉNÉRAL" in panneau
def test_retrait_forge_d6_236(client):
"""#236 (carte D6, #86) — Forge est retiré, « Editer » seul éditeur.
La page de l'éditeur avancé (editor-poc.html) n'existe plus ; son
URL redirige vers l'application (éditeur classique) ; plus aucun
handler postMessage Forge ni délégation iframe dans le parent.
"""
racine = FRONTEND.parent
assert not (FRONTEND / "editor-poc.html").exists()
r = client.get("/editor-poc", follow_redirects=False)
assert r.status_code == 302 and r.headers["location"] == "/"
sync = (FRONTEND / "js" / "sync.js").read_text(encoding="utf-8")
assert "forge-renamed" not in sync and "forge-close" not in sync
utils = (FRONTEND / "js" / "utils.js").read_text(encoding="utf-8")
assert "forge-iframe" not in utils and "parent-reload" not in utils
config = (FRONTEND / "js" / "config.js").read_text(encoding="utf-8")
assert "editor-poc" not in config