76 Commits
Author SHA1 Message Date
NanamiAdmin c7642ecca5 feat(settings): report which saved keys need a restart
Build / ubuntu-latest (push) Failing after 52s
Build / windows-latest (push) Failing after 41m49s
Every settings update answered with a bare success, so the console could not
tell a change that took effect at once from one written to the file that the
running program would keep ignoring until it was restarted — the listener
address, the storage paths, the Komari dashboard URL.

Classify the patch instead. config.RestartRequiredKeys expands a patch into the
dot-separated paths of its leaves and intersects them with the settings main
reads before it starts serving, and the settings endpoint returns that list as
data.restartRequired. It is a pure function of the patch, so UpdateSettings
keeps its signature and nothing else has to change; the write succeeds either
way, and the field only says which edits are not live.

Matching is by overlap rather than equality, so a patch that names a section —
replacing it, or deleting it with a null — reports the startup-only keys inside
it, while a sibling subtree like webhook.endpoints is not mistaken for
webhook.enabled.

The result is never nil, so an update with nothing to report serializes as []
rather than null and a client can iterate it without a guard.

The console reads the field in ConfigSection and warns instead of confirming,
naming the keys that are pending; Settings.vue's hints for the Komari URL, the
listen address and the storage paths now say which of their fields is affected
rather than labelling the whole card.
2026-09-28 23:28:47 +08:00
NanamiAdmin 457ea42417 fix(netproxy): resolve the proxy address per request
Build / ubuntu-latest (push) Failing after 3m3s
Build / windows-latest (push) Canceled after 3m19s
ProxyFunc parsed system.networkProxy once, when a client was built, and baked
the result into the transport. Editing the proxy address therefore had no effect
on any client that already existed: ntfy, the outgoing webhook, NapCat's HTTP
API, Telegram's polling and the NapCat WebSocket dialer all kept the address
they were built with, and Email's SMTP dialer did the same. Only a controller
rebuild would pick up a new one, and that fires only when controllerMethod
changes — so the address was effectively fixed until a restart.

Resolve it inside the returned function instead. A transport proxy function that
returns a nil URL asks for a direct connection, so this also covers clearing the
setting: a channel built while a proxy was configured now falls back to dialing
directly rather than retrying a dead address.

Opting out is now the only case where ProxyFunc returns nil. That is deliberate:
a function resolved to nothing at construction time is exactly what pinned the
address in the first place.

DialWithTimeout reads the address per dial for the same reason, which is what
lets the gomail NetDialTimeout hook follow a settings change.
2026-09-28 23:25:13 +08:00
NanamiAdmin 7dc6089871 docs(readme): correct how system.networkProxy takes effect
Build / ubuntu-latest (push) Canceled after 3m11s
Build / windows-latest (push) Canceled after 3m23s
The rebuild only fires when the controllerMethod section changed, so editing
networkProxy on its own does not rebuild anything and the channels keep the
proxy they connected with. The previous wording read as though a rebuild would
follow on its own.
2026-09-28 23:22:07 +08:00
NanamiAdmin 2a5a46a984 refactor(controller): apply controller settings by rebuilding the channel set
Build / ubuntu-latest (push) Canceled after 20s
Build / windows-latest (push) Canceled after 24s
Giving each controller a Reload method worked for the notification pipes, which
only hold values, but not for the two bot channels: the NapCat client is stopped
through a sync.Once and the Telegram polling context is created with the
controller, so neither can be re-pointed once running. It also meant five
bespoke implementations of the same idea.

Replace the whole set instead. Manager.ReplaceAll swaps in a freshly built set
under the registry lock, stops the outgoing controllers outside it, and starts
the incoming ones off the calling goroutine so a slow handshake does not hold
the settings request open. ReplaceAll is now the only way controllers are
installed: Register is gone, because a lone registration would slip a controller
in without recording the settings it was built from, which is what NeedsRebuild
compares against.

The rebuild runs from the reload hook and only fires when the controllerMethod
section actually changed, so saving a message template or a webhook endpoint
leaves the channels alone. NeedsRebuild compares the whole section by value, and
a test pins that reloading a file reproduces it exactly — a default applied
inconsistently would make every save look like a controller change and tear down
every channel.

With controllers immutable after construction and replaced wholesale, the atomic
pointers and Reload methods have no writers left, so they are gone and the pipes
return to plain fields. notifyReload now serializes hook execution for the same
reason: a hook mutates process-wide state, and two overlapping settings updates
would otherwise each decide to rebuild from their own view of what was applied.

Kept from that work: applyEmailProxy restores gomail's default dialer when
networkUseProxy is turned off. The old constructor only ever installed the proxy
dialer, so switching the flag back left SMTP tunnelled through a proxy with no
way to undo it short of a restart.

Documents the resulting behaviour in the README under "What applies without a
restart".
2026-09-28 23:21:35 +08:00
NanamiAdmin 0691e85ccf feat(controller): hot-reload the notification pipes
Build / ubuntu-latest (push) Failing after 3m13s
Build / windows-latest (push) Canceled after 6m23s
Email, ntfy and webhook kept their settings in a plain struct field copied at
construction, so editing controllerMethod in config.json wrote the file and
replaced the in-memory configuration while the running channels stayed on their
boot values.

Add Reload to the Controller interface and implement it for the three
notification pipes; Manager.ReloadAll fans an update out to every registered
controller and is wired into the reload hook from main.

Reload runs on the goroutine serving the settings update while the send methods
run on the status-change and incoming-webhook goroutines, so storing the new
settings in a plain field would be a data race. Each pipe publishes its settings
— and the HTTP client derived from them — through atomic pointers, and every
send takes one snapshot so a reload landing mid-send cannot split it across two
configurations.

Only a change to networkUseProxy rebuilds the client; everything else is read
from the settings at send time, so a reload that changes nothing relevant leaves
the client alone. Email needed one more fix: gomail exposes its dial hook as a
package-level variable with no unset, and the constructor only installed the
proxy dialer when the flag was set, so turning networkUseProxy off left SMTP
tunnelled through a proxy. applyEmailProxy now restores net.DialTimeout, which
is gomail's own default.

QQ (Napcat) and Telegram implement Reload because the interface requires it, but
neither can apply a change in place: the NapCat client is stopped through a
sync.Once and the Telegram polling context is created with the controller, so
both need to be rebuilt and swapped into the manager. Rather than no-op silently
and let an edit look applied, they log a warning while their settings diverge.
That rebuild is the next step.
2026-09-28 23:15:11 +08:00
NanamiAdmin d9a9918e21 feat(config): notify reload hooks after a settings update
Build / ubuntu-latest (push) Failing after 3m8s
Build / windows-latest (push) Canceled after 4m3s
A settings update replaced the in-memory configuration but nothing told the code
that derives state from it. The logger is the first such consumer: its debug
flag is captured once at startup by postLog.SetDebugMode, so toggling
system.debugMode at runtime changed what config.IsDebugMode() reported while
DEBUG lines stayed filtered by the value from boot.

Add a hook registry to the config package. OnReload registers a callback and
every writer of config.json runs the registered hooks with the configuration now
in effect. It lives in config so packages that already depend on it (the logger,
and later the controller manager) can react without config importing them back,
which would be an import cycle.

Hooks run after settingsLock is released, not inside it. They will rebuild
controllers once those support reloading, which can wait on a network call, and
settingsLock is also held by the node tracker's background save — running a hook
under the lock would stall node registration behind a settings edit.
runSettingsUpdate now owns that lock/notify sequence for all four writer paths
(UpdateSettings and the three webhook endpoint helpers).

A panicking hook is logged and skipped: by then the new configuration is on disk
and published, so reporting the write as failed would be a lie, and the hooks
registered after the broken one still need to run.
2026-09-28 23:10:33 +08:00
NanamiAdmin ac5587d0c8 fix(handler): read the data envelope in the server endpoint tests
Build / windows-latest (push) Failing after 1m49s
Build / ubuntu-latest (push) Failing after 5m45s
TestServerGetInfoAll, TestServerGetInfoSingleAndMissing and
TestServerGetStatusAll indexed the decoded response by uuid at the top level,
but utils.SendSuccessResponse wraps the payload as {success, message?, data:{...}}
— the shape the console reads as response.data[uuid] (frontend/src/api/index.js).
The uuid lookups therefore always missed, and unmarshalling the nil raw message
surfaced as "unexpected end of JSON input".

decodeResponse now decodes the envelope, asserts it is a success carrying a data
object, and returns that object. The handlers are unchanged: they already return
the documented shape.
2026-09-28 23:03:45 +08:00
NanamiAdminandClaude Code 2524e40566 test(config): restore settings tests with fixture IDs redacted
config/settings_test.go was removed from the whole history because its fixtures
used a real QQ number and group ID. This adds the file back as a new commit
whose fixtures are placeholder IDs, so the deep-merge, null-delete, array-replace
and settings-type validation coverage is kept without the identifiers.

The file has no history before this commit by design: the old blobs are gone
from every ref, and the working copy has been rebuilt from the redacted
version.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-09-28 22:49:54 +08:00
NanamiAdminandClaude Code 5167d799bc chore(gitignore): narrow the test-file ignore rule to the repo root
`*test.go` matched every test file at any depth, which kept the real suite out
of version control along with the scratch files it was meant to catch. Anchor
the pattern to the repository root so ad-hoc test files dropped there stay
untracked while the tests that live next to the code they cover are tracked.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-09-28 22:47:42 +08:00
NanamiAdminandClaude Code cb2df5076d refactor(config): publish config singletons through atomic pointers
The three configuration singletons (C_globalConfig, C_botUserConfig,
C_botNodeConfig) were plain variables: LoadGlobalConfig and friends assigned
them from the goroutine handling a settings update, while bot pipes, the node
tracker and the HTTP handlers read them from their own goroutines. That is an
unsynchronized read of a concurrently written variable — a data race the race
detector reports, and one that already existed before any hot-reload work
because /api/webhook/add reloads the configuration while the bots run.

Replace them with atomic.Pointer values behind Current(), BotUsers() and
BotNodes(). Each reload builds a fresh value and publishes it atomically, so a
reader either sees the previous configuration or the new one, never a partial
one. Callers read through the accessor on every use instead of caching it.

Two spots that read several fields of one guard now snapshot once per call, so
a reload cannot split a combined check mid-flight:
- qq_napcat.handleNapcatEvent, which evaluates the debug guards per event
- the komari task-echo guard, now behind taskEchoEnabled()

The NapCat HTTP methods keep logging on showNapcatAction alone (without
requiring debugMode), matching their existing behaviour; that inconsistency
with the WebSocket path is preserved, not introduced, and is called out in
actionLogEnabled.

Also adds TestConcurrentReloadAndRead, which drives every accessor from four
reader goroutines while two writers reload the configuration, and sanitises the
member IDs used as test fixtures in config/settings_test.go.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-09-28 22:47:37 +08:00
NanamiAdmin 2d5cf39151 fix(changelog): update version format to include commit hash for pre-release 2026-09-24 15:32:36 +08:00
NanamiAdmin 05dcc3769d feat(changelog): add webhook API settings and configuration feature 2026-09-24 15:03:57 +08:00
NanamiAdmin f36f17bd2a feat(frontend): enhance webhook functionality and UI
- Updated incoming webhook API endpoint to use `/api/webhook/post/<name>` for better namespace management.
- Added a new WebHooks page in the admin UI for managing webhook endpoints.
- Introduced a ConfigSection component to streamline the rendering and saving of configuration fields.
- Enhanced Settings.vue to reference the new WebHooks page and updated the configuration structure.
- Implemented a new webhook API in the frontend to handle listing, adding, modifying, and removing webhook endpoints.
- Improved the sidebar to include a link to the WebHooks page.
- Added functionality to generate tokens for new webhook endpoints and manage notification channels.
2026-09-24 15:02:52 +08:00
NanamiAdmin 3877c6d128 feat(webhook): implement management API for incoming webhook endpoints 2026-09-24 12:32:22 +08:00
NanamiAdmin 3ce42b3cca docs(changelog): add incoming webhook API feature to version 0.2.0.5 2026-09-24 11:24:13 +08:00
NanamiAdmin 057d7d584d feat: add incoming webhook API support with configurable endpoints
- Implemented the incoming webhook API to handle alerts from external applications.
- Added configuration options for webhook listening address, port, and endpoints in config.go.
- Created WebhookReceiverConfig and WebhookEndpointConfig structures to manage webhook settings.
- Developed WebhookHandler to process incoming requests, validate tokens, and deliver alerts to specified channels.
- Enhanced existing controller interfaces to support alert delivery.
- Updated message rendering to respect Markdown settings for different channels.
- Added tests for webhook functionality and ensured proper error handling.
2026-09-24 11:21:38 +08:00
NanamiAdmin 90ca08066b feat(release): update version to 0.2.0 and enhance changelog with new features 2026-09-23 11:22:46 +08:00
NanamiAdmin d481f13d1d feat(auth): implement WebSocket authentication for admin access to logs 2026-09-23 11:20:52 +08:00
NanamiAdmin 7ecf51eba5 docs(changelog): add Ver.0.1.2.4-59c0f5d.pre-release change log 2026-09-23 11:01:47 +08:00
NanamiAdmin 59c0f5d5d8 fix(variables): update version and build number in SoftwareInfo 2026-09-22 22:58:43 +08:00
NanamiAdmin 16455027ec fix(changelog): add missing URL for frontend build integration entry 2026-09-22 22:57:30 +08:00
NanamiAdmin 4be6d2add0 feat(build): integrate frontend build into backend binary and update scripts 2026-09-22 22:57:08 +08:00
NanamiAdmin 15144fb9d4 docs(changelog): add initial changelog entries for version 0.1.2.3 2026-09-22 22:11:04 +08:00
NanamiAdmin a89ad8143a fix(build): correct build script paths for Windows and Linux 2026-09-22 21:00:15 +08:00
NanamiAdmin fb5b46a548 chore(go.mod): update Go version to 1.27.1 2026-09-22 20:59:46 +08:00
NanamiAdmin f6092cd178 docs(readme): add frontend development instructions and update requirements 2026-09-10 21:02:43 +08:00
NanamiAdmin 3cba5df5c7 docs(readme): update build instructions 2026-09-10 21:01:13 +08:00
NanamiAdmin b2566d45f8 feat(build): add scripts for building frontend and backend for Linux and Windows 2026-09-10 20:59:21 +08:00
NanamiAdmin 8b88377d4f chore(web): directly read frontend/dist folder but not read it from web folder 2026-09-10 20:51:11 +08:00
NanamiAdmin f6af57cf58 feat(web): add static file serving for the frontend 2026-09-10 20:43:46 +08:00
NanamiAdmin 160918a93e fix(frontend): adjust the first node card height to avoid higher a little then others 2026-09-10 20:15:26 +08:00
NanamiAdmin f622baadbd fix(frontend/settings): fix json marshal fault, now the settings page could be loaded correctly 2026-09-10 20:12:21 +08:00
NanamiAdmin 78284ed816 feat(frontend): add debugMode global variable to store debug mode state 2026-09-10 19:36:29 +08:00
NanamiAdmin d96b90b5bf feat: update API response structure to nest payloads under a single "data" key 2026-09-09 16:15:33 +08:00
NanamiAdmin c0eada9bcc remove claude skills file 2026-09-08 23:18:31 +08:00
NanamiAdmin 378727ac57 feat(frontend): implement basic frontend interface 2026-09-08 23:15:50 +08:00
NanamiAdmin 8b43e8b2ea feat(config): make resolver support null value to delete a
key.
2026-09-08 23:10:26 +08:00
NanamiAdmin 786f364743 feat(user): implement registration for the first user with concurrency handling 2026-09-08 22:53:02 +08:00
NanamiAdmin a0e2df615c feat: add /api/server/getInfo to handle frontend get server info.
chore: rebuild `/api/server/getStatus` to the same logic as `getInfo`.
2026-09-08 22:28:49 +08:00
NanamiAdmin 4eb9abff49 feat: add /api/settings/get, /api/settings/set to modify config in frontend 2026-09-08 22:13:30 +08:00
NanamiAdmin 15f1ee38db feat(variables): update software version to 0.1.1 and change build type to pre-release 2026-09-06 22:05:56 +08:00
NanamiAdmin ec1cf20347 feat(config): implement loading and saving of bot node configuration with default notification settings 2026-09-06 14:00:45 +08:00
NanamiAdmin 6a0c2d1fc4 feat(controller): add per-node notify switch controller 2026-09-06 10:48:38 +08:00
NanamiAdmin 5bc85effa7 feat(komari): add bot_node_config.json to restore single node configurarion 2026-09-06 10:33:58 +08:00
NanamiAdmin 13a670eadd style(config): add structured config paths for global and bot configurations 2026-09-06 10:19:28 +08:00
NanamiAdmin 0cedb51e50 doc(readme): update readme to justify latest codebase 2026-09-03 15:34:32 +08:00
NanamiAdmin 6c819f8c52 feat(controller): enhance message handling and user options for automatic notifications 2026-09-03 11:57:20 +08:00
NanamiAdmin 2a1f5e11f8 feat(controller): update notification logic to respect event_status_notify settings for trusted groups and admins 2026-09-02 21:35:07 +08:00
NanamiAdmin 16341972af style: replace GetConfig() with variable C_globalConfig 2026-09-02 21:24:27 +08:00
NanamiAdmin bf4cdf0d88 chore(config): move admins && trustedGroups to a new config bot_user_config.json.
feat(config): add load bot_user_config endpoint
style(config): rename `LoadConfig` to `LoadGlobalConfig`.
2026-09-02 21:19:50 +08:00
NanamiAdmin 0b7fcd6c48 chore(telegram): rebuild telegram module with go-telegram/bot
fix(telegram): fix bot cannot send message in groups
2026-09-02 20:47:25 +08:00
NanamiAdmin 935ea24d54 feat(controller): enhance command handlers to accept source parameter for improved message formatting 2026-08-19 20:02:18 +08:00
NanamiAdmin 5689c942d2 feat(controller): add /getip command to retrieve server IP information 2026-08-19 14:39:41 +08:00
NanamiAdmin bd2bccd8ef feat(komari): update FetchNodes to use JSON-RPC2 for node retrieval 2026-08-19 14:21:25 +08:00
NanamiAdmin f2cc16177c feat(controller): add source for command handling.
feat(telegram): switch message type to markdown
feat(controller): add welcome message for telegram bot.
2026-08-13 17:07:55 +08:00
NanamiAdmin 8589654ba4 feat(internal/controller/pipes/telegram): make basic telegram communication functional 2026-08-12 23:57:16 +08:00
NanamiAdmin 56cc3485a7 feat(netproxy): add network proxy module to provide unified network proxy connection.
feat(internal/controller): make email, ntft, webhook, qq_napcat able to use network proxy.
2026-08-12 22:53:23 +08:00
NanamiAdmin 105fa47811 feat(debug): make komari task echo log to debug level and selectable
feat(internal/controller/qq_napcat): add trigger log display and detailed to chatID and senderID
2026-08-12 22:29:57 +08:00
NanamiAdmin 8cd7cfd6e7 feat(controller): add help command with message template for bot commands 2026-08-07 22:39:57 +08:00
NanamiAdmin ebbbe7ba1d feat(node): add Info structure to save every nodes system information
feat(processor): add /info <uuid> command to show basic system info for specific node
2026-08-07 22:31:02 +08:00
NanamiAdmin 56ed32ac0c feat(controller): add init message for bot pipes
chore: move softwareInfo from main package to a individual global package
2026-08-07 22:13:15 +08:00
NanamiAdmin d8a192e4e5 feat(build): add build scripts for Linux and Windows with commit hash and build time 2026-08-07 20:45:05 +08:00
NanamiAdmin fcb0751267 refactor(internal/komari/ws): streamline status request logic and enhance read loop handling
refactor(internal/node/tracker): improve initial refresh gating and snapshot handling
2026-08-07 18:33:34 +08:00
NanamiAdmin 58b600baf6 feat(node/tracker): implement initial refresh gate and bootstrap completion logic 2026-08-07 18:03:16 +08:00
NanamiAdmin f342ef5b34 fix(internal/controller/pipes/qq_napcat): remove debug msg echo, now it can process commands 2026-08-06 18:52:36 +08:00
NanamiAdmin 30ed0bd9ec chore(internal/controller): split command processor from pipes as an individual module 2026-08-06 17:53:53 +08:00
NanamiAdmin 10c3727b01 feat(internal/controller): split trigger from controller.go as a seperate module.
feat(internal/controller/pipes/qq_napcat): add message receive debug output.
2026-08-06 17:17:01 +08:00
NanamiAdmin 1d09765a4a chore(qq_napcat): rewrite all napcat_bridge logic into this project to replace adapt into napcat_bridge 2026-08-05 17:07:29 +08:00
NanamiAdmin dc30675e0f style(controller): re-organize controller project structure: split controller and pipes 2026-08-05 14:27:22 +08:00
NanamiAdmin 6e93a9bd2f fix(internal\komari\ws): add websocket origin header to prevent 403; replace with json-rpc 2.0. 2026-08-05 14:12:16 +08:00
NanamiAdmin 814fbe0dae fix(database): fix sqlite init error in smb workspace
fix(postLog/database): change journal mode from WAL to DELETE
2026-08-05 13:31:25 +08:00
NanamiAdmin c25b267334 fix: resolve merge conflict in README.md 2026-08-03 22:18:00 +08:00
NanamiAdmin 86a6736a48 Merge branch 'main' of https://gitea.nanami.tech/Nukumizu/numumizu-backend 2026-08-03 22:17:11 +08:00
NanamiAdmin 19b69acc29 feat: finish project basic structure and core functions 2026-08-03 22:15:53 +08:00
NanamiAdmin b3a5a5bad1 Update README.md 2026-08-03 13:40:17 +08:00
NanamiAdmin 3ab175b595 Initial commit 2026-08-03 13:39:23 +08:00