Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resolver = "2"
members = ["crates/openpl-oracle", "crates/openpl-core", "app/src-tauri"]

[workspace.package]
version = "1.0.0-beta.10"
version = "1.0.0-beta.11"
edition = "2021"
license = "Apache-2.0 OR MIT"

Expand Down
5 changes: 5 additions & 0 deletions anti-slop/audit-busqueda-historial-scripts-2026-11-27.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ Dirección de `DESIGN.md`, ENERGY 1, RHYTHM 1 y MOTION 1. Diálogos rectos con c
| Contenido y forma | PASS revisión de código | Etiquetas breves, botones con acción, íconos existentes, ancho acotado al viewport y listas desplazables que envuelven SQL e identificadores largos. Sin activos gráficos nuevos ni animaciones nuevas. |
| Compilación | PASS | Vite y Tauri de depuración generaron la aplicación. |
| Validación visual nativa | Pendiente | Los recorridos se ejecutaron con Vitest y jsdom. Falta la revisión visual en WebView y la consulta de catálogo contra Oracle real. |

## Apertura desde los resultados (WAL-126)

- **PASS automatizado.** Lupa, nombre y tipo, Buscar, clic en el resultado. Un paquete conserva la pestaña Spec. Una tabla, una vista y una secuencia abren su DDL en el editor de solo lectura. Al elegir el mismo resultado otra vez se reutiliza la pestaña. F8 no ejecuta el DDL.
- **PASS revisión de código.** La pestaña reutiliza el editor y los estados de carga y error existentes. Se conservan los tokens, el foco y los controles. La comprobación en escritorio contra Oracle queda pendiente.
4 changes: 2 additions & 2 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "openpl",
"private": true,
"version": "1.0.0-beta.10",
"version": "1.0.0-beta.11",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion app/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "OpenPL",
"version": "1.0.0-beta.10",
"version": "1.0.0-beta.11",
"identifier": "org.openpl.app",
"build": {
"beforeDevCommand": "npm run dev",
Expand Down
44 changes: 44 additions & 0 deletions app/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import App from "./App";
import { api } from "./api";

beforeAll(async () => {
if (!HTMLDialogElement.prototype.showModal) {
Object.defineProperty(HTMLDialogElement.prototype, "showModal", {
configurable: true,
value(this: HTMLDialogElement) { this.open = true; },
});
}
// La latencia de los módulos del runner no forma parte del flujo de sesión.
await Promise.all([
import("./components/ProgramWindow"),
Expand Down Expand Up @@ -51,6 +57,43 @@ test("busca por nombre y tipo en el esquema y abre el resultado", async () => {
expect(await screen.findByRole("textbox", { name: "Spec" })).toHaveTextContent("PACKAGE PKG_VENTAS");
});

test.each([
["Table", "CREATE TABLE HR.CLIENTES (ID NUMBER);"],
["View", "CREATE VIEW HR.CLIENTES AS SELECT 1 AS ID FROM DUAL;"],
["Sequence", "CREATE SEQUENCE HR.CLIENTES;"],
] as const)("Buscar en el esquema abre el DDL de %s en una pestaña de solo lectura", async (type, ddl) => {
windowEvents.close.mockResolvedValue(() => {});
vi.mocked(api.listObjects).mockResolvedValue([{
owner: "HR", name: "CLIENTES", object_type: type, status: "Valid", last_ddl_time: "",
}]);
const readDdl = vi.mocked(api.objectDdl).mockClear().mockResolvedValue(ddl);
const openSql = vi.mocked(api.sqlOpen).mockClear();
const execute = vi.mocked(api.sqlExecute).mockClear();
render(<App />);
await connectAs();

async function selectResult() {
fireEvent.click(screen.getByRole("button", { name: "Buscar en el esquema" }));
const dialog = within(screen.getByRole("dialog", { name: "Buscar en el esquema" }));
fireEvent.change(dialog.getByLabelText("Nombre"), { target: { value: "clientes" } });
fireEvent.change(dialog.getByLabelText("Tipo"), { target: { value: type } });
fireEvent.click(dialog.getByRole("button", { name: "Buscar" }));
fireEvent.click(await dialog.findByRole("button", { name: "HR.CLIENTES" }));
}

await selectResult();
const editor = await screen.findByRole("textbox", { name: "DDL" });
expect(editor).toHaveTextContent(ddl);
expect(editor).toHaveAttribute("aria-readonly", "true");
expect(readDdl).toHaveBeenCalledWith("s1", type, "HR", "CLIENTES");
fireEvent.keyDown(window, { key: "F8" });
await selectResult();
expect(screen.getAllByRole("textbox", { name: "DDL" })).toHaveLength(1);
expect(readDdl).toHaveBeenCalledOnce();
expect(openSql).not.toHaveBeenCalled();
expect(execute).not.toHaveBeenCalled();
});

test("el historial de sentencias permite recuperar SQL de una pestaña cerrada", async () => {
windowEvents.close.mockResolvedValue(() => {});
vi.mocked(api.sqlOpen).mockResolvedValueOnce("w1").mockResolvedValueOnce("w2");
Expand Down Expand Up @@ -199,6 +242,7 @@ vi.mock("./api", () => ({
sessionSiblings: vi.fn(async (): Promise<string[]> => []),
sessionPing: vi.fn(async () => true),
listObjects: vi.fn(),
objectDdl: vi.fn(),
programSource: vi.fn(),
editorObject: vi.fn(async () => null),
describeColumns: vi.fn(async () => []),
Expand Down
31 changes: 23 additions & 8 deletions app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { ToolsDialog } from "./components/ToolsDialog";
import { ObjectInspector, type Inspection } from "./components/ObjectInspector";
import { ObjectDraftDialog } from "./components/ObjectDraftDialog";
import { createDraft, dropDraft, privilegesQuery } from "./objectDraft";
import { hasObjectDdl } from "./objectMenu";
import type { ProgramActions } from "./components/ProgramWindow";
import { pendingDiscardMessage } from "./gridEdits";
import { neighbor, reorder } from "./tabs";
Expand Down Expand Up @@ -965,12 +966,14 @@ export default function App() {

async function onOpenObject(
object: ObjectInfo,
mode: "view" | "edit" = "view",
mode: "view" | "edit" | "definition" = "view",
connection = active,
at?: { partKind: string; line: number; column: number },
) {
if (!connection) return;
if (!supportsProgram.has(object.object_type)) {
const opensSource = supportsProgram.has(object.object_type);
const opensDdl = mode === "definition" && !opensSource && hasObjectDdl(object.object_type);
if (!opensSource && !opensDdl) {
if (mode === "edit") {
try {
const ddl = await api.objectDdl(connection.sessionId, object.object_type, object.owner, object.name);
Expand Down Expand Up @@ -1001,17 +1004,25 @@ export default function App() {
addProgram({
id,
connection,
object,
label: `${object.owner}.${object.name} @ ${connection.label}`,
readOnly: mode === "view",
object: opensDdl ? undefined : object,
label: `${object.owner ? `${object.owner}.` : ""}${object.name} @ ${connection.label}`,
readOnly: mode !== "edit",
dirty: false,
load,
target: at,
});
}
try {
const parts = [...(await fetchProgram(connection.sessionId, object))];
const parts: ProgramPart[] = opensDdl
? [{
kind: "DDL",
source: await api.objectDdl(connection.sessionId, object.object_type, object.owner, object.name),
last_ddl_time: object.last_ddl_time,
diagnostics: [],
}]
: [...(await fetchProgram(connection.sessionId, object))];
if (parts.length === 0) throw new Error("Fuente no disponible.");
if (opensDdl && !parts[0].source.trim()) throw new Error("DDL no disponible.");
const first = parts[0]?.kind;
if (parts.length === 1 && (first === "PACKAGE" || first === "TYPE")) {
parts.push({
Expand All @@ -1024,6 +1035,9 @@ export default function App() {
updateProgram(id, { parts, load: undefined }, load);
} catch (error) {
const detail = describeError(error);
if (opensDdl && detail.kind === "ConnectionLost") {
setStates((all) => ({ ...all, [connection.sessionId]: "Disconnected" }));
}
updateProgram(
id,
{
Expand Down Expand Up @@ -1501,7 +1515,8 @@ export default function App() {
}, read)
: undefined}
readOnly={tab.readOnly}
onReadOnlyChange={(readOnly) => updateProgram(tab.id, { readOnly })}
onReadOnlyChange={tab.parts[0]?.kind === "DDL"
? undefined : (readOnly) => updateProgram(tab.id, { readOnly })}
fileName={tab.fileName}
active={tab.id === programId}
catalog={
Expand Down Expand Up @@ -1625,7 +1640,7 @@ export default function App() {
{tool === "scripts" && <AutoReplaceDialog close={() => setTool(null)} />}
{tool === "search" && active && <SchemaSearch key={active.sessionId} connection={active}
close={() => setTool(null)} onConnectionLost={onConnectionLost}
open={(object) => { setTool(null); void onOpenObject(object, "view", active); }} />}
open={(object) => { setTool(null); void onOpenObject(object, "definition", active); }} />}
{tool === "history" && active && (() => {
const entries = statementHistory.filter((entry) => entry.connectionId === active.sessionId);
return <ToolsDialog title={commands.statementHistory.label} close={() => setTool(null)}>
Expand Down
1 change: 1 addition & 0 deletions app/src/components/ProgramWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ interface Props {
}

const caption = (kind: string) => {
if (kind === "DDL") return kind;
if (kind === "PACKAGE" || kind === "TYPE") return "Spec";
if (kind.endsWith(" BODY")) return "Body";
return "Fuente";
Expand Down
7 changes: 4 additions & 3 deletions app/src/objectMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const DATA_TYPES = new Set<ObjectType>(["Table", "View", "MaterializedView"]);
const TESTABLE = new Set<ObjectType>(["Package", "Procedure", "Function"]);
const RECOMPILABLE = new Set<ObjectType>([...CODE_TYPES, "View", "MaterializedView"]);
const NO_DDL = new Set<ObjectType>(["JavaClass", "DbmsJob", "RecycleBin"]);
export const hasObjectDdl = (type: ObjectType) => !NO_DDL.has(type);

function dataGroup(t: ObjectType, h: ObjectMenuHandlers): MenuEntry[] {
const editKeys = commands.editData.keys;
Expand Down Expand Up @@ -60,7 +61,7 @@ export function objectMenuItems(t: ObjectType, h: ObjectMenuHandlers): MenuEntry
{ label: "Ver", run: h.view },
{ label: "Editar", run: h.edit },
);
else if ((code || data) && !NO_DDL.has(t)) items.push({ label: "Ver", run: h.view }, { label: "Editar", run: h.edit });
else if ((code || data) && hasObjectDdl(t)) items.push({ label: "Ver", run: h.view }, { label: "Editar", run: h.edit });
if (TESTABLE.has(t)) items.push({ label: commands.test.label, keys: h.test ? undefined : commands.test.keys,
run: h.test, pending: h.test ? undefined : true });
if (data) items.push(...dataGroup(t, h));
Expand All @@ -76,8 +77,8 @@ export function objectMenuItems(t: ObjectType, h: ObjectMenuHandlers): MenuEntry
{ label: "Propiedades", run: inspect && (() => inspect("properties")) },
);
if (RECOMPILABLE.has(t)) items.push({ label: "Recompilar", run: h.recompile });
if (!user && !NO_DDL.has(t)) items.push({ label: "Copiar DDL", run: h.copyDdl });
if ((code || data) && !NO_DDL.has(t)) items.push({ label: "Comparar con…", run: inspect && (() => inspect("compare")) });
if (!user && hasObjectDdl(t)) items.push({ label: "Copiar DDL", run: h.copyDdl });
if ((code || data) && hasObjectDdl(t)) items.push({ label: "Comparar con…", run: inspect && (() => inspect("compare")) });
items.push(
"sep",
{ label: "Copiar nombre", keys: "Ctrl+C", run: h.copyName },
Expand Down
2 changes: 2 additions & 0 deletions docs/ESTADO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## Resumen

- Beta 11 (WAL-126): los resultados de Buscar en el esquema abren la fuente de los programas o una pestaña DDL de solo lectura para tablas, vistas y los demás tipos con DDL. Los tipos sin DDL conservan el inspector. Pasaron 779 pruebas Vitest, TypeScript, build web, fmt, Clippy y las pruebas Rust sin conexión a Oracle. Queda pendiente la comprobación manual en la app instalada. [Comportamiento](behavior/busqueda-historial-scripts.md).

- Beta 9 publicada y validada por el usuario. Los issues de las betas 8 y 9 están en Done en Linear. [Validación de Beta 8](https://linear.app/walter-aquino/project/openpl-7f23a40b5b5c/activity#project-update-511a7819) y [validación de Beta 9](https://linear.app/walter-aquino/project/openpl-7f23a40b5b5c/activity#project-update-031e4038).
- La rama `feat/ficha-todas-las-columnas` muestra todas las columnas al pasar el puntero sobre tablas y vistas. La ficha mantiene su altura máxima y permite desplazarse por la lista. Pasaron 776 pruebas Vitest, TypeScript, fmt, Clippy y pruebas Rust sin conexión a Oracle. La prueba de regresión usa una tabla simulada de 64 columnas. [Comportamiento](behavior/editor-inteligente.md).

Expand Down
2 changes: 1 addition & 1 deletion docs/behavior/busqueda-historial-scripts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Búsqueda, historial y scripts

- La lupa del explorador abre una búsqueda por nombre y tipo de objeto. Se puede buscar entre objetos propios o todos los accesibles en la conexión. Seleccionar un resultado abre el objeto como desde el árbol.
- La lupa del explorador busca por nombre y tipo entre objetos propios o todos los accesibles. Al seleccionar un resultado se abre su fuente en la pestaña de programa o su DDL en una pestaña de solo lectura. Los tipos sin DDL abren el inspector de metadatos. El DDL se muestra como texto y no se ejecuta.
- El reloj abre el historial de la conexión activa. Incluye sentencias SQL y PL/SQL enviadas desde ventanas SQL, de prueba y de comandos. Muestra el resultado de la ejecución. Seleccionar una entrada abre el texto en una pestaña SQL sin ejecutarlo. Conserva hasta 200 entradas en memoria durante la ejecución de OpenPL.
- Auto Replace permite agregar, editar y eliminar abreviaturas de scripts. La configuración se guarda en el equipo. `SEL` viene configurada con `select * from tabla`. Tab expande la abreviatura completa sin distinguir mayúsculas, en los editores editables y en el prompt de comandos. Si no coincide, queda el comportamiento habitual de Tab.
- La búsqueda usa el catálogo existente de solo lectura. Las pruebas del agente usan datos simulados y no ejecutan escrituras ni PL/SQL en Oracle.
Loading