Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(scheduling): let any team member edit team booking links (#7992)

Chaitanya Agarwalb13f12cf809a
diff --git a/apps/docs/AI/mcp/tools/get-booking-reschedule-slots.mdx b/apps/docs/AI/mcp/tools/get-booking-reschedule-slots.mdx
index 44228d48b2..c435cb4469 100644
--- a/apps/docs/AI/mcp/tools/get-booking-reschedule-slots.mdx
+++ b/apps/docs/AI/mcp/tools/get-booking-reschedule-slots.mdx
@@ -7,7 +7,7 @@ description: >-
# GetBookingRescheduleSlots
-Find available replacement times for a booking discovered through ListBookings. The date is in the booking schedule time zone. Only the personal owner or team administrators may reschedule it. Returns absolute start/end times for ChangeBooking reschedule; availability is checked again when moving the meeting.
+Find available replacement times for a booking discovered through ListBookings. The date is in the booking schedule time zone. Only the personal owner, a host of the meeting or team administrators may reschedule it. Returns absolute start/end times for ChangeBooking reschedule; availability is checked again when moving the meeting.
## Parameters
diff --git a/apps/docs/AI/mcp/tools/update-booking-settings.mdx b/apps/docs/AI/mcp/tools/update-booking-settings.mdx
index 5856bb61ca..119ef93c66 100644
--- a/apps/docs/AI/mcp/tools/update-booking-settings.mdx
+++ b/apps/docs/AI/mcp/tools/update-booking-settings.mdx
@@ -6,7 +6,7 @@ description: >-
# UpdateBookingSettings
-Update Booking Links settings after reading ReadBookingSettings. Pass the full profile with its current revision, preserving fields the user did not request changing. Supports booking-page name and introduction; adding, editing and deleting reusable schedules and date overrides; changing defaultScheduleId; reassigning link schedules; duplicating, deleting, enabling or pausing links. Generate new UUIDs for new schedules, links and questions; preserve existing IDs. Changing a shared schedule affects every link referencing it and personal default hours affect team hosting. Deleting a link does not cancel existing bookings. Explain affected links before changing shared hours or deleting. A stale revision fails: re-read and reconcile rather than overwriting. Use CreateBookingLink or EditBookingLink for ordinary single-link authoring and their conversational confirmation contract. Team edits require owner/admin access. Before saving, explain the proposed changes and their personal/team scope, ask whether to proceed, and wait for the user's approving reply in a later turn. Quote that reply verbatim in userConfirmation. Do not use the original request as confirmation.
+Update Booking Links settings after reading ReadBookingSettings. Pass the full profile with its current revision, preserving fields the user did not request changing. Supports booking-page name and introduction; adding, editing and deleting reusable schedules and date overrides; changing defaultScheduleId; reassigning link schedules; duplicating, deleting, enabling or pausing links. Generate new UUIDs for new schedules, links and questions; preserve existing IDs. Changing a shared schedule affects every link referencing it and personal default hours affect team hosting. Deleting a link does not cancel existing bookings. Explain affected links before changing shared hours or deleting. A stale revision fails: re-read and reconcile rather than overwriting. Use CreateBookingLink or EditBookingLink for ordinary single-link authoring and their conversational confirmation contract. Any team member can edit team settings. Before saving, explain the proposed changes and their personal/team scope, ask whether to proceed, and wait for the user's approving reply in a later turn. Quote that reply verbatim in userConfirmation. Do not use the original request as confirmation.
## Parameters
diff --git a/apps/web/src/features/scheduling/browser-test/fixture.tsx b/apps/web/src/features/scheduling/browser-test/fixture.tsx
index 5b8f979d7a..a9f2c1e5a1 100644
--- a/apps/web/src/features/scheduling/browser-test/fixture.tsx
+++ b/apps/web/src/features/scheduling/browser-test/fixture.tsx
@@ -205,12 +205,13 @@ function Fixture() {
const capabilities: SchedulingCapabilities = {
userId: () => 'macro|[email protected]',
scopes: () => [
- { id: 'me', name: 'Personal', canEdit: true },
+ { id: 'me', name: 'Personal', canEdit: true, canManageBookings: true },
{
id: 'team',
teamId: 'team',
name: 'Design team',
canEdit: !readOnlyTeam(),
+ canManageBookings: !readOnlyTeam(),
},
],
members: () => [
@@ -262,7 +263,7 @@ function Fixture() {
const booking = bookings().find((b) => b.id === id);
if (
!booking ||
- (!scope().canEdit &&
+ (!scope().canManageBookings &&
!booking.hosts.includes('macro|[email protected]'))
)
throw new Error('Forbidden');
diff --git a/apps/web/src/features/scheduling/calendar-actions.tsx b/apps/web/src/features/scheduling/calendar-actions.tsx
index d6d636bb30..d80b060f8e 100644
--- a/apps/web/src/features/scheduling/calendar-actions.tsx
+++ b/apps/web/src/features/scheduling/calendar-actions.tsx
@@ -22,6 +22,7 @@ function Actions() {
id: user() ?? 'me',
name: 'Personal',
canEdit: true,
+ canManageBookings: true,
}),
() => user() ?? ''
);
diff --git a/apps/web/src/features/scheduling/components/bookings-panel.tsx b/apps/web/src/features/scheduling/components/bookings-panel.tsx
index 13b03736ce..e3e95f4c81 100644
--- a/apps/web/src/features/scheduling/components/bookings-panel.tsx
+++ b/apps/web/src/features/scheduling/components/bookings-panel.tsx
@@ -19,7 +19,7 @@ export type BookingsPanelProps = {
bookings: Booking[];
events: EventType[];
members: SchedulingMember[];
- canEdit: boolean;
+ canManageBookings: boolean;
busyId: string;
currentUserId: string;
onApprove: (id: string) => void;
@@ -82,10 +82,13 @@ function BookingRow(
const member = props.members.find((m) => m.id === id);
return member?.name || member?.email || 'Calendar host';
});
+ const isHost = () => props.booking.hosts.includes(props.currentUserId);
+ // Hosts move or cancel the meetings they host; approving stays with admins.
const canManage = () =>
- props.canEdit &&
- (props.booking.status === 'pending' ||
- (props.booking.status === 'confirmed' && !isPast()));
+ (props.canManageBookings && props.booking.status === 'pending') ||
+ ((props.canManageBookings || isHost()) &&
+ props.booking.status === 'confirmed' &&
+ !isPast());
const meetingUrl = () => {
try {
const url = new URL(props.booking.location);
@@ -278,9 +281,7 @@ function BookingRow(
{ value: 'hostNoShow', label: 'Host no-show' },
]}
disabled={
- (!props.canEdit &&
- !props.booking.hosts.includes(props.currentUserId)) ||
- !!props.busyId
+ (!props.canManageBookings && !isHost()) || !!props.busyId
}
onChange={(value) => {
if (
diff --git a/apps/web/src/features/scheduling/core/types.ts b/apps/web/src/features/scheduling/core/types.ts
index 81861651e5..0cce2177d2 100644
--- a/apps/web/src/features/scheduling/core/types.ts
+++ b/apps/web/src/features/scheduling/core/types.ts
@@ -46,7 +46,10 @@ export type SchedulingScope = {
id: string;
name: string;
teamId?: string;
+ /** May change booking links, schedules, and the booking page. */
canEdit: boolean;
+ /** May cancel, reschedule, and record attendance for any host's bookings. */
+ canManageBookings: boolean;
};
export type SchedulingMember = { id: string; name: string; email: string };
export type BookingAttendance =
diff --git a/apps/web/src/features/scheduling/primitives/create-scheduling-owner.ts b/apps/web/src/features/scheduling/primitives/create-scheduling-owner.ts
index d328037b0b..c8f124d6f8 100644
--- a/apps/web/src/features/scheduling/primitives/create-scheduling-owner.ts
+++ b/apps/web/src/features/scheduling/primitives/create-scheduling-owner.ts
@@ -53,7 +53,7 @@ export function createSchedulingOwner(
};
const save = async (next: SchedulingProfile) => {
if (!scope().canEdit)
- throw new Error('Only owners and admins can edit team scheduling.');
+ throw new Error('Only team members can edit team scheduling.');
setError('');
await source.save(next);
};
diff --git a/apps/web/src/features/scheduling/scheduling.tsx b/apps/web/src/features/scheduling/scheduling.tsx
index c0847b9562..86bfb072f8 100644
--- a/apps/web/src/features/scheduling/scheduling.tsx
+++ b/apps/web/src/features/scheduling/scheduling.tsx
@@ -40,7 +40,12 @@ function SchedulingSettingsContent() {
}) ?? [];
const scopes = (): SchedulingScope[] => {
const result: SchedulingScope[] = [
- { id: user.userId() ?? 'me', name: 'Personal', canEdit: true },
+ {
+ id: user.userId() ?? 'me',
+ name: 'Personal',
+ canEdit: true,
+ canManageBookings: true,
+ },
];
const data = currentTeam();
if (data) {
@@ -49,7 +54,8 @@ function SchedulingSettingsContent() {
id: data.team.id,
name: data.team.name,
teamId: data.team.id,
- canEdit: role === 'admin' || role === 'owner',
+ canEdit: role !== undefined,
+ canManageBookings: role === 'admin' || role === 'owner',
});
}
return result;
diff --git a/apps/web/src/features/scheduling/views/owner-settings-section.tsx b/apps/web/src/features/scheduling/views/owner-settings-section.tsx
index 7b86b8c239..3b9d0dabde 100644
--- a/apps/web/src/features/scheduling/views/owner-settings-section.tsx
+++ b/apps/web/src/features/scheduling/views/owner-settings-section.tsx
@@ -304,7 +304,7 @@ export function OwnerSettingsSection(props: {
events={p().eventTypes}
members={capabilities.members()}
currentUserId={capabilities.userId()}
- canEdit={scope().canEdit}
+ canManageBookings={scope().canManageBookings}
busyId={busyBooking()}
onApprove={(id) =>
void bookingAction(id, () => source.approve(id))
diff --git a/apps/web/src/features/scheduling/views/settings-view.test.tsx b/apps/web/src/features/scheduling/views/settings-view.test.tsx
index a8ddee69fd..0ae1565ed4 100644
--- a/apps/web/src/features/scheduling/views/settings-view.test.tsx
+++ b/apps/web/src/features/scheduling/views/settings-view.test.tsx
@@ -14,6 +14,7 @@ import {
type SchedulingSource,
} from '../context/scheduling-context';
import {
+ type Booking,
newEventType,
newSchedule,
type SchedulingProfile,
@@ -51,7 +52,29 @@ afterEach(() => {
vi.restoreAllMocks();
});
-function fixture(teamEditable = true) {
+const future = (hours: number) =>
+ new Date(Date.now() + hours * 3_600_000).toISOString();
+
+/** A confirmed team meeting hosted by a teammate, not the signed-in user. */
+const teammateBooking: Booking = {
+ id: 'booking',
+ eventTypeId: 'same-event-id',
+ title: 'Team planning',
+ name: 'Guest',
+ email: '[email protected]',
+ startsAt: future(24),
+ endsAt: future(25),
+ timeZone: 'UTC',
+ hosts: ['teammate'],
+ status: 'confirmed',
+ attendance: 'unknown',
+ rescheduleCount: 0,
+ rescheduledAt: null,
+ location: '',
+ answers: {},
+};
+
+function fixture(team = { canEdit: true, canManageBookings: true }) {
const sources = new Map<string, SchedulingSource>();
const saves = vi.fn();
const createSource: SchedulingCapabilities['createSource'] = (scope) => {
@@ -75,7 +98,18 @@ function fixture(teamEditable = true) {
});
const source: SchedulingSource = {
profile,
- bookings: () => [],
+ bookings: () =>
+ scope().teamId
+ ? [
+ teammateBooking,
+ {
+ ...teammateBooking,
+ id: 'hosted',
+ name: 'Own guest',
+ hosts: ['user'],
+ },
+ ]
+ : [],
loading: () => false,
error: () => undefined,
saving: () => false,
@@ -96,8 +130,13 @@ function fixture(teamEditable = true) {
<SchedulingProvider
value={{
scopes: () => [
- { id: 'personal', name: 'Personal', canEdit: true },
- { id: 'team', name: 'Design', teamId: 'team', canEdit: teamEditable },
+ {
+ id: 'personal',
+ name: 'Personal',
+ canEdit: true,
+ canManageBookings: true,
+ },
+ { id: 'team', name: 'Design', teamId: 'team', ...team },
],
members: () => [],
userId: () => 'user',
@@ -181,7 +220,7 @@ it('keeps page drafts across navigation and scopes each section', async () => {
});
it('preserves read-only access and clears search when switching owners', async () => {
- fixture(false);
+ fixture({ canEdit: false, canManageBookings: false });
fireEvent.input(
screen.getByRole('searchbox', { name: 'Search booking links' }),
{ target: { value: 'no match' } }
@@ -197,6 +236,19 @@ it('preserves read-only access and clears search when switching owners', async (
).toBeNull();
expect(screen.queryByRole('button', { name: 'New booking link' })).toBeNull();
expect(
- screen.getByText('Only team owners and admins can edit these settings.')
+ screen.getByText('Only team members can edit these settings.')
).toBeTruthy();
});
+
+it('lets a team member edit booking links and manage only the meetings they host', async () => {
+ fixture({ canEdit: true, canManageBookings: false });
+ await selectOwner('Team · Design');
+ expect(screen.getByRole('button', { name: 'New booking link' })).toBeTruthy();
+
+ fireEvent.click(screen.getByRole('tab', { name: 'Bookings' }));
+ expect(await screen.findByText('Guest')).toBeTruthy();
+ expect(screen.getByText('Own guest')).toBeTruthy();
+ // One Cancel and one Reschedule: the meeting they host, not the teammate's.
+ expect(screen.getAllByRole('button', { name: 'Cancel' })).toHaveLength(1);
+ expect(screen.getAllByRole('button', { name: 'Reschedule' })).toHaveLength(1);
+});
diff --git a/apps/web/src/features/scheduling/views/settings-view.tsx b/apps/web/src/features/scheduling/views/settings-view.tsx
index 42754aa03e..0a03949ebd 100644
--- a/apps/web/src/features/scheduling/views/settings-view.tsx
+++ b/apps/web/src/features/scheduling/views/settings-view.tsx
@@ -282,7 +282,7 @@ export function SchedulingSettingsView() {
<Show when={!owner.scope().canEdit}>
<p class="mt-4 flex flex-wrap items-center gap-2 text-sm text-ink-muted">
<OwnerBadge scope={owner.scope()} />
- Only team owners and admins can edit these settings.
+ Only team members can edit these settings.
</p>
</Show>
</>
diff --git a/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts b/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts
index be4061b6b8..d190b33628 100644
--- a/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts
+++ b/apps/web/src/lib/service-clients/service-cognition/generated/tools/types.ts
@@ -9407,7 +9407,7 @@ export interface InsightCounts {
hostNoShow: number;
}
/**
- * Find available replacement times for a booking discovered through ListBookings. The date is in the booking schedule time zone. Only the personal owner or team administrators may reschedule it. Returns absolute start/end times for ChangeBooking reschedule; availability is checked again when moving the meeting.
+ * Find available replacement times for a booking discovered through ListBookings. The date is in the booking schedule time zone. Only the personal owner, a host of the meeting or team administrators may reschedule it. Returns absolute start/end times for ChangeBooking reschedule; availability is checked again when moving the meeting.
*/
export interface GetBookingRescheduleSlots {
/**
@@ -13813,7 +13813,7 @@ export interface TextEditorCodeExecutionToolError {
error_code: CodeExecutionErrorCode;
}
/**
- * Update Booking Links settings after reading ReadBookingSettings. Pass the full profile with its current revision, preserving fields the user did not request changing. Supports booking-page name and introduction; adding, editing and deleting reusable schedules and date overrides; changing defaultScheduleId; reassigning link schedules; duplicating, deleting, enabling or pausing links. Generate new UUIDs for new schedules, links and questions; preserve existing IDs. Changing a shared schedule affects every link referencing it and personal default hours affect team hosting. Deleting a link does not cancel existing bookings. Explain affected links before changing shared hours or deleting. A stale revision fails: re-read and reconcile rather than overwriting. Use CreateBookingLink or EditBookingLink for ordinary single-link authoring and their conversational confirmation contract. Team edits require owner/admin access. Before saving, explain the proposed changes and their personal/team scope, ask whether to proceed, and wait for the user's approving reply in a later turn. Quote that reply verbatim in userConfirmation. Do not use the original request as confirmation.
+ * Update Booking Links settings after reading ReadBookingSettings. Pass the full profile with its current revision, preserving fields the user did not request changing. Supports booking-page name and introduction; adding, editing and deleting reusable schedules and date overrides; changing defaultScheduleId; reassigning link schedules; duplicating, deleting, enabling or pausing links. Generate new UUIDs for new schedules, links and questions; preserve existing IDs. Changing a shared schedule affects every link referencing it and personal default hours affect team hosting. Deleting a link does not cancel existing bookings. Explain affected links before changing shared hours or deleting. A stale revision fails: re-read and reconcile rather than overwriting. Use CreateBookingLink or EditBookingLink for ordinary single-link authoring and their conversational confirmation contract. Any team member can edit team settings. Before saving, explain the proposed changes and their personal/team scope, ask whether to proceed, and wait for the user's approving reply in a later turn. Quote that reply verbatim in userConfirmation. Do not use the original request as confirmation.
*/
export interface UpdateBookingSettings {
/**
diff --git a/crates/calendar_scheduling/src/domain/booking_links.rs b/crates/calendar_scheduling/src/domain/booking_links.rs
index 14896e3278..d5c9d4138e 100644
--- a/crates/calendar_scheduling/src/domain/booking_links.rs
+++ b/crates/calendar_scheduling/src/domain/booking_links.rs
@@ -87,7 +87,6 @@ impl<Store: Repository, Calendar: Send + Sync + 'static, Members: Directory> Boo
draft: BookingLinkDraft,
) -> Result<BookingLink, Error> {
let mut profile = self.settings(user, team).await?;
- self.authorize_link_write(user, team, &profile).await?;
if let Some(event) = profile
.event_types
.iter()
@@ -127,7 +126,6 @@ impl<Store: Repository, Calendar: Send + Sync + 'static, Members: Directory> Boo
draft: BookingLinkDraft,
) -> Result<BookingLink, Error> {
let mut profile = self.settings(user, team).await?;
- self.authorize_link_write(user, team, &profile).await?;
let index = profile
.event_types
.iter()
@@ -169,23 +167,3 @@ impl<Store: Repository, Calendar: Send + Sync + 'static, Members: Directory> Boo
saved_link(&profile, &event)
}
}
-
-impl<Store: Repository, Calendar, Members: Directory> Service<Store, Calendar, Members> {
- async fn authorize_link_write(
- &self,
- user: &str,
- team: Option<Uuid>,
- profile: &Profile,
- ) -> Result<(), Error> {
- self.authorize(
- user,
- &OwnedProfile {
- user_id: team.is_none().then(|| user.into()),
- team_id: team,
- profile: profile.clone(),
- },
- true,
- )
- .await
- }
-}
diff --git a/crates/calendar_scheduling/src/domain/models.rs b/crates/calendar_scheduling/src/domain/models.rs
index 613b76974f..496ccaa2b4 100644
--- a/crates/calendar_scheduling/src/domain/models.rs
+++ b/crates/calendar_scheduling/src/domain/models.rs
@@ -303,7 +303,7 @@ pub struct Slot {
pub struct TeamMember {
/// Macro user identity.
pub user_id: String,
- /// Whether this member administers scheduling.
+ /// Whether this member is a team owner or admin, who may manage any host's bookings.
pub admin: bool,
}
/// Use-case failures mapped by transport adapters.
diff --git a/crates/calendar_scheduling/src/domain/service.rs b/crates/calendar_scheduling/src/domain/service.rs
index 1cb9d0e226..85f13c9d2f 100644
--- a/crates/calendar_scheduling/src/domain/service.rs
+++ b/crates/calendar_scheduling/src/domain/service.rs
@@ -71,11 +71,13 @@ impl<R: Repository, C, D: Directory> Service<R, C, D> {
);
Uuid::new_v5(&Uuid::NAMESPACE_URL, scope.as_bytes())
}
+ /// Any team member may read and edit their team's profile; `admin` limits
+ /// the action to the team's administrators.
pub(super) async fn authorize(
&self,
user: &str,
owner: &OwnedProfile,
- write: bool,
+ admin: bool,
) -> Result<(), Error> {
if let Some(team) = owner.team_id {
if self
@@ -83,7 +85,7 @@ impl<R: Repository, C, D: Directory> Service<R, C, D> {
.members(team)
.await?
.iter()
- .any(|m| m.user_id == user && (!write || m.admin))
+ .any(|m| m.user_id == user && (!admin || m.admin))
{
return Ok(());
}
@@ -135,7 +137,7 @@ impl<R: Repository, C, D: Directory> Service<R, C, D> {
self.authorize(user, &owner, false).await?;
Ok(owner.profile)
}
- /// Save a validated, revision-protected profile. Only team admins may edit team links.
+ /// Save a validated, revision-protected profile. Any team member may edit team links.
pub async fn save(
&self,
user: &str,
@@ -151,7 +153,7 @@ impl<R: Repository, C, D: Directory> Service<R, C, D> {
team_id: team,
profile,
};
- self.authorize(user, &owner, true).await?;
+ self.authorize(user, &owner, false).await?;
let previous = self.repository.profile(owner.profile.id).await?;
self.validate_hosts(&owner, previous.as_ref()).await?;
self.repository.save_profile(owner).await
@@ -611,11 +613,7 @@ impl<R: Repository, C: Calendars, D: Directory> Service<R, C, D> {
.profile(record.profile_id)
.await?
.ok_or(Error::NotFound)?;
- if record.booking.hosts.iter().any(|host| host == user) {
- self.authorize(user, &owner, false).await?;
- } else {
- self.authorize(user, &owner, true).await?;
- }
+ self.authorize_booking(user, &owner, &record).await?;
if record.booking.status != BookingStatus::Confirmed || record.booking.ends_at > Utc::now()
{
return Err(Error::Invalid(
@@ -688,9 +686,19 @@ impl<R: Repository, C: Calendars, D: Directory> Service<R, C, D> {
.profile(record.profile_id)
.await?
.ok_or(Error::NotFound)?;
- self.authorize(user, &owner, true).await?;
+ self.authorize_booking(user, &owner, &record).await?;
Ok(record)
}
+ /// Hosts may manage the meetings they host; anyone else needs admin rights.
+ async fn authorize_booking(
+ &self,
+ user: &str,
+ owner: &OwnedProfile,
+ record: &BookingRecord,
+ ) -> Result<(), Error> {
+ let hosts = record.booking.hosts.iter().any(|host| host == user);
+ self.authorize(user, owner, !hosts).await
+ }
/// Read a booking using its unguessable booker capability.
pub async fn receipt(&self, id: Uuid, token: Uuid) -> Result<BookingRecord, Error> {
let record = self.repository.booking(id).await?.ok_or(Error::NotFound)?;
@@ -809,7 +817,7 @@ impl<R: Repository, C: Calendars, D: Directory> Service<R, C, D> {
.profile(record.profile_id)
.await?
.ok_or(Error::NotFound)?;
- self.authorize(user.ok_or(Error::Forbidden)?, &owner, true)
+ self.authorize_booking(user.ok_or(Error::Forbidden)?, &owner, &record)
.await?;
}
if record.booking.status == BookingStatus::Cancelled {
diff --git a/crates/calendar_scheduling/src/domain/service/test.rs b/crates/calendar_scheduling/src/domain/service/test.rs
index ee4529dd66..f787f51026 100644
--- a/crates/calendar_scheduling/src/domain/service/test.rs
+++ b/crates/calendar_scheduling/src/domain/service/test.rs
@@ -344,7 +344,7 @@ async fn team_permissions_and_host_membership_are_server_enforced() {
let team = Some(Uuid::new_v4());
let p = profile(team);
assert!(matches!(
- service.save("member", team, p.clone()).await,
+ service.save("stranger", team, p.clone()).await,
Err(Error::Forbidden)
));
assert!(matches!(
@@ -357,8 +357,8 @@ async fn team_permissions_and_host_membership_are_server_enforced() {
service.save("admin", team, bad).await,
Err(Error::Invalid(_))
));
- assert!(service.save("admin", team, p).await.is_ok());
- assert!(service.settings("member", team).await.is_ok());
+ assert!(service.save("member", team, p).await.is_ok());
+ assert!(service.settings("admin", team).await.is_ok());
}
#[tokio::test]
async fn personal_calendar_cannot_impersonate_another_host() {
@@ -644,6 +644,45 @@ async fn approval_rechecks_assigned_hosts_even_after_link_removal() {
));
}
+#[tokio::test]
+async fn hosts_manage_the_team_meetings_they_host() {
+ let store = Arc::new(Memory::default());
+ let service = TestService::new(store.clone(), Arc::new(Calendar::default()), Members);
+ let team = Some(Uuid::new_v4());
+ let mut p = profile(team);
+ p.event_types[0].hosts = vec!["member".into()];
+ let p = service.save("admin", team, p).await.unwrap();
+ let r = service
+ .book(p.id, p.event_types[0].id, request())
+ .await
+ .unwrap();
+ let set_hosts = |hosts: &[&str]| {
+ let mut data = store.bookings.lock().unwrap();
+ data.get_mut(&r.booking.id).unwrap().booking.hosts =
+ hosts.iter().map(|host| host.to_string()).collect();
+ };
+ set_hosts(&["admin"]);
+ assert!(matches!(
+ service.manage("member", r.booking.id).await,
+ Err(Error::Forbidden)
+ ));
+ assert!(matches!(
+ service.cancel(r.booking.id, None, Some("member")).await,
+ Err(Error::Forbidden)
+ ));
+ set_hosts(&["member"]);
+ assert!(service.manage("admin", r.booking.id).await.is_ok());
+ assert!(service.manage("member", r.booking.id).await.is_ok());
+ assert_eq!(
+ service
+ .cancel(r.booking.id, None, Some("member"))
+ .await
+ .unwrap()
+ .status,
+ BookingStatus::Cancelled
+ );
+}
+
#[tokio::test]
async fn attendance_requires_finished_confirmed_booking_and_current_host_or_admin() {
let store = Arc::new(Memory::default());
diff --git a/crates/calendar_scheduling/src/domain/service/test/booking_links.rs b/crates/calendar_scheduling/src/domain/service/test/booking_links.rs
index 097c5b59af..00c81fa16e 100644
--- a/crates/calendar_scheduling/src/domain/service/test/booking_links.rs
+++ b/crates/calendar_scheduling/src/domain/service/test/booking_links.rs
@@ -141,7 +141,22 @@ async fn edit_preserves_other_links_hours_and_profile_and_rejects_stale_changes(
}
#[tokio::test]
-async fn invalid_drafts_and_team_non_admins_do_not_write() {
+async fn any_team_member_can_create_a_team_link() {
+ let service = TestService::new(
+ Arc::new(Memory::default()),
+ Arc::new(Calendar::default()),
+ Members,
+ );
+ let team = Some(Uuid::now_v7());
+ let profile = profile(team);
+ let draft = BookingLinkDraft::from_parts(&profile.event_types[0], &profile.schedules[0]);
+ let link = service.create_link("member", team, draft).await.unwrap();
+ let listed = service.list_links("admin", team, None).await.unwrap();
+ assert_eq!(listed.links[0].event_type_id, link.event_type_id);
+}
+
+#[tokio::test]
+async fn invalid_drafts_and_non_members_do_not_write() {
let memory = Arc::new(Memory::default());
let service = TestService::new(memory.clone(), Arc::new(Calendar::default()), Members);
let mut invalid = draft();
@@ -158,7 +173,7 @@ async fn invalid_drafts_and_team_non_admins_do_not_write() {
));
assert!(matches!(
service
- .create_link("member", Some(Uuid::now_v7()), draft())
+ .create_link("stranger", Some(Uuid::now_v7()), draft())
.await,
Err(Error::Forbidden)
));
diff --git a/crates/calendar_scheduling/src/inbound/toolset/get_booking_reschedule_slots.rs b/crates/calendar_scheduling/src/inbound/toolset/get_booking_reschedule_slots.rs
index a118a78e7b..62aa6a195a 100644
--- a/crates/calendar_scheduling/src/inbound/toolset/get_booking_reschedule_slots.rs
+++ b/crates/calendar_scheduling/src/inbound/toolset/get_booking_reschedule_slots.rs
@@ -13,7 +13,7 @@ use uuid::Uuid;
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[schemars(
title = "GetBookingRescheduleSlots",
- description = "Find available replacement times for a booking discovered through ListBookings. The date is in the booking schedule time zone. Only the personal owner or team administrators may reschedule it. Returns absolute start/end times for ChangeBooking reschedule; availability is checked again when moving the meeting."
+ description = "Find available replacement times for a booking discovered through ListBookings. The date is in the booking schedule time zone. Only the personal owner, a host of the meeting or team administrators may reschedule it. Returns absolute start/end times for ChangeBooking reschedule; availability is checked again when moving the meeting."
)]
pub struct GetBookingRescheduleSlots {
/// Existing booking ID from ListBookings.
diff --git a/crates/calendar_scheduling/src/inbound/toolset/update_booking_settings.rs b/crates/calendar_scheduling/src/inbound/toolset/update_booking_settings.rs
index 34b332d9a3..8ecb9995d9 100644
--- a/crates/calendar_scheduling/src/inbound/toolset/update_booking_settings.rs
+++ b/crates/calendar_scheduling/src/inbound/toolset/update_booking_settings.rs
@@ -14,7 +14,7 @@ use uuid::Uuid;
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[schemars(
title = "UpdateBookingSettings",
- description = "Update Booking Links settings after reading ReadBookingSettings. Pass the full profile with its current revision, preserving fields the user did not request changing. Supports booking-page name and introduction; adding, editing and deleting reusable schedules and date overrides; changing defaultScheduleId; reassigning link schedules; duplicating, deleting, enabling or pausing links. Generate new UUIDs for new schedules, links and questions; preserve existing IDs. Changing a shared schedule affects every link referencing it and personal default hours affect team hosting. Deleting a link does not cancel existing bookings. Explain affected links before changing shared hours or deleting. A stale revision fails: re-read and reconcile rather than overwriting. Use CreateBookingLink or EditBookingLink for ordinary single-link authoring and their conversational confirmation contract. Team edits require owner/admin access. Before saving, explain the proposed changes and their personal/team scope, ask whether to proceed, and wait for the user's approving reply in a later turn. Quote that reply verbatim in userConfirmation. Do not use the original request as confirmation."
+ description = "Update Booking Links settings after reading ReadBookingSettings. Pass the full profile with its current revision, preserving fields the user did not request changing. Supports booking-page name and introduction; adding, editing and deleting reusable schedules and date overrides; changing defaultScheduleId; reassigning link schedules; duplicating, deleting, enabling or pausing links. Generate new UUIDs for new schedules, links and questions; preserve existing IDs. Changing a shared schedule affects every link referencing it and personal default hours affect team hosting. Deleting a link does not cancel existing bookings. Explain affected links before changing shared hours or deleting. A stale revision fails: re-read and reconcile rather than overwriting. Use CreateBookingLink or EditBookingLink for ordinary single-link authoring and their conversational confirmation contract. Any team member can edit team settings. Before saving, explain the proposed changes and their personal/team scope, ask whether to proceed, and wait for the user's approving reply in a later turn. Quote that reply verbatim in userConfirmation. Do not use the original request as confirmation."
)]
pub struct UpdateBookingSettings {
/// Existing team ID from discovery, or null for personal settings.
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index 59bc10ae3b..52eab0112b 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -1365,8 +1365,10 @@ Date overrides and the searchable timezone picker sit below the weekly hours.
The header shows the selected owner; team owners have an explicit **Team** label.
Links and availability use flat rows, with actions beside each item.
Booking pages, bookings, and insights show only the selected owner. Search filters
-that owner’s links and clears when switching owners. Team owners/admins can edit
-team links; ordinary members can view them. `Links` creates, edits, pauses,
+that owner’s links and clears when switching owners. Any team member can edit
+team links. Hosts can cancel or reschedule the meetings they host; team
+owners/admins can also manage teammates’ bookings and approve pending ones.
+`Links` creates, edits, pauses,
duplicates, previews, and copies booking links. Event settings include a
video choice. New links default to a Macro call, which is created when
someone books and attached to the calendar invitation. Google Meet and no