Skip to content

feat(apps): ctx.chat_slots.open(hidden=True) opens an app's hidden chat - #39246

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
feat/chat-slot-hidden
Nov 19, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
feat/chat-slot-hidden

Conversation

@iamwhatever

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: An app's backend can open a chat that stays out of the session lists and still carries the app's name, so app-scoped rules treat it as the app's.

Today an app picks one of two:

  • ctx.chat_slots.open(state, key) stamps the chat with the app's name (slot._app), so the app's tool profile, browserSites and /api/browser/media see it as the app's. But it always opens as a plain chat, listed in the sidebar, even for an app that declares permissions.hiddenSessions: true.
  • The app's page can open a hidden chat (POST /api/chat/slots with mode set to the app's id). That request is the owner's, so the chat gets no _app, and the app-scoped rules do not see it as the app's.

Reproduced on main with the real dashboard state: the SDK chat comes out _app='acme-app' mode='' surface='' (listed); the page chat comes out _app='' mode='acme-app' surface='acme-app' (hidden).

Why it matters

The Mood Music app's DJ chat drives the Crew Browser, whose site grants check the chat is the app's. It also declares hiddenSessions so that chat stays out of the person's list. Neither path gives both, so the app either clutters the sidebar or loses its Browser grants.

Not a goal

  • Letting a page name the app to stamp _app: a page's claim can be forged.
  • A new hiding rule: the existing hiddenSessions rule (installed, enabled, trusted, declaring) decides.
  • Changing an existing chat's mode, or what open does without the new keyword.

What changed (motivation → approach → change)

ctx.chat_slots.open (src/kiro_crew/apps/chat_slot_sdk.py) gains hidden=False. With hidden=True, a new chat is created under the app's own mode, the same mode POST /api/chat/slots already accepts from a hiding app, and keeps its _app stamp. The SDK asks the existing may_hide_sessions off the event loop first; when the app may not hide, it raises ChatSlotRefused and creates nothing. An existing chat is returned with the mode it has. Listing, resume and the switch back to listed when the app is disabled or untrusted are the existing hiddenSessions code, unchanged.

The API reference, the manifest reference, the App Kit spec and the src/kiro_crew/apps/hidden_sessions.py docstring now name the keyword.

Backwards compatibility

Compatible: hidden is a new keyword that defaults to the old behaviour; an older host's open takes no hidden and raises TypeError, which the API reference states.

Removes nothing: the diff only adds an opt-in keyword; no path, key, row or validator is taken away.

Tests

test/test_app_hidden_sessions.py, against the real dashboard state:

  • test_chat_slots_opens_a_hidden_chat_stamped_with_its_app: open(..., hidden=True) gives _app and mode both the app's name, the slot listing reports it hidden, and once the app may not hide, the open chat lists again while keeping its mode.
  • test_chat_slots_refuses_a_hidden_chat_to_an_app_that_may_not_hide: ChatSlotRefused, no slot created.
  • test_chat_slots_opens_a_listed_chat_by_default: no keyword gives a plain chat; a later hidden=True open of that chat keeps its mode and asks nothing.

test/test_chat_follow_default_slot_kinds.py: open now has two get_or_create_slot calls, both passing app=; the registry count says so.

Determinism: the file passed 3 repeats and once in reversed order (46 passed). By hand, dropping the may_hide_sessions check fails two new tests, and dropping mode= fails the first.

Proof: PROVEN test/test_chat_follow_default_slot_kinds.py::TestSlotCreatorRegistry::test_every_creator_is_classified (head 6165439, same tree rebased)

Manual verification

N/A — unit coverage sufficient: the tests drive the real get_or_create_slot, the real slot listing route and the real hidden-chat refresh; only may_hide_sessions is stubbed, which test_any_other_app_may_not already covers.

Real-machine verification

N/A -- the change is an in-process SDK keyword covered by tests on the real dashboard state; no host, install or OS path differs.

Related Issues

Closes #39193

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners November 18, 2026 20:25
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 18, 2026
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision ad4b3d15ed328ad5ae0a6dec75db81ac86cbf1d1 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of ad4b3d15ed328ad5ae0a6dec75db81ac86cbf1d1 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the new keyword goes through the existing may_hide_sessions check and the existing app-mode hiding rule, so it adds no second rule for hiding chats.

Notes

  • When a saved transcript sits under the key but no slot is live, get_or_create_slot(..., mode=self._app) may restore it under its saved mode instead of the app's. The docs say "an existing slot keeps the mode it has"; confirm that sentence also covers restored slots.

[DESIGN-REVIEWED] ad4b3d1

Description read

[DESCRIPTION-READ] 743c057eee5805c3b1df40ccdf7ce3b018591024fbbe1376b5f127524bc9aa93

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of ad4b3d15ed328ad5ae0a6dec75db81ac86cbf1d1 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks: the keyword is opt-in, closes #39193, and reuses the existing may_hide_sessions rule.

Notes

  • Item 1 — inherited: the description says "Neither path gives both," but the backend path already gives both. POST /api/chat/slots with an app token passes app=request.get("app", "") and mode=_mode to the same get_or_create_slot call (dashboard/chat_api/slot_create.py:762-765), which stamps _app and hides the chat. A later open then adopts that slot. The description only compares against the page path. The fair justification is "in-process, no HTTP round trip," not "impossible today."
  • Item 3 — oversized: the if hidden: … else: … around two get_or_create_slot calls exists only to pass mode. Subtraction: make it one call with mode=self._app if hidden else "", and delete the ("apps/chat_slot_sdk.py", "open"): 2 row from _CALLS_PER_SITE.

What this change ships

Inventory (4 items) — 2 justified

Intent: let an app's backend open a chat that stays out of the session lists and still counts as the app's chat for app-scoped rules (ADDITION).

  1. ctx.chat_slots.open(..., hidden=True) creates an app-stamped chat under the app's own mode — inherited: backend app-token POST already gives _app plus mode
  2. An app that may not hide gets ChatSlotRefused and no slot is created — justified
  3. The slot-creator registry counts two creator calls in open — oversized: one call with a conditional mode suffices
  4. The API reference, manifest reference, App Kit spec and docstring name the keyword — justified

[FIRST-PRINCIPLES-REVIEWED] ad4b3d1

Description read

[DESCRIPTION-READ] 81617bc29b9363f2f9a8489e81c251f62da6b91ab795d883e1f6139a2e2314ac

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed ad4b3d15ed328ad5ae0a6dec75db81ac86cbf1d1 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] ad4b3d1

Verdict parsed from the review's SHA-scoped output markers for commit ad4b3d15ed328ad5ae0a6dec75db81ac86cbf1d1.

False positive or not applicable? A repository writer can comment:
/ai-review override fable ad4b3d15ed328ad5ae0a6dec75db81ac86cbf1d1 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of ad4b3d15ed328ad5ae0a6dec75db81ac86cbf1d1 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] ad4b3d1

False positive or not applicable? A repository writer can comment:
/ai-review override gpt ad4b3d15ed328ad5ae0a6dec75db81ac86cbf1d1 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 18, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebased onto main to pick up #39262, which fixes the main-red test_bare_session_handle_guard failure behind the three red jobs on the previous head (6165439 -> ad4b3d1); CI re-running.

@iamwhatever
iamwhatever force-pushed the feat/chat-slot-hidden branch from 6165439 to ad4b3d1 Compare November 18, 2026 22:08
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 18, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider estimates a 10% chance that this change introduces a defect, within the 12% limit for approving on its own, but it is held at tier 2: security-sensitive path.

This adds an opt-in hidden=False keyword to ChatSlotSDK.open. With hidden=True, a new slot is created under mode=self._app and keeps its _app stamp, so it stays out of the session lists but still counts as the app's chat. Before creating the slot, open asks the existing may_hide_sessions check off the event loop. If the app may not hide its chats, it raises ChatSlotRefused and creates nothing. After that check, open looks up the slot again with no await before the create, so the old no-race guarantee still holds. An existing live slot is returned with the mode it already has, and may_hide_sessions is not asked again.

Trust boundary. The mode is always the app's own id, never one the caller supplies, which is the same rule _app_hides_own_mode applies on POST /api/chat/slots. may_hide_sessions refuses DM_SLOT_MODE ("member") and retired modes, so an app named "member" cannot use this to get past the reserved member- key check in prepare_creation.

Lifecycle. Disable, untrust and uninstall already go through listed_surface and resume_keeps_mode, which read only the mode, so an SDK-made hidden chat lists again exactly like a chat made throug

Tier: 2, held for a person: security-sensitive path.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit ad4b3d15ed · 99 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 19, 2026 00:55

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved. On head ad4b3d1 the review checked four things. open(hidden=True) runs the existing may_hide_sessions check off the loop. The check happens only when no live slot exists, and the key is looked up again after the await. A refused open creates nothing. An existing chat keeps its mode. All three new tests go red when the production hunk is reverted, and the _CALLS_PER_SITE row matches the real call count.

Security: the new path adds no hiding rule. The mode it sets is always the app name the host fixes when it builds the SDK, so an app cannot hide another app's chat or a person's chat. may_hide_sessions refuses the core member mode and retired or invalid names, and returns False on any manifest or trust read error. The result matches what the existing app-token POST /api/chat/slots path already produces, behind the same hiddenSessions grant.

Done well: the tests drive the real slot listing route and refresh, and show the chat lists again once the app may not hide it.

Optional:

  • On main an app backend can already get a hidden chat with _app stamped through its app token and POST /api/chat/slots with mode=<app>. A short comment that names that path would help. The real gain here is the in-process call, with no extra permissions.api grant and no HTTP round trip.
  • The spec line about the chatSlots trust copy could say that the hiddenSessions row carries the exception.
  • No test pins that the may_hide_sessions read runs off the event loop. A stub that records threading.get_ident() would pin it.

@KiroCrewCaptain
KiroCrewCaptain merged commit f65547b into main Nov 19, 2026
103 of 111 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the feat/chat-slot-hidden branch November 19, 2026 00:55
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 19, 2026
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.

ctx.chat_slots: let an app's backend open a hidden chat that keeps its app name

2 participants