feat(telegram): make /ctx work everywhere (#159)

This commit is contained in:
banteg
2026-01-17 01:17:50 +04:00
committed by GitHub
parent b215279a3c
commit 419ec5078b
13 changed files with 390 additions and 20 deletions
+2
View File
@@ -70,6 +70,8 @@ Takopi will bind the topic and rename it to match the context.
- `/ctx set <project> @branch` updates it
- `/ctx clear` removes it
Note: Outside topics (private chats or main group chats), `/ctx` binds the chat context instead of a topic.
## Reset a topic session
Use `/new` inside the topic to clear stored sessions for that thread.
+9 -3
View File
@@ -42,11 +42,17 @@ This line is parsed from replies and takes precedence over new directives.
| `/file put <path>` | Upload a document into the repo/worktree (requires file transfer enabled). |
| `/file get <path>` | Fetch a file or directory back into Telegram. |
| `/topic <project> @branch` | Create/bind a topic (topics enabled). |
| `/ctx` | Show topic context binding (topics enabled). |
| `/ctx set <project> @branch` | Update topic context binding. |
| `/ctx clear` | Remove topic context binding. |
| `/ctx` | Show context binding (chat or topic). |
| `/ctx set <project> @branch` | Update context binding. |
| `/ctx clear` | Remove context binding. |
| `/new` | Clear stored sessions for the current scope (topic/chat). |
Notes:
- Outside topics, `/ctx` binds the chat context.
- In topics, `/ctx` binds the topic context.
- `/new` clears sessions but does **not** clear a bound context.
## CLI
Takopis CLI is an auto-router by default; engine subcommands override the default engine.
+3
View File
@@ -119,6 +119,9 @@ When a message arrives in a chat whose `chat_id` matches `projects.<alias>.chat_
Takopi defaults the project context to that alias unless a reply `ctx:` or explicit
`/project` directive is present.
In non-topic chats, `/ctx` can bind a chat context. That bound context is treated as
ambient and takes precedence over the default project mapping until cleared.
## Worktree resolution
When `@branch` is present:
+2 -2
View File
@@ -204,8 +204,8 @@ Commands:
- `projects`: `/topic @branch` creates a topic in the project chat and binds it.
- `all`: use `/topic <project> @branch` in the main chat, or `/topic @branch` in
project chats.
- `/ctx` inside a topic shows the bound context and stored session engines.
`/ctx set ...` and `/ctx clear` update the binding.
- `/ctx` shows the bound context and stored session engines inside topics.
Outside topics, `/ctx set ...` and `/ctx clear` bind the chat context.
- `/new` inside a topic clears stored resume tokens for that topic.
State is stored in `telegram_topics_state.json` alongside the config file.
+8 -1
View File
@@ -31,6 +31,13 @@ Takopi treats the second message as a continuation. If you want a clean slate, u
!!! user "You"
/new
To pin a project or branch for the chat, use:
!!! user "You"
/ctx set <project> [@branch]
`/new` clears the session but keeps the bound context.
Tip: set a default agent for this chat with `/agent set claude`.
## Stateless (reply-to-continue)
@@ -81,7 +88,7 @@ takopi --onboard
## Resume lines in chat mode
If you enable chat mode (or topics), Takopi can auto-resume, so you can hide resume lines for a cleaner chat.
Resume lines are still shown when no project context is set, so replies can branch there.
Disable them if you want a fully clean footer, or enable `show_resume_line` to keep reply-branching visible.
If you prefer always-visible resume lines, set: