Skip to content

An always-on second brain you talk to. Voice notes in Telegram → typed, linked knowledge in your Obsidian vault. Runs 24/7 on the Claude subscription you already have.

fix(dbrain): make `dbrain login` actually restore the brain

smixs248c9a7ee9bc
diff --git a/bin/dbrain b/bin/dbrain
index 4f2af9c..f895b97 100755
--- a/bin/dbrain
+++ b/bin/dbrain
@@ -58,7 +58,18 @@ case "$cmd" in
login)
echo "🔑 Запускаю вход в Claude (нужна подписка)…"
echo "Открой ссылку ниже на телефоне/ноутбуке, подтверди и вставь код сюда:"
- claude setup-token
+ # Pin the config dir to the one the brain runs under (the systemd units set
+ # CLAUDE_CONFIG_DIR=$HOME/.claude), so the new token lands where the
+ # session reads it — not in some other dir the login shell might point to.
+ CLAUDE_CONFIG_DIR="${CLAUDE_CONFIG_DIR:-$HOME/.claude}" claude setup-token
+ # Auth is read only at session START. The live tmux brain holds the old
+ # (logged-out) auth in memory; `dbrain restart` won't help (KillMode=process
+ # keeps the brain alive). Recreate BOTH sessions so the bot rebuilds them
+ # with the fresh login on the next message / cron job.
+ echo "♻️ Пересоздаю сессию, чтобы она подхватила новый вход…"
+ tmux kill-session -t "$BRAIN" 2>/dev/null || true
+ tmux kill-session -t "${BRAIN}_cron" 2>/dev/null || true
+ echo "Готово. Бот поднимет сессию заново при следующем сообщении. Проверь: dbrain status"
;;
*)
echo "Usage: dbrain <status|restart|logs|doctor|clear|attach|repair|login>"