handle method
Implementation
@override
Future<StructuredResponse> handle(GlintSession session, CallToolRequest request) async {
final args = request.arguments ?? const {};
final target =
await readTarget(session, args, readTargetedArgs(args, session.config), tool: 'resolve', coordinates: '');
if (target.error != null) return target.error!;
final glintId = target.glintId!;
final scene = await session.reader.readSummary();
try {
if (scene.findByGlintId(glintId) == null) {
final hint = didYouMean(suggestIds(scene.glintIds, glintId));
return StructuredResponse.error(
summary: 'no node with glintId "$glintId" in the current scene',
errorKind: GlintErrorKind.unresolvedTarget,
nextSteps: [
if (labelHint(scene.root, glintId) case final h?) h,
if (hint != null) hint,
're-run get_scene to read current glintIds',
],
);
}
final c = await session.resolver.resolve(scene, glintId);
return StructuredResponse(
summary: 'resolved $glintId at (${pointText(c.logicalCenter.x)}, '
'${pointText(c.logicalCenter.y)}) pt '
'(painted=${c.painted}, hittable=${c.hittable})',
warnings: c.warnings,
data: c.toJson(),
);
} on GeometryResolveError catch (e) {
// Same failure the interactor maps cleanly — resolve must not leak it as
// a raw `internal` stack trace. A non-string eval usually means the node
// has no usable geometry (offstage/zero-size) or the app's VM is wedged.
return StructuredResponse.error(
summary: 'could not resolve geometry for $glintId',
errorKind: GlintErrorKind.geometryResolveError,
detail: e.message,
nextSteps: const [
'the element may be offstage or zero-size — get_scene to confirm it is on screen',
'if the app just threw or hot-reloaded, its VM may be wedged — re-attach or hot-restart',
],
);
} finally {
await scene.dispose();
}
}