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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.36.0 · 2026-11-19

- Only one FormTxt engine uses a data folder at a time. A second copy of FormTxt started on the same folder is told that FormTxt is already running there, and the first copy carries on undisturbed.
- An engine of this version that is left running after its app is gone is stopped and replaced the next time FormTxt starts. An engine left behind by 0.35.0 or older is not: it holds nothing FormTxt can recognise it by.
- The engine keeps a log: `Logs/formtxt-engine.log` in the FormTxt folder, with the three files before it. When the engine has nowhere to write its errors, they go to `Logs/formtxt-engine-errors.log` beside it.
- Opening the engine program by itself, for example with a double click in the install folder, opens FormTxt and leaves no engine running.
- When FormTxt cannot start its engine, it says so before its loading window closes, and the sentence says that a copy may already be open and where the log is.
- Not in this release: on Windows, ending FormTxt from Task Manager is not yet made to end everything the engine started, and the sentence for a failed start does not yet carry the engine's own last lines. Nothing in this release was run on Windows or macOS.

## 0.35.0 · 2026-11-19

- Antigravity, Google's `agy` program, is the fourth agent program FormTxt works with, beside Claude Code, Codex and Cursor. The terminal panel has an Antigravity tab when the program is found on this computer.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</p>

<p align="center">
<img alt="version 0.35.0" src="https://img.shields.io/badge/version-0.35.0-eef0f4?style=flat-square">
<img alt="version 0.36.0" src="https://img.shields.io/badge/version-0.36.0-eef0f4?style=flat-square">
<img alt="TypeScript and Vite" src="https://img.shields.io/badge/TypeScript%20%2B%20Vite-3178c6?style=flat-square&logo=typescript&logoColor=white">
<img alt="Python and FastAPI" src="https://img.shields.io/badge/Python%20%2B%20FastAPI-009688?style=flat-square">
<img alt="macOS, Windows, Linux" src="https://img.shields.io/badge/macOS%20%C2%B7%20Windows%20%C2%B7%20Linux-native-2f7bf5?style=flat-square">
Expand All @@ -24,7 +24,7 @@
<a href="#run-it-from-source">Run it from source</a>
</p>

Version 0.35.0 · Apache-2.0 · macOS, Windows, Linux (browser, or the desktop app built with ./build_app)
Version 0.36.0 · Apache-2.0 · macOS, Windows, Linux (browser, or the desktop app built with ./build_app)

<br>

Expand Down
23 changes: 21 additions & 2 deletions backend/HASHOUT_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,30 @@

Living log of comment content, rationale and removed code for the engine. Source files stay comment-free; read this first, then edit surgically.

Current build version: v0.35.0
Last updated: 2026-11-19 · v0.35.0: the family's finder for the agent programs at 1.0.1, an Antigravity tab, agents install for Antigravity, tests that find only stand-ins, the engine starting with no output streams (sections below, headed "after v0.34.0" as they were written). Before: 2026-11-19 · v0.34.0: database merge data, list reports and report run, changes only from the window, the outside-agent question with Allow once and Block all agents, Codex and Cursor tabs (sections below, headed "v0.34.0, not released yet" as they were written). Before: 2026-11-17 · v0.33.0 has no change in the engine; the AMOLED Black theme is in the frontend log. Before: 2026-11-14 · v0.32.1: the macOS freeze keeps the Python library loadable inside the app bundle (section below). Before: 2026-11-13 · v0.32.0 has no change in the engine; `setup/icon_rules.py` also checks the insertable icon and emoji data (frontend log). Before: 2026-11-13 · v0.31.0: MCP, terminals and Claude Code in the engine, the agent kit (section below). Before: 2026-11-13 · the v0.30.8 fixes to the engine entry and scripts (section below). Before: 2026-11-12 · the v0.30.7 review fixes. Before: 2026-10-31 · .js, .mjs and .css keep their types on Windows; the Linux packages pull in the media plugins. Before: macOS engine signed for notarization
Current build version: v0.36.0
Last updated: 2026-11-19 · v0.36.0: one engine per data folder, the engine's log file, an engine started alone opens the app, the engine leaving with its app by the family's watch, and in the shell the failure sentence before the loading window closes (sections below, headed "after v0.35.0" as they were written). Before: 2026-11-19 · v0.35.0: the family's finder for the agent programs at 1.0.1, an Antigravity tab, agents install for Antigravity, tests that find only stand-ins, the engine starting with no output streams (sections below, headed "after v0.34.0" as they were written). Before: 2026-11-19 · v0.34.0: database merge data, list reports and report run, changes only from the window, the outside-agent question with Allow once and Block all agents, Codex and Cursor tabs (sections below, headed "v0.34.0, not released yet" as they were written). Before: 2026-11-17 · v0.33.0 has no change in the engine; the AMOLED Black theme is in the frontend log. Before: 2026-11-14 · v0.32.1: the macOS freeze keeps the Python library loadable inside the app bundle (section below). Before: 2026-11-13 · v0.32.0 has no change in the engine; `setup/icon_rules.py` also checks the insertable icon and emoji data (frontend log). Before: 2026-11-13 · v0.31.0: MCP, terminals and Claude Code in the engine, the agent kit (section below). Before: 2026-11-13 · the v0.30.8 fixes to the engine entry and scripts (section below). Before: 2026-11-12 · the v0.30.7 review fixes. Before: 2026-10-31 · .js, .mjs and .css keep their types on Windows; the Linux packages pull in the media plugins. Before: macOS engine signed for notarization

---

## after v0.35.0 · the shell: its process id under the family's name, and the failure sentence before the loading window closes (2026-11-19)

- src-tauri/src/main.rs :: `main` (the engine's start in `setup`) · the engine also gets `FORMTXT_SHELL_PID`, the shell's own process id, beside `FORMTXT_PARENT_PID`, which stays. When no address and key came, the sentence is shown first and the loading window is closed only after it returns; before, the loading window was closed first, and closing the last window before a dialog is the silent end a tester saw in another Form app. The sentence now says what the lock makes the likely cause, a copy that is already open, and where the engine's log is. This entry is in the engine's log because the shell has no log of its own.
- Three small changes on purpose: one more `.env(...)` line beside its twin, one string, two statements in another order. Not compiled: the desktop shell cannot be built on the build machine. Not run on any system.
- Not done, the rest of the family's shell side, held for a session that can prove it with the scratch crate: `win_job.rs` (the job object that ends the engine with the shell on Windows) and `engine_start.rs` (the failure sentences with the engine's last lines and exit code, and a limit on the wait for the address, which has none today). FormTxt starts its engine through tauri-plugin-shell, which gives no `std::process::Child` for `win_job::hold`; the way to take is FormTools's, moving that one start to `std::process::Command`. Things that session must mind: `kill_backend` asks `kill -0`, which a finished child that was not waited for still answers, so it must ask `try_wait` as FormTools does; the one-file engine is beside the app's program (the plugin's `sidecar` found it there), so `packaged::engine_folder` needs that place; `sidecar.spawn().expect(...)` ends the shell without a word when the engine cannot be started.

## after v0.35.0 · the engine starts and stops cleanly: one engine per data folder, a log, and leaving with the app (2026-11-19)

- core/startup.py (new) · the family's start and stop file, copied from FormTools's `backend/app/core/startup.py` at its main with only the names at its top changed (`APP`, `NAMES`, `SHELL_ENV` = `FORMTXT_SHELL_PID`, `ALONE_ENV` = `FORMTXT_NO_SHELL`, `ERRORS_NAME`). Standard library only, no import of FormTxt. `PLACES` is as FormTools has it: FormTxt's engine sits beside the app's program (the one-file engine) or in a folder `engine` under the install folder or under `Contents/Resources` (`src-tauri/src/packaged.rs`), and both are covered.
- core/runtime.py (new) :: `start_logging`, `stop_logging`, `claim`, `release` · FormTxt had no log file and no lock. The log is `Logs/formtxt-engine.log` in the data folder (1 MB, three older files kept). A second call for the same file adds the handler back to the loggers that lost it. The handler is on `formtxt`, `uvicorn` and `uvicorn.access`; `uvicorn.error` reaches it through `uvicorn`, and with the handler on both each line was written twice (seen).
- formtxt_engine.py :: `started_by`, `watch_shell`, `serve`, `main` · `--selfcheck` is decided first and is unchanged. Serving now goes: the data folder and the log (a folder that cannot be made is one sentence on standard error and exit code 5); `startup.keep_errors` (an absent standard error goes to `Logs/formtxt-engine-errors.log`); a frozen engine started with no app opens the app beside it and returns 0, or says "formtxt-engine is a part of FormTxt and serves nothing on its own" and returns 4, with no lock and no port; the lock `engine.lock` (refused with "formtxt is already running on [folder] (engine process N)." in the log and on standard error, exit code 2); the watch on the app; then the port, the window key line and the server as before. An error that ends the engine is written to the log before it is raised.
- Kept from before: `FORMTXT_PARENT_PID`, the variable the shell of 0.35.0 and older sets. `started_by` reads `FORMTXT_SHELL_PID` first and that one second, for the lock, the watch and the started-alone question, so an engine given only the older variable is not taken for one started alone. Removed: `_alive` and `watch_parent`; `startup.alive` and `startup.watch` take their place. The removed Windows `_alive` opened the process and read its exit code; the family's form waits on the handle with no time, which does not call a finished process alive while something else holds a handle to it.
- The server is `uvicorn.Server(uvicorn.Config(...))` where it was `uvicorn.run(...)`: uvicorn's log setup takes handlers off its loggers when the config is made, so the log is started a second time between the config and the run. A SIGTERM handler set before the run gives the lock up and exits 0: uvicorn shuts down, then raises the signal again, and without the handler the process ended on the signal before the lock was removed (seen: exit -15, lock left). With it: exit 0, lock and `engine.json` gone.
- No older lock exists for FormTxt, so the table's row for a lock left by a released engine has nothing to meet here. An engine of 0.35.0 or older that is still running holds no lock and is not ended by a new one; it leaves by its own watch when its app goes.
- What changes for a second start: two copies of the packaged app on one data folder used to run two engines side by side; the second engine is now refused (exit code 2). Engines started without the entry (`./formtxt`, `uvicorn app.main:app`, the test fixtures) take no lock and are as before. An engine started through the entry with no app (a development run) holds the lock with `shell` 0 and is never ended by another.
- Seen first, on Linux, Python 3.13, engines from source with stand-in shells (`sleep`), scratch scripts not kept: the entry with standard output closed, with output and error closed, and with all three closed answered `/api/health` (descriptors 0, 1 and 2 on the null device; the errors file beside the log in the last two); a second engine with another shell exited 2 with the sentence while the first kept answering, and the log had the refusal; the first exited 0 about a second after its shell was ended and the lock was gone, the same with only `FORMTXT_PARENT_PID`; a holder stopped with SIGSTOP whose shell was gone was replaced after the five seconds (ended by SIGKILL), and one that was running ended on SIGTERM; an engine with no shell holding the lock refused both a second with a shell and one without; locks holding `not json at all`, `[1, 2]`, `{"pid": "x"}` and nothing, and two naming an unrelated `sleep`, were replaced and the `sleep` kept running; a lock with a live process id and no time was obeyed. Started alone (the entry through `python -c` with `sys.frozen` set and `sys.executable` a stand-in path, a stand-in app that writes a mark): the app beside the engine, in the folder above `engine`, in `Contents/MacOS` and in `usr/bin` was opened each time, exit 0, no lock, the port did not answer; with no app near, exit 4 and the sentence; with `FORMTXT_NO_SHELL=1` it served. A data folder under a file: exit 5 and the sentence.
- Tests, added after that: `tests/test_startup.py`, FormTools's file with FormTxt's names (15 tests; the engine tests ask the health route where FormTools's read a port file, and two are added: the older variable, and the second engine refused).
- Not run: Windows and macOS (every Windows line of `startup.py`: `_kernel`, `_open_windows`, `_alive_windows`, `_created_windows`, `_end_windows`, the handle branch of `watch`, and in `open_app` the `SetDllDirectoryW` line and the detached flags), a frozen engine.

## after v0.34.0 · the supported agent programs are named as four (2026-11-19)

- `formtxt` (the launcher's usage text, the `agents` line), `README.md` (the `./formtxt mcp` line under Built for agents), `CLAUDE.md` (the agents kit line), `.claude/skills/formtxt-driving/sub-skills/terminal/SUB-SKILL.md` and `.claude/skills/formtxt-harness/sub-skills/terminal-operator/SUB-SKILL.md` (mirrored to `.agents/skills` by `./formtxt agents sync`) · where the list was Claude Code, Codex and Cursor it is now Claude Code, Codex, Cursor and Antigravity. The harness page's line about `agent_programs.py` also says the programs are found by the family's finder and where an Antigravity tab runs.
Expand Down
2 changes: 1 addition & 1 deletion backend/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.35.0"
__version__ = "0.36.0"
62 changes: 62 additions & 0 deletions backend/app/core/runtime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import json
import logging
import os
from logging.handlers import RotatingFileHandler
from pathlib import Path

from app.core import startup

LOG_NAME = "formtxt-engine.log"
LOG_BYTES = 1_048_576
LOG_KEEP = 3
LOGGERS = ("formtxt", "uvicorn", "uvicorn.access")
FORMAT = "%(asctime)s %(levelname)s %(name)s %(message)s"
HANDLER = "formtxt-file"


def start_logging(data: Path) -> Path:
folder = data / "Logs"
folder.mkdir(parents=True, exist_ok=True)
path = folder / LOG_NAME
for held in logging.getLogger("formtxt").handlers:
if held.get_name() == HANDLER and getattr(held, "baseFilename", "") == os.path.abspath(path):
for name in LOGGERS:
if held not in logging.getLogger(name).handlers:
logging.getLogger(name).addHandler(held)
return path
stop_logging()
handler = RotatingFileHandler(path, maxBytes=LOG_BYTES, backupCount=LOG_KEEP, encoding="utf-8")
handler.setFormatter(logging.Formatter(FORMAT))
handler.set_name(HANDLER)
for name in LOGGERS:
logger = logging.getLogger(name)
logger.addHandler(handler)
if name == "formtxt":
logger.setLevel(logging.INFO)
logging.getLogger("formtxt").info("engine started, pid %s, data folder %s", os.getpid(), data)
return path


def stop_logging() -> None:
for name in LOGGERS:
logger = logging.getLogger(name)
for handler in list(logger.handlers):
if handler.get_name() == HANDLER:
logger.removeHandler(handler)
handler.close()


def claim(data: Path, shell: int) -> Path:
lock, replaced = startup.claim(data, shell)
if replaced:
logging.getLogger("formtxt").warning("an engine left running without its app was stopped (process %s)", replaced)
return lock


def release(data: Path) -> None:
path = data / startup.LOCK_NAME
try:
if int(json.loads(path.read_text(encoding="utf-8")).get("pid", 0)) == os.getpid():
path.unlink()
except (OSError, ValueError, AttributeError, TypeError):
pass
Loading
Loading