Skip to content

Commit 031a7c2

Browse files
authored
fix: harden workspace trust and land session and terminal behavior (#332)
## Related Issue No public issue. This is maintainer work for session safety, workspace trust, and terminal controls. ## Problem A very large session transcript can crash the local server. A fork drops the source title kind. File tools and git can follow a symlink out of the workspace. Project-local config can apply before the workspace is trusted. The terminal has no setting for the fullscreen layout, no click-to-toggle fold, and no jump-to-bottom control. ## What changed ```text open large transcript - push every parsed record in one call + append records one by one fork session - default title kind is replaceable + default title kind comes from the source write or git path - use the path as given + resolve the real path and reject a target outside the workspace project-local config - apply on load + apply only after the workspace is trusted terminal + tui_mode regular | fullscreen + click one fold to toggle it + jump to bottom when scrolled up ``` Also in this change: - `auto_session_title` can turn automatic titles off. - `PYTHINKER_CODE_REPEAT_BREAKER=0` turns off the repeated-tool-call stop. - MCP sign-in asks for offline access only when the server advertises it. - The browser extension skill resends a failed command as a file and can move the daemon off a busy port. - A failed telemetry flush no longer blocks exit. Telemetry hosts are unchanged. - Tower reviews name the next step after a verdict. - Dynamic workflow members are restored from persisted lifecycle events. Hosted banner targeting and login-region relay selection are not in this change. ## Evidence - **Before:** a cold read of a large wire file used a spread push that can overflow the stack. **After:** package `tsc` is clean for agent-core-v2, agent-gateway, transcript, oauth, telemetry, and the CLI. Focused tests: 141 passed (fold, MCP OAuth, repeat breaker, git hardening, real path). Write-tool tests passed. Tower identity fallback passed after the test forces `user.useConfigOnly`. - Full `pnpm test`, `pnpm lint`, `pnpm build`, and `nix build` were not run on this branch. ## Merge Danger **Door:** two-way Revert the branch. No published version or identity field changes. **Blast Radius:** session Workspace trust, file tools, git calls, session fork titles, and the terminal layout are the user-visible surfaces. A wrong trust gate can hide project-local config until the user trusts the folder. ## Checklist - [ ] I have read the [CONTRIBUTING](https://github.com/PyModel/pythinker-code/blob/main/CONTRIBUTING.md) document. - [ ] I have linked a related issue (external PRs: the issue must have a maintainer's `/approve`). Internal maintainer change; no public issue. - [x] I have added tests that prove my feature works. - [x] Ran `gen-changesets` skill, or this PR needs no changeset. - [ ] Ran `gen-docs` skill, or this PR needs no doc update. Config and env docs were updated in the same change. The `gen-docs` skill was not run as a separate pass. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Choose regular or fullscreen terminal layouts in settings; changes take effect after restarting. * Expand and collapse transcript details by clicking supported cards, and jump to the bottom of a scrolled transcript. * Configure automatic session titles and repeated-tool-call stopping behavior. * View elapsed time in task updates and tool results. * Browser extension recovery guidance now covers failed commands and busy daemon ports. * **Bug Fixes** * Improved handling of very large transcripts and session forks. * File operations now block symlinks that escape the workspace; project-local settings are gated by workspace trust. * MCP sign-in better handles offline access, and failed telemetry shutdown no longer disrupts normal exit. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent ea4bdd6 commit 031a7c2

215 files changed

Lines changed: 6494 additions & 815 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/review-pr/SKILL.md‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
name: review-pr
3+
description: Use when reviewing a pull request in the pythinker-code repository — evaluate the change against the template structure.
4+
disable-model-invocation: true
5+
---
6+
7+
# Review PR
8+
9+
Review a pull request by evaluating the description against the template and the actual diff, then write a structured review summary in English.
10+
11+
## Workflow
12+
13+
1. Fetch the PR description and metadata:
14+
15+
```bash
16+
gh pr view <number> --json title,body,url,files,additions,deletions,baseRefName,headRefName
17+
```
18+
19+
2. Read the full diff:
20+
21+
```bash
22+
gh pr diff <number>
23+
```
24+
25+
3. Read enough surrounding code to verify the claims in the PR description.
26+
27+
4. Evaluate each section against the criteria below.
28+
29+
5. Write the review summary in English.
30+
31+
## Review Criteria
32+
33+
### Requirement or Bug
34+
35+
- Is the linked issue valid and relevant?
36+
- If no issue, is the requirement clearly stated in one or two sentences?
37+
38+
### Bug Reproduction Steps
39+
40+
- For bug PRs: are the steps clear and reproducible?
41+
- Can you follow the steps to confirm the bug exists on the base branch?
42+
43+
### Root Cause
44+
45+
- For bug PRs: is the root cause convincingly explained?
46+
- Does the stated root cause match what you see in the diff?
47+
- Is it clear whether this is a fundamental fix or a workaround?
48+
49+
### Code Changes
50+
51+
- Does the description match the actual diff?
52+
- Are visual outlines (diff blocks, call trees, file trees) accurate and helpful?
53+
- Is the approach sound? Are there simpler alternatives?
54+
- Are there edge cases the author missed?
55+
56+
### Impact Scope
57+
58+
- Are all affected modules identified? Cross-check with the diff file list.
59+
- Does test coverage match the claimed scope?
60+
- Are there untested paths that carry risk?
61+
62+
### Checklist
63+
64+
- Are all applicable items checked?
65+
- For items marked as "not needed", do you agree?
66+
67+
## Output
68+
69+
Write the review summary in English. For each section:
70+
71+
- State whether it is adequately filled in.
72+
- Flag anything missing, inaccurate, or inconsistent with the diff.
73+
- If the PR is ready, say so. If changes are needed, list them as actionable items.

‎.agents/skills/write-pr/SKILL.md‎

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
name: write-pr
3+
description: Use when creating a pull request in the pythinker-code repository — how to fill in each section of the PR template with concise, reviewer-friendly content.
4+
---
5+
6+
# Write PR Description
7+
8+
Create or update the pull request for the current branch with a description that helps the reviewer understand why the change exists and the shape of the implementation.
9+
10+
## Workflow
11+
12+
1. Read the PR template:
13+
14+
`Read(.github/pull_request_template.md)`
15+
16+
2. Identify or create the pull request:
17+
- Check the current branch for an existing PR: `gh pr view --json url,number,title,state 2>/dev/null`.
18+
- If no PR exists, inspect `git status --short --branch` and the commits on the current branch.
19+
- Commit remaining changes, push the branch with an upstream, and create the PR with `gh pr create`.
20+
- Follow the repository's git safety protocol.
21+
22+
3. Gather the context needed to explain the change:
23+
- Read the linked issue and any relevant task artifacts.
24+
- Read the complete diff (`git diff main...HEAD`) and enough surrounding code to understand behavior and ownership.
25+
- Use `gh pr view` to collect PR metadata and changed files if the PR already exists.
26+
27+
4. Write the PR description following the template sections:
28+
- **Requirement or Bug** — one sentence or `Resolve #<number>`. Nothing more.
29+
- **Bug Reproduction Steps** — bug PRs only; `N/A` for features. Write `See linked issue` when steps are already there.
30+
- **Root Cause** — bug PRs only; `N/A` for features. State the cause and whether this is a fundamental fix or a workaround.
31+
- **Code Changes** — use visual outline views (see below) instead of prose whenever they explain the change better.
32+
- **Impact Scope** — list affected modules and test coverage.
33+
- **Checklist** — check every box that applies.
34+
35+
5. Publish the description:
36+
- Save to a temp file, then `gh pr edit <number> --body-file <path>` or `gh pr create --body-file <path>`.
37+
- Confirm the update succeeded.
38+
39+
## Visual Outline for Code Changes
40+
41+
Prefer structural views over prose. Use the smallest combination that explains the implementation. Omit categories that did not change.
42+
43+
Show logic or algorithm changes as pseudocode diff:
44+
45+
```diff
46+
on(save)
47+
- write content
48+
+ if content is unchanged
49+
+ return cached result
50+
+ write new content
51+
+ invalidate cache
52+
```
53+
54+
Show runtime control flow as a call tree diff:
55+
56+
```diff
57+
submitForm
58+
createSession
59+
persistPrompt
60+
+ expandSkillMention
61+
launchAgent
62+
- navigateToSession
63+
+ navigateToSession
64+
+ subscribeToEvents
65+
```
66+
67+
Show file responsibility changes as a shallow file tree diff:
68+
69+
```diff
70+
src/
71+
├── commands/
72+
+│ └── show-me.ts # expands the slash command
73+
├── sessions/
74+
-└── transport.ts
75+
+└── transport/
76+
+ ├── client.ts
77+
+ └── stream.ts
78+
```
79+
80+
Show component or UI structure changes as a tree diff:
81+
82+
```diff
83+
<SessionPage>
84+
useSessionEvents()
85+
<SessionToolbar>
86+
+ <RunSkillButton />
87+
<SessionTimeline>
88+
+ <SkillResultCard />
89+
```
90+
91+
Show component interaction, control flow, or data flow with Mermaid (especially useful for explaining bug mechanics):
92+
93+
```mermaid
94+
sequenceDiagram
95+
participant User
96+
participant UI
97+
participant Daemon
98+
User->>UI: choose command
99+
UI->>Daemon: send expanded prompt
100+
Daemon-->>UI: stream result
101+
```
102+
103+
Show key data structure or type changes in a language-specific block:
104+
105+
```ts
106+
interface SessionEvents {
107+
onTurnStart(cb: (turn: Turn) => void): void;
108+
onTurnEnd(cb: (turn: Turn) => void): void;
109+
}
110+
```
111+
112+
Rules for visual outlines:
113+
- Use `diff` blocks when the point is what changes and the surrounding shape already exists.
114+
- Show the complete target shape in a language-specific or `text` block when most of it is new or diff notation would obscure ownership or order.
115+
- Tell the story in the order that makes it easiest to understand — files first, or data structures first, whichever fits.
116+
- Write as one human talking to another: simple, coherent, concise language.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pymodel/pythinker-code": patch
3+
---
4+
5+
Add `auto_session_title` so automatic session titles can be turned off.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pymodel/pythinker-code": patch
3+
---
4+
5+
The browser extension skill resends a failed command as a file and can move the local daemon off a busy port.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pymodel/pythinker-code": patch
3+
---
4+
5+
A forked session keeps the source title kind when you do not set a new title.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pymodel/pythinker-code": patch
3+
---
4+
5+
Fix a crash when opening a session with a very large transcript.

‎.changeset/mcp-offline-access.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pymodel/pythinker-code": patch
3+
---
4+
5+
MCP sign-in requests offline access when the authorization server advertises it.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pymodel/pythinker-code": patch
3+
---
4+
5+
Set `PYTHINKER_CODE_REPEAT_BREAKER=0` to turn off the repeated-tool-call stop.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pymodel/pythinker-code": patch
3+
---
4+
5+
Click a transcript fold to open or close that block, and jump to the bottom when the transcript is scrolled up.

‎.changeset/tui-mode-setting.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pymodel/pythinker-code": patch
3+
---
4+
5+
Choose a regular or fullscreen terminal layout with `tui_mode`.

0 commit comments

Comments
 (0)