Skip to content

docs: map types and I/O data interfaces for issue #441 - #478

Merged
tunahorse merged 4 commits into
masterfrom
claude/old-issues-review-axg9qv
Jul 11, 2026
Merged

docs: map types and I/O data interfaces for issue #441#478
tunahorse merged 4 commits into
masterfrom
claude/old-issues-review-axg9qv

Conversation

@tunahorse

@tunahorse tunahorse commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Field-level trace of the five data boundaries (tool args, session
persistence, agent messages, runtime state, UI display shapes), the
concrete shapes flowing through each Any annotation, dead-code
inventory, and the target type design. Includes an HTML visualization
of the same map.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01U3DHf5FbGZiDLMSWpq53gK

Summary

  • Simplified session state by removing obsolete recursive-execution, task hierarchy, input-session, spinner, and undo fields and APIs; retained session persistence and core runtime state.
  • Removed unused messaging conversion helpers, ripgrep execution/metrics utilities, runtime streaming-panel state, and stale type re-exports.
  • Added per-tool TypedDict schemas and narrowed tool-call, renderer, and UI panel arguments from generic dictionaries to ToolArgs and tool-specific types.
  • Updated clear/reset behavior to reset context-panel state and per-call usage without discarding accumulated session usage.
  • Removed recursive-state exception/reset paths and corresponding protocol contracts, reducing dead state-management surface area.
  • Documented the project’s data boundaries and concrete shapes flowing through tool arguments, session persistence, agent messages, runtime state, and UI display data.

Validation

  • mypy passes cleanly.
  • 324 tests pass.

claude added 4 commits July 11, 2026 15:31
Field-level trace of the five data boundaries (tool args, session
persistence, agent messages, runtime state, UI display shapes), the
concrete shapes flowing through each Any annotation, dead-code
inventory, and the target type design. Includes an HTML visualization
of the same map.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U3DHf5FbGZiDLMSWpq53gK
Removes symbols with zero callers, verified by trace (see
docs/architecture/types-and-io-interfaces.md):

- types/base.py: AgentConfig, ErrorContext, UpdateOperation, Validator,
  ValidationResult, CommandResult, CommandArgs, InputSessions, FileDiff,
  DiffHunk, DiffLine dead aliases
- types/callbacks.py: UICallback, UIInputCallback, AsyncFunc,
  AsyncToolFunc, AsyncVoidFunc dead aliases
- utils/messaging/adapter.py: to_canonical_list, from_canonical,
  from_canonical_list (zero call sites)
- tools/utils/ripgrep.py: RipgrepExecutor and RipgrepMetrics (only
  get_ripgrep_binary_path is consumed)
- core/session/state.py: vestigial SessionState fields (spinner,
  current_task, input_sessions, undo_initialized) and the unwired
  recursive-execution cluster (task_hierarchy, recursive_context_stack,
  depth counters, iteration budgets, push/pop/reset methods); the sole
  external caller (/clear) only reset fields nothing ever writes
- core/types/state.py: matching protocol methods
- core/types/state_structures.py: vestigial RuntimeState.streaming_panel

Also refreshes stale module docs that described the removed canonical
message layer. mypy clean, 324 tests pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U3DHf5FbGZiDLMSWpq53gK
…dDicts (issue #441)

Replaces hand-written dict[str, Any] with the existing ToolArgs alias
(= tinyagent JsonObject) across the tool rendering pipeline: RenderFunc,
the renderer protocol/base, all six tool renderers, tool_panel /
tool_panel_smart, ToolDisplayData.arguments, and
ToolCallPartProtocol.args.

Adds types/tool_args.py declaring each renderer's de-facto argument
schema (BashArgs, ReadFileArgs, WriteFileArgs, WebFetchArgs,
HashlineEditArgs; total=False since model output is untrusted).
parse_result narrows ToolArgs to its tool's schema at the boundary, so
key typos and wrong value types are now caught by mypy.

The stricter signature immediately surfaced one loose call site
(shell_runner building a bash args dict), now annotated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U3DHf5FbGZiDLMSWpq53gK
- types-and-io-interfaces.md: record executed progress (dead-code
  deletion 5ce24c4, tool-args boundary f0fe551), mark B1 done, move
  removed symbols to past tense, and consolidate remaining work into
  one table. Drop the HTML visualization from the repo.
- modules/types/types.md: remove stale canonical.py/CanonicalMessage
  and LspSettings references, document tool_args.py and the ToolArgs
  narrowing pattern, note UsageCost/UsageMetrics live in __init__.py.
- modules/core/core.md: SessionState no longer tracks recursion state.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U3DHf5FbGZiDLMSWpq53gK
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR simplifies session and messaging APIs, removes ripgrep execution utilities, introduces typed tool-argument schemas, and updates UI renderer contracts and callers to use those schemas.

Changes

Session state simplification

Layer / File(s) Summary
Session state and protocol contracts
src/tunacode/core/session/state.py, src/tunacode/core/types/state.py
Session state removes recursive and transient fields, and the state protocol removes recursive execution methods.
Session reset and UI clearing
src/tunacode/core/session/state.py, src/tunacode/ui/commands/clear.py
Session replacement is provided through reset_session(), while clearing resets the context panel instead of recursive state.
Runtime state field cleanup
src/tunacode/core/types/state_structures.py
RuntimeState no longer stores a streaming panel reference.

Typed tool argument contracts

Layer / File(s) Summary
Tool argument schemas and exports
src/tunacode/types/tool_args.py, src/tunacode/types/base.py, src/tunacode/types/callbacks.py, src/tunacode/types/__init__.py
Per-tool optional TypedDict schemas are added, exported, and used to narrow callback argument types while obsolete exports are removed.
Shared renderer contracts
src/tunacode/ui/renderers/panels.py, src/tunacode/ui/renderers/tools/base.py
Tool panel and renderer interfaces replace generic dictionaries with ToolArgs.
Per-tool renderer argument handling
src/tunacode/ui/renderers/tools/*.py
Tool renderers accept ToolArgs, cast to tool-specific schemas, and preserve existing field defaults and rendering behavior.
Shell panel typing
src/tunacode/ui/shell_runner.py
The shell timeout mapping is explicitly annotated as ToolArgs.

Ripgrep utility reduction

Layer / File(s) Summary
Ripgrep binary resolution and legacy removal
src/tunacode/tools/utils/ripgrep.py
The module retains platform and binary resolution while removing execution wrappers, fallback search functions, and metrics state.

Canonical messaging API reduction

Layer / File(s) Summary
Canonical adapter and exports
src/tunacode/utils/messaging/adapter.py, src/tunacode/utils/messaging/__init__.py
List and reverse canonical conversion helpers are removed from the adapter and package re-exports.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 7 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description does not follow the template and omits the required Description, Type of Change, Testing, and checklist sections. Reformat it to the repository template and fill in all required sections, especially testing, type of change, and pre-PR/pre-commit checklists.
Dependencydirection ⚠️ Warning Gate 2 is violated: changed files under src/tunacode/types/ import non-stdlib project/external modules, including tunacode.types.* and tinyagent.agent_types. Keep types/ self-contained: move shared aliases out of types/, and remove non-stdlib imports from src/tunacode/types/init.py, base.py, and callbacks.py.
✅ Passed checks (7 passed)
Check name Status Explanation
Title check ✅ Passed Uses the required docs: prefix, stays under 72 characters, and matches the PR's type/interface mapping work.
Docstring Coverage ✅ Passed Docstring coverage is 95.45% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Noshallowcopymutation ✅ Passed Commit is docs-only; no .copy() calls or nested dict/list mutations appear in the touched diff.
Exceptionpathcleanup ✅ Passed No except (UserAbortError, CancelledError) found; the only CancelledError handler in agent_streaming calls _handle_interrupted_stream_cleanup() before re-raising.
Nosilentfailures ✅ Passed The PR removes recursive-state fallbacks and only adds type narrowing; no new broad swallow/return-None error path was introduced in changed lines.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/tunacode/core/session/state.py (1)

111-113: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

reset_session() should restore loaded config and the model context window (src/tunacode/core/session/state.py:111-113)

StateManager.__init__() calls _load_user_configuration(), but reset_session() replaces the session with a bare SessionState(). That drops the merged user config and leaves conversation.max_tokens at its default, so the next run can use stale/default settings. Reuse the init path here, or preserve user_config/current_model when resetting runtime state.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tunacode/core/session/state.py` around lines 111 - 113, Update
StateManager.reset_session() so resetting runtime state preserves the
configuration loaded by StateManager.__init__(), including user_config and
current_model, and restores conversation.max_tokens from the active model
context window. Reuse the existing initialization/configuration path where
appropriate instead of replacing the session with an unconfigured bare
SessionState.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/tunacode/types/callbacks.py`:
- Line 38: Update the callback type definitions around the args annotation to
remove imports of ToolArgs, ToolName, and ToolResult from tunacode.types.base,
keeping src/tunacode/types self-contained with only stdlib/typing dependencies.
Define the necessary shared aliases locally or move them to an allowed shared
location, then update the callback annotations to use those aliases without
violating the types-layer import gate.

In `@src/tunacode/ui/renderers/tools/discover.py`:
- Line 164: Update DiscoverRenderer.parse_result to explicitly mark the
intentionally unused args parameter, such as by assigning it to the project’s
standard unused-variable convention, while preserving the existing result
parsing behavior; do not introduce a DiscoverArgs schema.

In `@src/tunacode/ui/shell_runner.py`:
- Around line 144-145: Update the type annotation for the bash tool argument
literals in the shell runner to use BashArgs instead of the broader ToolArgs.
Apply this at both annotated occurrences, including the literal consumed by
render_bash/BashRenderer, and adjust the import accordingly so mypy validates
the expected BashArgs keys.

---

Outside diff comments:
In `@src/tunacode/core/session/state.py`:
- Around line 111-113: Update StateManager.reset_session() so resetting runtime
state preserves the configuration loaded by StateManager.__init__(), including
user_config and current_model, and restores conversation.max_tokens from the
active model context window. Reuse the existing initialization/configuration
path where appropriate instead of replacing the session with an unconfigured
bare SessionState.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4fd5e9f5-be0f-4a56-a8e0-0ab1a7f17430

📥 Commits

Reviewing files that changed from the base of the PR and between 0ae3c8c and 7e658b4.

⛔ Files ignored due to path filters (4)
  • docs/architecture/types-and-io-interfaces.md is excluded by !**/docs/**, !**/*.md
  • docs/modules/core/core.md is excluded by !**/docs/**, !**/*.md
  • docs/modules/types/types.md is excluded by !**/docs/**, !**/*.md
  • docs/modules/utils/utils.md is excluded by !**/docs/**, !**/*.md
📒 Files selected for processing (20)
  • src/tunacode/core/session/state.py
  • src/tunacode/core/types/state.py
  • src/tunacode/core/types/state_structures.py
  • src/tunacode/tools/utils/ripgrep.py
  • src/tunacode/types/__init__.py
  • src/tunacode/types/base.py
  • src/tunacode/types/callbacks.py
  • src/tunacode/types/tool_args.py
  • src/tunacode/ui/commands/clear.py
  • src/tunacode/ui/renderers/panels.py
  • src/tunacode/ui/renderers/tools/base.py
  • src/tunacode/ui/renderers/tools/bash.py
  • src/tunacode/ui/renderers/tools/discover.py
  • src/tunacode/ui/renderers/tools/hashline_edit.py
  • src/tunacode/ui/renderers/tools/read_file.py
  • src/tunacode/ui/renderers/tools/web_fetch.py
  • src/tunacode/ui/renderers/tools/write_file.py
  • src/tunacode/ui/shell_runner.py
  • src/tunacode/utils/messaging/__init__.py
  • src/tunacode/utils/messaging/adapter.py
💤 Files with no reviewable changes (5)
  • src/tunacode/core/types/state.py
  • src/tunacode/ui/commands/clear.py
  • src/tunacode/utils/messaging/init.py
  • src/tunacode/tools/utils/ripgrep.py
  • src/tunacode/utils/messaging/adapter.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (5)
**/*.py

📄 CodeRabbit inference engine (Custom checks)

**/*.py: Enforce dependency direction: ui → core → tools → utils/types. Flag violations where core/ imports from ui/, tools/ imports from ui/, tools/ imports from core/, or types/ imports from anything except stdlib/typing
In agent/orchestration code, verify exception handlers clean up state: flag except (UserAbortError, CancelledError) patterns that exist without corresponding cleanup like _remove_dangling_tool_calls() or state rollback. State mutations (messages.append, session modifications) followed by await/function calls that could raise must be cleaned up in except blocks
Check for shallow copy followed by nested dict mutation: flag .copy() on dicts that contain nested dicts/lists. Use deepcopy() instead or use dictionary spreading syntax to avoid mutating original objects
Enforce error handling principle: 'Fail fast, fail loud. No silent fallbacks.' Flag except: pass, except Exception: pass, empty except blocks, catching broad exceptions without re-raising or logging, and returning None/[]/{} sentinel values instead of raising exceptions for invalid inputs

**/*.py: Use Python 3.11 or newer.
Do not introduce new file-specific exemptions to the >600 line rule; fix the enforcement path or split the code instead.

Files:

  • src/tunacode/ui/shell_runner.py
  • src/tunacode/types/tool_args.py
  • src/tunacode/ui/renderers/tools/bash.py
  • src/tunacode/ui/renderers/tools/web_fetch.py
  • src/tunacode/ui/renderers/tools/read_file.py
  • src/tunacode/ui/renderers/tools/discover.py
  • src/tunacode/core/types/state_structures.py
  • src/tunacode/ui/renderers/tools/base.py
  • src/tunacode/ui/renderers/panels.py
  • src/tunacode/ui/renderers/tools/hashline_edit.py
  • src/tunacode/types/base.py
  • src/tunacode/ui/renderers/tools/write_file.py
  • src/tunacode/core/session/state.py
  • src/tunacode/types/callbacks.py
  • src/tunacode/types/__init__.py
src/tunacode/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

src/tunacode/**/*.py: Keep application code under the primary src/tunacode/ package and preserve its documented package structure.
Preserve the dependency direction types -> utils -> infrastructure -> configuration -> tools -> core -> ui; do not add imports across forbidden layers.
Follow the repository's documented import ordering for shared modules and layered modules.
Do not add TunaCode-owned message-contract wrappers around tinyagent message types; use tinyagent models directly in memory and keep dict payloads at real boundaries.
Prefer small, scoped, minimal, and targeted edits; follow existing nearby patterns, including command and test naming.

Files:

  • src/tunacode/ui/shell_runner.py
  • src/tunacode/types/tool_args.py
  • src/tunacode/ui/renderers/tools/bash.py
  • src/tunacode/ui/renderers/tools/web_fetch.py
  • src/tunacode/ui/renderers/tools/read_file.py
  • src/tunacode/ui/renderers/tools/discover.py
  • src/tunacode/core/types/state_structures.py
  • src/tunacode/ui/renderers/tools/base.py
  • src/tunacode/ui/renderers/panels.py
  • src/tunacode/ui/renderers/tools/hashline_edit.py
  • src/tunacode/types/base.py
  • src/tunacode/ui/renderers/tools/write_file.py
  • src/tunacode/core/session/state.py
  • src/tunacode/types/callbacks.py
  • src/tunacode/types/__init__.py
src/tunacode/ui/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Keep Rich default/ANSI color handling local to TunaCode; preserve the startup/theme stability behavior involving render_safety.py and built-in theme wrapping in constants.py.

Files:

  • src/tunacode/ui/shell_runner.py
  • src/tunacode/ui/renderers/tools/bash.py
  • src/tunacode/ui/renderers/tools/web_fetch.py
  • src/tunacode/ui/renderers/tools/read_file.py
  • src/tunacode/ui/renderers/tools/discover.py
  • src/tunacode/ui/renderers/tools/base.py
  • src/tunacode/ui/renderers/panels.py
  • src/tunacode/ui/renderers/tools/hashline_edit.py
  • src/tunacode/ui/renderers/tools/write_file.py

⚙️ CodeRabbit configuration file

src/tunacode/ui/**/*.py: UI layer rules:

  1. DEPENDENCY DIRECTION: ui/ can import from core/, tools/, utils/, types/

    • core/ MUST NOT import from ui/ (check for violations)
  2. GATE 5 - Indirection Requires Verification:

    • If using expand=True, verify actual rendered width
    • Panel widths should be explicit, not delegated
  3. Command implementations:

    • Must handle errors gracefully
    • Must not corrupt session state (see PR #264 /update crash)

Files:

  • src/tunacode/ui/shell_runner.py
  • src/tunacode/ui/renderers/tools/bash.py
  • src/tunacode/ui/renderers/tools/web_fetch.py
  • src/tunacode/ui/renderers/tools/read_file.py
  • src/tunacode/ui/renderers/tools/discover.py
  • src/tunacode/ui/renderers/tools/base.py
  • src/tunacode/ui/renderers/panels.py
  • src/tunacode/ui/renderers/tools/hashline_edit.py
  • src/tunacode/ui/renderers/tools/write_file.py
**/*

📄 CodeRabbit inference engine (AGENTS.md)

**/*: Before any Git operation, read docs/git/practices.md in the current session.
Never delete or clean untracked files or directories without explicit user confirmation; pause and ask if unknown files appear during checks.
During commit-time check failures, apply only trivial lint-only fixes; otherwise stop and request user instruction rather than making architectural or refactoring changes.
Do not edit unrelated local changes unless they are within the task scope.
Avoid adding empty directories or __init__.py-only directories.
Run validation commands before handoff when touching architecture, dependencies, or shared packages.

Files:

  • src/tunacode/ui/shell_runner.py
  • src/tunacode/types/tool_args.py
  • src/tunacode/ui/renderers/tools/bash.py
  • src/tunacode/ui/renderers/tools/web_fetch.py
  • src/tunacode/ui/renderers/tools/read_file.py
  • src/tunacode/ui/renderers/tools/discover.py
  • src/tunacode/core/types/state_structures.py
  • src/tunacode/ui/renderers/tools/base.py
  • src/tunacode/ui/renderers/panels.py
  • src/tunacode/ui/renderers/tools/hashline_edit.py
  • src/tunacode/types/base.py
  • src/tunacode/ui/renderers/tools/write_file.py
  • src/tunacode/core/session/state.py
  • src/tunacode/types/callbacks.py
  • src/tunacode/types/__init__.py
src/tunacode/types/**/*.py

⚙️ CodeRabbit configuration file

src/tunacode/types/**/*.py: Type layer is at the bottom of the dependency hierarchy.

  1. types/ MUST NOT import from ui/, core/, or tools/
  2. Only standard library and typing imports allowed
  3. All type definitions must have proper annotations
  4. Canonical types (PR #293) are immutable - use frozen=True

Files:

  • src/tunacode/types/tool_args.py
  • src/tunacode/types/base.py
  • src/tunacode/types/callbacks.py
  • src/tunacode/types/__init__.py
🪛 Ruff (0.15.20)
src/tunacode/ui/renderers/tools/discover.py

[warning] 164-164: Unused method argument: args

(ARG002)

🔇 Additional comments (14)
src/tunacode/core/session/state.py (2)

23-23: LGTM!


45-63: 🩺 Stability & Availability

No dangling SessionState field accesses remain.

			> Likely an incorrect or invalid review comment.
src/tunacode/core/types/state_structures.py (2)

57-58: 🩺 Stability & Availability

No runtime.streaming_panel access remains.


6-6: 🩺 Stability & Availability

No issue here Any is not referenced in src/tunacode/core/types/state_structures.py, and from __future__ import annotations prevents import-time evaluation of annotations.

			> Likely an incorrect or invalid review comment.
src/tunacode/types/tool_args.py (1)

1-33: LGTM!

src/tunacode/types/__init__.py (1)

67-75: LGTM!

src/tunacode/ui/renderers/tools/hashline_edit.py (1)

9-17: LGTM!

Also applies to: 74-74, 90-91, 355-355, 412-412

src/tunacode/ui/renderers/tools/read_file.py (1)

11-11: LGTM!

Also applies to: 20-20, 128-128, 162-164, 273-273

src/tunacode/ui/renderers/tools/web_fetch.py (1)

9-16: LGTM!

Also applies to: 44-54, 188-188

src/tunacode/ui/renderers/tools/write_file.py (1)

10-10: LGTM!

Also applies to: 21-21, 49-61, 165-165

src/tunacode/ui/renderers/panels.py (1)

20-20: LGTM!

Also applies to: 88-88, 468-468, 524-524

src/tunacode/ui/renderers/tools/base.py (1)

17-17: LGTM!

Also applies to: 32-32, 133-133, 204-204, 308-318, 426-426

src/tunacode/ui/renderers/tools/bash.py (1)

10-16: LGTM!

Also applies to: 46-46, 91-92, 251-251

src/tunacode/types/base.py (1)

19-19: 🗄️ Data Integrity & Integration

No dangling imports remain for the removed type aliases.

			> Likely an incorrect or invalid review comment.

tool_call_id: str
tool_name: str
args: str | dict[str, Any] | None
args: str | ToolArgs | None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the import of ToolArgs in callbacks.py
sed -n '1,14p' src/tunacode/types/callbacks.py | rg -n 'ToolArgs'

Repository: alchemiststudiosDOTai/tunacode

Length of output: 168


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the full imports and relevant type usage in the target file.
wc -l src/tunacode/types/callbacks.py
cat -n src/tunacode/types/callbacks.py | sed -n '1,120p'

Repository: alchemiststudiosDOTai/tunacode

Length of output: 3102


src/tunacode/types/callbacks.py violates the types-layer import gate
ToolArgs, ToolName, and ToolResult are imported from tunacode.types.base, but src/tunacode/types/**/*.py is limited to stdlib/typing imports. Keep this module self-contained or move the shared aliases out of types/.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tunacode/types/callbacks.py` at line 38, Update the callback type
definitions around the args annotation to remove imports of ToolArgs, ToolName,
and ToolResult from tunacode.types.base, keeping src/tunacode/types
self-contained with only stdlib/typing dependencies. Define the necessary shared
aliases locally or move them to an allowed shared location, then update the
callback annotations to use those aliases without violating the types-layer
import gate.

Source: Path instructions

return ""

def parse_result(self, args: dict[str, Any] | None, result: str) -> DiscoverData | None:
def parse_result(self, args: ToolArgs | None, result: str) -> DiscoverData | None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Unused args parameter (Ruff ARG002).

DiscoverRenderer.parse_result never reads args, unlike the other renderers in this cohort that cast it to a tool-specific schema. Silence the lint warning or confirm this is intentionally unused (discover has no DiscoverArgs schema).

🧹 Proposed fix
-    def parse_result(self, args: ToolArgs | None, result: str) -> DiscoverData | None:
+    def parse_result(self, args: ToolArgs | None, result: str) -> DiscoverData | None:  # noqa: ARG002
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def parse_result(self, args: ToolArgs | None, result: str) -> DiscoverData | None:
def parse_result(self, args: ToolArgs | None, result: str) -> DiscoverData | None: # noqa: ARG002
🧰 Tools
🪛 Ruff (0.15.20)

[warning] 164-164: Unused method argument: args

(ARG002)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tunacode/ui/renderers/tools/discover.py` at line 164, Update
DiscoverRenderer.parse_result to explicitly mark the intentionally unused args
parameter, such as by assigning it to the project’s standard unused-variable
convention, while preserving the existing result parsing behavior; do not
introduce a DiscoverArgs schema.

Source: Linters/SAST tools

Comment on lines +144 to +145
from tunacode.types import ToolArgs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider typing as BashArgs instead of the broader ToolArgs.

This literal is only ever consumed by render_bash/BashRenderer, which casts to BashArgs. Annotating it as BashArgs directly would let mypy catch a wrong/misspelled key here instead of silently allowing any JSON-object shape.

♻️ Proposed tightening
-        from tunacode.types import ToolArgs
+        from tunacode.types import BashArgs

         from tunacode.ui.renderers.tools.bash import render_bash
         ...
-        args: ToolArgs = {"timeout": int(SHELL_COMMAND_TIMEOUT_SECONDS)}
+        args: BashArgs = {"timeout": int(SHELL_COMMAND_TIMEOUT_SECONDS)}

Also applies to: 161-161

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tunacode/ui/shell_runner.py` around lines 144 - 145, Update the type
annotation for the bash tool argument literals in the shell runner to use
BashArgs instead of the broader ToolArgs. Apply this at both annotated
occurrences, including the literal consumed by render_bash/BashRenderer, and
adjust the import accordingly so mypy validates the expected BashArgs keys.

@tunahorse
tunahorse merged commit 853724d into master Jul 11, 2026
6 checks passed
@tunahorse
tunahorse deleted the claude/old-issues-review-axg9qv branch July 11, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants